Permalink
Browse files

Initial Implementation

  • Loading branch information...
1 parent 58e31be commit f937523eb638402033d19821bbd0680c59a4169e @jlcaro committed Aug 22, 2011
Showing with 3,103 additions and 29 deletions.
  1. 0 __init__.py
  2. BIN db.sqlite
  3. 0 demo/__init__.py
  4. +9 −0 demo/models.py
  5. +16 −0 demo/tests.py
  6. +56 −0 demo/views.py
  7. 0 fileupload/__init__.py
  8. +30 −0 fileupload/forms.py
  9. +8 −0 fileupload/models.py
  10. +100 −0 fileupload/static/fileupload/css/jquery.fileupload-ui.css
  11. +30 −0 fileupload/static/fileupload/css/jqueryui/1.8.14/AUTHORS.txt
  12. +278 −0 fileupload/static/fileupload/css/jqueryui/1.8.14/GPL-LICENSE.txt
  13. +25 −0 fileupload/static/fileupload/css/jqueryui/1.8.14/MIT-LICENSE.txt
  14. BIN fileupload/static/fileupload/css/jqueryui/1.8.14/themes/base/images/ui-bg_flat_0_aaaaaa_40x100.png
  15. BIN fileupload/static/fileupload/css/jqueryui/1.8.14/themes/base/images/ui-bg_flat_75_ffffff_40x100.png
  16. BIN fileupload/static/fileupload/css/jqueryui/1.8.14/themes/base/images/ui-bg_glass_55_fbf9ee_1x400.png
  17. BIN fileupload/static/fileupload/css/jqueryui/1.8.14/themes/base/images/ui-bg_glass_65_ffffff_1x400.png
  18. BIN fileupload/static/fileupload/css/jqueryui/1.8.14/themes/base/images/ui-bg_glass_75_dadada_1x400.png
  19. BIN fileupload/static/fileupload/css/jqueryui/1.8.14/themes/base/images/ui-bg_glass_75_e6e6e6_1x400.png
  20. BIN fileupload/static/fileupload/css/jqueryui/1.8.14/themes/base/images/ui-bg_glass_95_fef1ec_1x400.png
  21. BIN ...static/fileupload/css/jqueryui/1.8.14/themes/base/images/ui-bg_highlight-soft_75_cccccc_1x100.png
  22. BIN fileupload/static/fileupload/css/jqueryui/1.8.14/themes/base/images/ui-icons_222222_256x240.png
  23. BIN fileupload/static/fileupload/css/jqueryui/1.8.14/themes/base/images/ui-icons_2e83ff_256x240.png
  24. BIN fileupload/static/fileupload/css/jqueryui/1.8.14/themes/base/images/ui-icons_454545_256x240.png
  25. BIN fileupload/static/fileupload/css/jqueryui/1.8.14/themes/base/images/ui-icons_888888_256x240.png
  26. BIN fileupload/static/fileupload/css/jqueryui/1.8.14/themes/base/images/ui-icons_cd0a0a_256x240.png
  27. +11 −0 fileupload/static/fileupload/css/jqueryui/1.8.14/themes/base/jquery.ui.all.css
  28. +3 −0 fileupload/static/fileupload/css/jqueryui/1.8.14/themes/base/jquery.ui.base.css
  29. +38 −0 fileupload/static/fileupload/css/jqueryui/1.8.14/themes/base/jquery.ui.button.css
  30. +41 −0 fileupload/static/fileupload/css/jqueryui/1.8.14/themes/base/jquery.ui.core.css
  31. +11 −0 fileupload/static/fileupload/css/jqueryui/1.8.14/themes/base/jquery.ui.progressbar.css
  32. +247 −0 fileupload/static/fileupload/css/jqueryui/1.8.14/themes/base/jquery.ui.theme.css
  33. +1 −0 fileupload/static/fileupload/css/jqueryui/1.8.14/version.txt
  34. +22 −0 fileupload/static/fileupload/css/style.css
  35. +3 −0 fileupload/static/fileupload/css/thumbnail-scaling.css
  36. BIN fileupload/static/fileupload/img/pbar-ani.gif
  37. +42 −0 fileupload/static/fileupload/js/application.js
  38. +18 −0 fileupload/static/fileupload/js/jquery-1.6.2.min.js
  39. +76 −0 fileupload/static/fileupload/js/jquery-ui-1.8.14.custom.min.js
  40. +642 −0 fileupload/static/fileupload/js/jquery.fileupload-ui.js
  41. +720 −0 fileupload/static/fileupload/js/jquery.fileupload.js
  42. +156 −0 fileupload/static/fileupload/js/jquery.iframe-transport.js
  43. +1 −0 fileupload/static/fileupload/js/jquery.templates/beta1/jquery.tmpl.min.js
  44. +31 −0 fileupload/templates/fileupload/file_form.html
  45. +14 −0 fileupload/templates/fileupload/fileupload_filedata.html
  46. +4 −0 fileupload/templates/fileupload/fileupload_head.html
  47. +102 −0 fileupload/templates/fileupload/fileupload_js.html
  48. +2 −0 fileupload/templatetags/__init__.py
  49. +11 −0 fileupload/templatetags/upload_tags.py
  50. +45 −0 fileupload/templatetags/verbatim.py
  51. +16 −0 fileupload/tests.py
  52. +64 −0 fileupload/views.py
  53. +9 −0 fileupload/widgets.py
  54. +14 −0 manage.py
  55. +157 −0 settings.py
  56. +0 −29 templates/demo/noteattachment_form.html
  57. +24 −0 templates/main.html
  58. +26 −0 urls.py
View
No changes.
View
BIN db.sqlite
Binary file not shown.
View
No changes.
View
@@ -0,0 +1,9 @@
+from django.db import models
+
+class Note(models.Model):
+ title = models.CharField(max_length=50)
+ text = models.TextField(null=True, blank=True)
+
+class NoteAttachment(models.Model):
+ file = models.FileField(upload_to='attachments')
+
View
@@ -0,0 +1,16 @@
+"""
+This file demonstrates writing tests using the unittest module. These will pass
+when you run "manage.py test".
+
+Replace this with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+
+class SimpleTest(TestCase):
+ def test_basic_addition(self):
+ """
+ Tests that 1 + 1 always equals 2.
+ """
+ self.assertEqual(1 + 1, 2)
View
@@ -0,0 +1,56 @@
+from django.conf.urls.defaults import *
+
+from demo import models
+from django.views.generic import CreateView, DeleteView
+
+from django.http import HttpResponse
+from django.utils import simplejson
+from django.core.urlresolvers import reverse
+
+from django.conf import settings
+
+def response_mimetype(request):
+ if "application/json" in request.META['HTTP_ACCEPT']:
+ return "application/json"
+ else:
+ return "text/plain"
+
+
+class FileCreateView(CreateView):
+ model = models.NoteAttachment
+
+ def form_valid(self, form):
+ self.object = form.save()
+ f = self.request.FILES.get('file')
+ data = [{
+ 'name': f.name,
+ 'url': settings.MEDIA_URL + "pictures/" + f.name,
+ #'thumbnail_url': settings.MEDIA_URL + "pictures/" + f.name,
+ 'delete_url': reverse('upload-delete', args=[self.object.id]),
+ 'delete_type': "DELETE"
+ }]
+ response = JSONResponse(data, {}, response_mimetype(self.request))
+ response['Content-Disposition'] = 'inline; filename=file.json'
+ return response
+
+
+class FileDeleteView(DeleteView):
+ model = models.NoteAttachment
+
+ def delete(self, request, *args, **kwargs):
+ """
+ This does not actually delete the file, only the database record. But
+ that is easy to implement.
+ """
+ self.object = self.get_object()
+ self.object.delete()
+ response = JSONResponse(True, {}, response_mimetype(self.request))
+ response['Content-Disposition'] = 'inline; filename=files.json'
+ return response
+
+
+class JSONResponse(HttpResponse):
+ """ JSON Response class."""
+ def __init__(self, obj='', json_opts={}, mimetype="application/json", *args, **kwargs):
+ content = simplejson.dumps(obj, **json_opts)
+ super(JSONResponse, self).__init__(content, mimetype, *args, **kwargs)
View
No changes.
View
@@ -0,0 +1,30 @@
+#!/usr/local/bin/python
+# coding: utf-8
+
+from fileupload.widgets import MultipleFileInput
+
+from django import forms
+class FileUploadSimpleForm(forms.Form):
+ file = forms.FileField(widget=MultipleFileInput)
+ file_field = 'file'
+ add_url_name = 'file_add'
+ delete_url_name = 'file_delete'
+ media_url = None
+ submit_url = None
+
+ def get_file_field(self):
+ if not self.file_field:
+ self.file_field = 'file'
+ return self.file_field
+ def get_submit_url(self, *args, **kwargs):
+ if not self.submit_url:
+ self.submit_url = '#'
+ return self.submit_url
+ def get_media_url(self, *args, **kwargs):
+ if not self.media_url:
+ self.media_url = 'uploaded'
+ return self.media_url
+ def get_delete_url_name(self, *args, **kwargs):
+ if not self.delete_url_name:
+ self.delete_url_name = 'file_delete'
+ return self.delete_url_name
View
@@ -0,0 +1,8 @@
+from django.db import models
+
+class FileUploadData(object):
+ def __init__(self, name, url, delete_url=None, delete_type='DELETE'):
+ self.name = name
+ self.url = url
+ self.delete_url = delete_url
+ self.delete_type = delete_type
@@ -0,0 +1,100 @@
+@charset 'UTF-8';
+/*
+ * jQuery File Upload UI Plugin CSS 5.0.6
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2010, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://creativecommons.org/licenses/MIT/
+ */
+
+.fileupload-buttonbar .ui-button input {
+ position: absolute;
+ top: 0;
+ right: 0;
+ margin: 0;
+ border: solid transparent;
+ border-width: 0 0 100px 200px;
+ opacity: 0;
+ filter: alpha(opacity=0);
+ -o-transform: translate(250px, -50px) scale(1);
+ -moz-transform: translate(-300px, 0) scale(4);
+ direction: ltr;
+ cursor: pointer;
+}
+
+.fileinput-button {
+ overflow: hidden;
+}
+
+/* Fix for IE 6: */
+*html .fileinput-button {
+ padding: 2px 0;
+}
+
+/* Fix for IE 7: */
+*+html .fileinput-button {
+ padding: 2px 0;
+}
+
+.fileupload-buttonbar {
+ padding: 0.2em 0.4em;
+}
+
+.fileupload-buttonbar .ui-button {
+ vertical-align: middle;
+}
+
+.fileupload-content {
+ padding: 0.2em 0.4em;
+ border-top-width: 0;
+}
+
+.fileupload-content .ui-progressbar {
+ width: 200px;
+ height: 20px;
+}
+
+.fileupload-content .ui-progressbar-value {
+ background: url(pbar-ani.gif);
+}
+
+.fileupload-content .fileupload-progressbar {
+ width: 400px;
+ margin: 10px 0;
+}
+
+.files {
+ margin: 10px 0;
+ border-collapse: collapse;
+}
+
+.files td {
+ padding: 5px;
+ border-spacing: 5px;
+}
+
+.files img {
+ border: none;
+}
+
+.files .name {
+ padding: 0 10px;
+}
+
+.files .size {
+ padding: 0 10px 0 0;
+ text-align: right;
+ white-space: nowrap;
+}
+
+.ui-state-disabled .ui-state-disabled {
+ opacity: 1;
+ filter: alpha(opacity=100);
+}
+
+.ui-state-disabled input {
+ cursor: default;
+}
@@ -0,0 +1,30 @@
+jQuery UI Authors (http://jqueryui.com/about)
+
+This software consists of voluntary contributions made by many
+individuals. For exact contribution history, see the revision history
+and logs, available at http://github.com/jquery/jquery-ui
+
+Brandon Aaron
+Paul Bakaus (paulbakaus.com)
+David Bolter
+Rich Caloggero
+Chi Cheng (cloudream@gmail.com)
+Colin Clark (http://colin.atrc.utoronto.ca/)
+Michelle D'Souza
+Aaron Eisenberger (aaronchi@gmail.com)
+Ariel Flesler
+Bohdan Ganicky
+Scott González
+Marc Grabanski (m@marcgrabanski.com)
+Klaus Hartl (stilbuero.de)
+Scott Jehl
+Cody Lindley
+Eduardo Lundgren (eduardolundgren@gmail.com)
+Todd Parker
+John Resig
+Patty Toland
+Ca-Phun Ung (yelotofu.com)
+Keith Wood (kbwood@virginbroadband.com.au)
+Maggie Costello Wachs
+Richard D. Worth (rdworth.org)
+Jörn Zaefferer (bassistance.de)
Oops, something went wrong.

0 comments on commit f937523

Please sign in to comment.