Skip to content

Commit ea9cfe6

Browse files
committed
Initial version of django-jquery-file-upload.
* Delete buttons do not work * No resizing of thumbnails (yet) * Probably more...
0 parents  commit ea9cfe6

25 files changed

+2111
-0
lines changed

LICENSE.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The MIT License (MIT)
2+
Copyright (c) 2010, 2011, Sebastian Tschan
3+
Copyright (c) 2011, Sigurd Gartmann
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[jQuery-File-Upload](http://aquantum-demo.appspot.com/file-upload) is developed by Sebastian Tschan, with the source available on [github](https://github.com/blueimp/jQuery-File-Upload). Example code is [ported to Django](https://github.com/sigurdga/django-jquery-file-upload) by Sigurd Gartmann ([sigurdga on github](https://github.com/sigurdga/)).
2+
3+
Introduction
4+
============
5+
6+
This is a small example on how to setup Sebastian Tschan's jQuery File Upload in Django. He has a working demo on his [webpage](http://aquantum-demo.appspot.com/file-upload) and a [github repository](https://github.com/blueimp/jQuery-File-Upload) with an example on how to do it in PHP.
7+
8+
Here, you'll find a minimal Django project with a minimal app. You can run the example standalone by cloning the repository, running the migrations and starting the server.
9+
10+
Detailed instructions will probably be posted when the delete part (the only missing part) and image resize is finished.
11+
12+
I want to give a thank to Sebastian Tschan, the original author, and Jørgen Bergquist for helping me over the first hurdles.
13+
14+
License
15+
=======
16+
MIT, as the original project. See LICENSE.txt.

__init__.py

Whitespace-only changes.

fileupload/__init__.py

Whitespace-only changes.

fileupload/forms.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from django.forms import ModelForm
2+
from fileupload.models import Picture
3+
4+
class PictureForm(ModelForm):
5+
6+
class Meta:
7+
model = Picture
8+

fileupload/migrations/0001_initial.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# encoding: utf-8
2+
import datetime
3+
from south.db import db
4+
from south.v2 import SchemaMigration
5+
from django.db import models
6+
7+
class Migration(SchemaMigration):
8+
9+
def forwards(self, orm):
10+
11+
# Adding model 'Picture'
12+
db.create_table('fileupload_picture', (
13+
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
14+
('file', self.gf('django.db.models.fields.files.ImageField')(max_length=100)),
15+
))
16+
db.send_create_signal('fileupload', ['Picture'])
17+
18+
19+
def backwards(self, orm):
20+
21+
# Deleting model 'Picture'
22+
db.delete_table('fileupload_picture')
23+
24+
25+
models = {
26+
'fileupload.picture': {
27+
'Meta': {'object_name': 'Picture'},
28+
'file': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),
29+
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
30+
}
31+
}
32+
33+
complete_apps = ['fileupload']

fileupload/migrations/__init__.py

Whitespace-only changes.

fileupload/models.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from django.db import models
2+
3+
class Picture(models.Model):
4+
5+
file = models.ImageField(upload_to="pictures")
6+
7+
def __unicode__(self):
8+
return self.file
9+
10+
@models.permalink
11+
def get_absolute_url(self):
12+
return ('upload-new', )
13+

fileupload/static/application.js

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* jQuery File Upload Plugin JS Example 5.0.1
3+
* https://github.com/blueimp/jQuery-File-Upload
4+
*
5+
* Copyright 2010, Sebastian Tschan
6+
* https://blueimp.net
7+
*
8+
* Licensed under the MIT license:
9+
* http://creativecommons.org/licenses/MIT/
10+
*/
11+
12+
/*jslint nomen: false */
13+
/*global $ */
14+
15+
$(function () {
16+
17+
// Initialize the jQuery File Upload widget:
18+
$('#fileupload').fileupload();
19+
20+
// Load existing files:
21+
$.getJSON($('#fileupload form').prop('action'), function (files) {
22+
var fu = $('#fileupload').data('fileupload');
23+
fu._adjustMaxNumberOfFiles(-files.length);
24+
fu._renderDownload(files)
25+
.appendTo($('#fileupload .files'))
26+
.fadeIn(function () {
27+
// Fix for IE7 and lower:
28+
$(this).show();
29+
});
30+
});
31+
32+
// Open download dialogs via iframes,
33+
// to prevent aborting current uploads:
34+
$('#fileupload .files a:not([target^=_blank])').live('click', function (e) {
35+
e.preventDefault();
36+
$('<iframe style="display:none;"></iframe>')
37+
.prop('src', this.href)
38+
.appendTo('body');
39+
});
40+
41+
});
+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
@charset 'UTF-8';
2+
/*
3+
* jQuery File Upload UI Plugin CSS 5.0.5
4+
* https://github.com/blueimp/jQuery-File-Upload
5+
*
6+
* Copyright 2010, Sebastian Tschan
7+
* https://blueimp.net
8+
*
9+
* Licensed under the MIT license:
10+
* http://creativecommons.org/licenses/MIT/
11+
*/
12+
13+
.ui-button input {
14+
position: absolute;
15+
top: 0;
16+
right: 0;
17+
margin: 0;
18+
border: solid transparent;
19+
border-width: 0 0 100px 200px;
20+
opacity: 0;
21+
filter: alpha(opacity=0);
22+
-o-transform: translate(250px, -50px) scale(1);
23+
-moz-transform: translate(-300px, 0) scale(4);
24+
direction: ltr;
25+
cursor: pointer;
26+
}
27+
28+
.fileinput-button {
29+
overflow: hidden;
30+
}
31+
32+
/* Fix for IE 6: */
33+
*html .fileinput-button {
34+
padding: 2px 0;
35+
}
36+
37+
/* Fix for IE 7: */
38+
*+html .fileinput-button {
39+
padding: 2px 0;
40+
}
41+
42+
.fileupload-buttonbar {
43+
padding: 0.2em 0.4em;
44+
}
45+
46+
.fileupload-buttonbar .ui-button {
47+
vertical-align: middle;
48+
}
49+
50+
.fileupload-content {
51+
padding: 0.2em 0.4em;
52+
border-top-width: 0;
53+
}
54+
55+
.ui-progressbar {
56+
width: 200px;
57+
height: 20px;
58+
}
59+
60+
.ui-progressbar-value {
61+
background: url(pbar-ani.gif);
62+
}
63+
64+
.fileupload-progressbar {
65+
width: 400px;
66+
margin: 10px 0;
67+
}
68+
69+
.files {
70+
margin: 10px 0;
71+
border-collapse: collapse;
72+
}
73+
74+
.files td {
75+
padding: 5px;
76+
border-spacing: 5px;
77+
}
78+
79+
.files img {
80+
border: none;
81+
}
82+
83+
.files .name {
84+
padding: 0 10px;
85+
}
86+
87+
.files .size {
88+
padding: 0 10px 0 0;
89+
text-align: right;
90+
white-space: nowrap;
91+
}
92+
93+
.ui-state-disabled .ui-state-disabled {
94+
opacity: 1;
95+
filter: alpha(opacity=100);
96+
}
97+
98+
.ui-state-disabled input {
99+
cursor: default;
100+
}

0 commit comments

Comments
 (0)