Commits

Scott Nixon committed 9f55ea2

Workflow completed. Improvements still needed but it is a working app.

  • Participants
  • Parent commits d50d5f8

Comments (0)

Files changed (2)

 	    filename = file.name
             content = file
 	    store_in_s3(filename, content)
-            urljson = json.dumps(url)
+
         except IOError, e:
             print e
 
-	return HttpResponse(urljson)
+	return HttpResponse(url)
     def render(self, name, value, attrs=None):
         rendered = super(CloudImages, self).render(name, value, attrs)
         return rendered + mark_safe(u'''<script type="text/javascript">
+            /* Declaring global so it can be passed between functions. */
+            var Cloudiurl = ''; 
             $(document).ready(function () {
-                $('#id_%s').after("<a class='cloudimages' href='/cloud/'>Upload Image</a>");
+                /* Add the link to upload after the input box. */
+                $('#id_%s').after("<a class='cloudimages' style='margin:0em 1em;font-size:14px;' href='/cloud/'>Upload Image</a>");
+                /* Bind fancybox to the class as an iframe. Once the file upload
+                   is complete get the image link and add it to the form field */
                 $('.cloudimages').fancybox({
                 'autoScale'         : false,
                 'transitionIn'      : 'none',
                 'transitionOut'     : 'none',
-                'type'              : 'iframe'
+                'type'              : 'iframe',
+                 onCleanup          : function () {
+                     Cloudiurl = $('iframe#fancybox-frame').contents().text();           
+                      },
+                 onClosed           : function () {
+                     $('#id_%s').val(Cloudiurl);
+                                            }
                  });
 
             });                        
-            </script>''' % (name,))
+            </script>''' % (name, name))