Skip to content

Commit 5bc6a9b

Browse files
committed
Updated to the latest version of jQuery-File-Upload. Added a simple template without the use of additional libraries.
1 parent 575c3e1 commit 5bc6a9b

29 files changed

+1741
-97
lines changed

README

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,71 @@
1-
Yet another plugin for uploading files to the server using Django and JQuery.
1+
Yet another plugin for uploading files to the server using
2+
Django and JQuery.
23

3-
Based on jQuery-File-Upload written by Sebastian Tschan (https://github.com/blueimp/jQuery-File-Upload).
4+
Based on jQuery-File-Upload written by Sebastian Tschan
5+
(https://github.com/blueimp/jQuery-File-Upload).
46

5-
The project is still in its infancy.
7+
8+
Requirements
9+
10+
- PIL (Python Imaging Library) for thumbnails generation
11+
- Django 1.4 +
12+
13+
14+
Installation
15+
16+
1. Add app to your INSTALLED_APPS:
17+
INSTALLED_APPS = (
18+
...
19+
'jquery_uploader',
20+
...
21+
)
22+
23+
24+
2. Register urls in your root urls.py:
25+
urlpatterns = patterns('',
26+
...
27+
url(r'^jquery_uploader/', include('jquery_uploader.urls')),
28+
...
29+
)
30+
31+
32+
3. If necessary, you must configure the directory for temporary storage
33+
of uploaded files and link to it, and also the size of created thumbnails:
34+
# by default
35+
JQUERY_UPLOADER_ROOT = 'jquery_uploader'
36+
JQUERY_UPLOADER_URL = 'jquery_uploader'
37+
JQUERY_UPLOADER_PREVIEW_MAX_HEIGHT = 140
38+
JQUERY_UPLOADER_PREVIEW_MAX_WIDTH = 200
39+
JQUERY_UPLOADER_MAX_FILE_SIZE = 10485760
40+
41+
42+
4. Simple example use in the project:
43+
44+
4.1. In template:
45+
<form action="/your-url-for-upload-and-save/" method="POST">
46+
{% csrf_token %}
47+
{% load jquery_uploader_tags %}
48+
{% jquery_uploader_simple %}
49+
{# or for JQuery UI {% jquery_uploader_jqueryui %} #}
50+
{# or for Bootstrap {% jquery_uploader_bootstrap %} #}
51+
<input type="submit" />
52+
</form>
53+
54+
Also, for certain cases, you can specify a maximum file size with the templatetag argument:
55+
56+
{% jquery_uploader_simple 1048576 %}
57+
58+
4.2. In model and in views (downloaded files are returned by variable 'jquery_uploader_files'):
59+
# model
60+
class Photo(models.Model):
61+
photo = models.ImageField(upload_to='photo')
62+
63+
# view
64+
from jquery_uploader.utils import save_to_model
65+
66+
if request.method == 'POST':
67+
files = request.POST.getlist('jquery_uploader_files', None)
68+
for f in files:
69+
p = Photo()
70+
save_to_model(p.photo, f)
71+
p.save()
210 Bytes
Binary file not shown.

jquery_uploader/locale/ru/LC_MESSAGES/django.po

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2013-04-11 16:16+0300\n"
11+
"POT-Creation-Date: 2013-07-12 10:12+0300\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -19,35 +19,57 @@ msgstr ""
1919
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
2020
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
2121

22-
#: templates/jquery_uploader/bootstrap.html:14
22+
#: templates/jquery_uploader/bootstrap.html:15
2323
msgid "Add files..."
2424
msgstr "Добавить файлы..."
2525

26-
#: templates/jquery_uploader/bootstrap.html:19
26+
#: templates/jquery_uploader/bootstrap.html:20
2727
msgid "Start upload"
2828
msgstr "Начать загрузку"
2929

30-
#: templates/jquery_uploader/bootstrap.html:23
30+
#: templates/jquery_uploader/bootstrap.html:24
3131
msgid "Cancel upload"
3232
msgstr "Отменить загрузку"
3333

34-
#: templates/jquery_uploader/bootstrap.html:27
35-
#: templates/jquery_uploader/bootstrap.html:105
34+
#: templates/jquery_uploader/bootstrap.html:28
35+
#: templates/jquery_uploader/simple.html:92
3636
msgid "Delete"
3737
msgstr "Удалить"
3838

39-
#: templates/jquery_uploader/bootstrap.html:34
39+
#: templates/jquery_uploader/bootstrap.html:35
40+
#: templates/jquery_uploader/jquery-ui.html:31
41+
#: templates/jquery_uploader/simple.html:25
4042
msgid "Global Progress"
4143
msgstr "Общий прогресс"
4244

43-
#: templates/jquery_uploader/bootstrap.html:44
45+
#: templates/jquery_uploader/bootstrap.html:45
46+
#: templates/jquery_uploader/jquery-ui.html:41
47+
#: templates/jquery_uploader/simple.html:35
4448
msgid "Selected files for download"
4549
msgstr "Выбранные файлы для загрузки"
4650

47-
#: templates/jquery_uploader/bootstrap.html:66
51+
#: templates/jquery_uploader/bootstrap.html:74
4852
msgid "Start"
4953
msgstr "Загрузить"
5054

51-
#: templates/jquery_uploader/bootstrap.html:75
55+
#: templates/jquery_uploader/bootstrap.html:80
56+
#: templates/jquery_uploader/simple.html:62
5257
msgid "Cancel"
5358
msgstr "Отменить"
59+
60+
#: templates/jquery_uploader/simple.html:13
61+
msgid "Add files"
62+
msgstr "Добавить файлы"
63+
64+
#: templates/jquery_uploader/simple.html:55
65+
#: templates/jquery_uploader/simple.html:84
66+
msgid "Error"
67+
msgstr "Ошибка"
68+
69+
#: templates/jquery_uploader/simple.html:57
70+
msgid "Ready for loading"
71+
msgstr "Готов к загрузке"
72+
73+
#: templates/jquery_uploader/simple.html:86
74+
msgid "Loaded"
75+
msgstr "Загружен"

jquery_uploader/settings.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from django.conf import settings
44

5+
56
uploader_days_diff = getattr(settings, 'JQUERY_UPLOADER_DAYS_DIFF', 1)
67

78
uploader_root_rel = getattr(settings, 'JQUERY_UPLOADER_ROOT', 'jquery_uploader')
@@ -12,4 +13,9 @@
1213
if not os.path.exists(uploader_root):
1314
os.makedirs(uploader_root)
1415

15-
uploader_size = getattr(settings, 'JQUERY_UPLOADER_THUMB_SIZE', (80, 80))
16+
uploader_preview_max_height = getattr(settings, 'JQUERY_UPLOADER_PREVIEW_MAX_HEIGHT', 140)
17+
uploader_preview_max_width = getattr(settings, 'JQUERY_UPLOADER_PREVIEW_MAX_WIDTH', 200)
18+
19+
uploader_size = (uploader_preview_max_width, uploader_preview_max_height)
20+
21+
uploader_max_file_size = getattr(settings, 'JQUERY_UPLOADER_MAX_FILE_SIZE', 10485760)
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
@charset "UTF-8";
2+
/*
3+
* jQuery File Upload UI Plugin CSS 7.4
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://www.opensource.org/licenses/MIT
11+
*/
12+
13+
.fileinput-button {
14+
position: relative;
15+
overflow: hidden;
16+
float: left;
17+
margin-right: 5px;
18+
}
19+
.fileinput-button input {
20+
position: absolute;
21+
top: 0;
22+
right: 0;
23+
margin: 0;
24+
opacity: 0;
25+
filter: alpha(opacity=0);
26+
transform: translate(-300px, 0) scale(4);
27+
font-size: 23px;
28+
direction: ltr;
29+
cursor: pointer;
30+
}
31+
.fileupload-buttonbar .ui-button,
32+
.fileupload-buttonbar .toggle {
33+
margin-bottom: 5px;
34+
}
35+
.files .progress {
36+
width: 200px;
37+
}
38+
.files .progress,
39+
.fileupload-buttonbar .progress {
40+
height: 20px;
41+
}
42+
.files .ui-progressbar-value,
43+
.fileupload-buttonbar .ui-progressbar-value {
44+
background: url(../img/progressbar.gif);
45+
}
46+
.fileupload-buttonbar .fade,
47+
.files .fade {
48+
display: none;
49+
}
50+
.fileupload-loading {
51+
position: absolute;
52+
left: 50%;
53+
width: 128px;
54+
height: 128px;
55+
background: url(../img/loading.gif) center no-repeat;
56+
display: none;
57+
}
58+
.fileupload-processing .fileupload-loading {
59+
display: block;
60+
}
61+
62+
/* Fix for IE 6: */
63+
* html .fileinput-button {
64+
margin-right: 1px;
65+
}
66+
* html .fileinput-button .ui-button-text {
67+
line-height: 24px;
68+
}
69+
* html .fileupload-buttonbar .ui-button {
70+
margin-left: 3px;
71+
}
72+
73+
/* Fix for IE 7: */
74+
* + html .fileinput-button {
75+
margin-right: 4px;
76+
}
77+
* + html .fileinput-button .ui-button-text {
78+
line-height: 24px;
79+
}
80+
* + html .fileupload-buttonbar .ui-button {
81+
margin-left: 3px;
82+
}
83+
84+
@media (max-width: 767px) {
85+
.fileupload-buttonbar .toggle,
86+
.files .toggle,
87+
.files .btn span {
88+
display: none;
89+
}
90+
.files .preview * {
91+
width: 40px;
92+
}
93+
.files .name * {
94+
width: 80px;
95+
display: inline-block;
96+
word-wrap: break-word;
97+
}
98+
.files .progress {
99+
width: 20px;
100+
}
101+
}
102+
103+
/* Fix for Webkit (Safari, Chrome) */
104+
@media screen and (-webkit-min-device-pixel-ratio:0) {
105+
.fileinput-button {
106+
margin-top: 2px;
107+
}
108+
}
109+
110+
111+
.fileupload {
112+
background-color: #f5f5f5;
113+
outline: 1px solid #e5e5e5;
114+
padding: 10px;
115+
}
116+
117+
118+
.fileupload table {
119+
border-collapse: collapse;
120+
}
121+
122+
.template-upload td {
123+
background-color: #f5f5f5;
124+
border-top: 1px solid #d0d0d0;
125+
padding: 5px 20px 10px 10px;
126+
}

0 commit comments

Comments
 (0)