From 9957fcc02907d81aea1aaa4f6a043278b1c9411d Mon Sep 17 00:00:00 2001
From: alex
Date: Fri, 22 May 2015 13:07:54 +0400
Subject: [PATCH 01/15] Fix project structure to Django 1.8
---
.gitignore | 3 +-
.../__init__.py | 0
.../settings.py | 1 +
urls.py => django-jquery-file-upload/urls.py | 0
manage.py | 30 ++++++++++++-------
requirements.txt | 2 +-
6 files changed, 24 insertions(+), 12 deletions(-)
rename __init__.py => django-jquery-file-upload/__init__.py (100%)
rename settings.py => django-jquery-file-upload/settings.py (98%)
rename urls.py => django-jquery-file-upload/urls.py (100%)
diff --git a/.gitignore b/.gitignore
index b0d4e48..55e6249 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,8 +7,9 @@ db
/share
/env
/venv
-/django-jquery-file-upload
+
*.log
*.pot
*.pyc
local_settings.py
+.idea
\ No newline at end of file
diff --git a/__init__.py b/django-jquery-file-upload/__init__.py
similarity index 100%
rename from __init__.py
rename to django-jquery-file-upload/__init__.py
diff --git a/settings.py b/django-jquery-file-upload/settings.py
similarity index 98%
rename from settings.py
rename to django-jquery-file-upload/settings.py
index 68744b1..d7e49bd 100644
--- a/settings.py
+++ b/django-jquery-file-upload/settings.py
@@ -100,6 +100,7 @@
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
+ 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
)
ROOT_URLCONF = 'django-jquery-file-upload.urls'
diff --git a/urls.py b/django-jquery-file-upload/urls.py
similarity index 100%
rename from urls.py
rename to django-jquery-file-upload/urls.py
diff --git a/manage.py b/manage.py
index 3e4eedc..92a4d6e 100755
--- a/manage.py
+++ b/manage.py
@@ -1,14 +1,24 @@
#!/usr/bin/env python
-from django.core.management import execute_manager
-import imp
-try:
- imp.find_module('settings') # Assumed to be in the same directory.
-except ImportError:
- import sys
- sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
- sys.exit(1)
+# from django.core.management import execute_manager
+# import imp
+# try:
+# imp.find_module('settings') # Assumed to be in the same directory.
+# except ImportError:
+# import sys
+# sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
+# sys.exit(1)
+#
+# import settings
+#
+# if __name__ == "__main__":
+# execute_manager(settings)
-import settings
+#!/usr/bin/env python
+import os, sys
if __name__ == "__main__":
- execute_manager(settings)
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django-jquery-file-upload.settings")
+
+ from django.core.management import execute_from_command_line
+
+ execute_from_command_line(sys.argv)
diff --git a/requirements.txt b/requirements.txt
index 23cb63a..67a04d6 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,2 @@
-django<1.6
+django
pillow
From fe06a23c191aab7f6b7d0a9de489da240a6b9d3a Mon Sep 17 00:00:00 2001
From: alex
Date: Fri, 22 May 2015 13:12:19 +0400
Subject: [PATCH 02/15] Fix using django.utils.simplejson. Now use json.
---
fileupload/response.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fileupload/response.py b/fileupload/response.py
index 829685a..334eb29 100644
--- a/fileupload/response.py
+++ b/fileupload/response.py
@@ -1,6 +1,6 @@
# encoding: utf-8
from django.http import HttpResponse
-from django.utils import simplejson
+import json
MIMEANY = '*/*'
MIMEJSON = 'application/json'
@@ -34,5 +34,5 @@ def a_iew(request):
"""
def __init__(self, obj='', json_opts=None, mimetype=MIMEJSON, *args, **kwargs):
json_opts = json_opts if isinstance(json_opts, dict) else {}
- content = simplejson.dumps(obj, **json_opts)
+ content = json.dumps(obj, **json_opts)
super(JSONResponse, self).__init__(content, mimetype, *args, **kwargs)
From 3a9ea7fd4594b17f30f8cdd2197c0b91b3faed3a Mon Sep 17 00:00:00 2001
From: alex
Date: Fri, 22 May 2015 13:14:54 +0400
Subject: [PATCH 03/15] Add 'fields' to PictureCreateView
---
fileupload/views.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/fileupload/views.py b/fileupload/views.py
index 98b339c..e9f6b01 100644
--- a/fileupload/views.py
+++ b/fileupload/views.py
@@ -10,6 +10,7 @@
class PictureCreateView(CreateView):
model = Picture
+ fields = "__all__"
def form_valid(self, form):
self.object = form.save()
From 82155f3caad1220eeb2ee718142c5aace8600f87 Mon Sep 17 00:00:00 2001
From: alex
Date: Fri, 22 May 2015 13:21:07 +0400
Subject: [PATCH 04/15] Fix serve media files path
---
django-jquery-file-upload/urls.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/django-jquery-file-upload/urls.py b/django-jquery-file-upload/urls.py
index 00270ad..0c3e2d4 100644
--- a/django-jquery-file-upload/urls.py
+++ b/django-jquery-file-upload/urls.py
@@ -19,7 +19,7 @@
url(r'^admin/', include(admin.site.urls)),
)
-import os
+from os.path import join, abspath, dirname
urlpatterns += patterns('',
- (r'^media/(.*)$', 'django.views.static.serve', {'document_root': os.path.join(os.path.abspath(os.path.dirname(__file__)), 'media')}),
+ (r'^media/(.*)$', 'django.views.static.serve', {'document_root': join(abspath(dirname(dirname(__file__))), 'media')}),
)
From 8b7bb906df393f213b087553e16ee27710dab8fb Mon Sep 17 00:00:00 2001
From: Sigurd Gartmann
Date: Sat, 23 May 2015 18:13:34 +0200
Subject: [PATCH 05/15] Still saving images to /media under
django-jquery-file-upload app.
---
.gitignore | 4 ++--
django-jquery-file-upload/urls.py | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/.gitignore b/.gitignore
index 55e6249..8fef53c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,9 +7,9 @@ db
/share
/env
/venv
-
+/django-jquery-file-upload/media
*.log
*.pot
*.pyc
local_settings.py
-.idea
\ No newline at end of file
+.idea
diff --git a/django-jquery-file-upload/urls.py b/django-jquery-file-upload/urls.py
index 0c3e2d4..7072912 100644
--- a/django-jquery-file-upload/urls.py
+++ b/django-jquery-file-upload/urls.py
@@ -21,5 +21,5 @@
from os.path import join, abspath, dirname
urlpatterns += patterns('',
- (r'^media/(.*)$', 'django.views.static.serve', {'document_root': join(abspath(dirname(dirname(__file__))), 'media')}),
+ (r'^media/(.*)$', 'django.views.static.serve', {'document_root': join(abspath(dirname(__file__)), 'media')}),
)
From a9b307c9e2670c044a97f2961206404b0c1d517d Mon Sep 17 00:00:00 2001
From: Sigurd Gartmann
Date: Tue, 7 Jun 2016 22:24:48 +0200
Subject: [PATCH 06/15] Upgrade to Django 1.9
---
django-jquery-file-upload/settings.py | 194 +++++++-----------
django-jquery-file-upload/urls.py | 22 +-
django-jquery-file-upload/wsgi.py | 11 +
fileupload/apps.py | 6 +
fileupload/migrations/0001_initial.py | 24 +++
fileupload/migrations/__init__.py | 0
fileupload/models.py | 2 +-
.../fileupload/picture_angular_form.html | 36 ++--
.../fileupload/picture_basic_form.html | 12 +-
.../fileupload/picture_basicplus_form.html | 26 +--
.../templates/fileupload/picture_form.html | 38 ++--
.../fileupload/picture_jquery_form.html | 40 ++--
fileupload/templates/upload_base.html | 8 +-
fileupload/urls.py | 6 +-
14 files changed, 202 insertions(+), 223 deletions(-)
create mode 100644 django-jquery-file-upload/wsgi.py
create mode 100644 fileupload/apps.py
create mode 100644 fileupload/migrations/0001_initial.py
create mode 100644 fileupload/migrations/__init__.py
diff --git a/django-jquery-file-upload/settings.py b/django-jquery-file-upload/settings.py
index d7e49bd..d27d9db 100644
--- a/django-jquery-file-upload/settings.py
+++ b/django-jquery-file-upload/settings.py
@@ -1,149 +1,95 @@
+"""
+Django settings.
+"""
+
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
+BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+# SECURITY WARNING: keep the secret key used in production secret!
+SECRET_KEY = '9%$in^gpdaig@v3or_to&_z(=n)3)$f1mr3hf9e#kespy2ajlo'
+
+# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
-TEMPLATE_DEBUG = DEBUG
-SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
+ALLOWED_HOSTS = []
+
+# Application definition
-ADMINS = (
- # ('Your Name', 'your_email@example.com'),
+INSTALLED_APPS = (
+ 'fileupload.apps.FileuploadConfig',
+ 'django.contrib.admin',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.messages',
+ 'django.contrib.staticfiles',
+)
+
+MIDDLEWARE_CLASSES = (
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.middleware.common.CommonMiddleware',
+ 'django.middleware.csrf.CsrfViewMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
+ 'django.contrib.messages.middleware.MessageMiddleware',
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
+ 'django.middleware.security.SecurityMiddleware',
)
-MANAGERS = ADMINS
+ROOT_URLCONF = 'django-jquery-file-upload.urls'
+
+TEMPLATES = [
+ {
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ #'DIRS': ['django-jquery-file-upload/templates'],
+ 'APP_DIRS': True,
+ 'OPTIONS': {
+ 'context_processors': [
+ 'django.template.context_processors.debug',
+ 'django.template.context_processors.request',
+ 'django.contrib.auth.context_processors.auth',
+ 'django.contrib.messages.context_processors.messages',
+ ],
+ },
+ },
+]
+
+WSGI_APPLICATION = 'django-jquery-file-upload.wsgi.application'
+
+
+# Database
+# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
'default': {
- 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
- 'NAME': os.path.join(SITE_ROOT, 'db'), # Or path to database file if using sqlite3.
- 'USER': '', # Not used with sqlite3.
- 'PASSWORD': '', # Not used with sqlite3.
- 'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
- 'PORT': '', # Set to empty string for default. Not used with sqlite3.
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': os.path.join(BASE_DIR, 'db'),
}
}
-# Local time zone for this installation. Choices can be found here:
-# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
-# although not all choices may be available on all operating systems.
-# On Unix systems, a value of None will cause Django to use the same
-# timezone as the operating system.
-# If running in a Windows environment this must be set to the same as your
-# system time zone.
-TIME_ZONE = 'America/Chicago'
-
-# Language code for this installation. All choices can be found here:
-# http://www.i18nguy.com/unicode/language-identifiers.html
+
+# Internationalization
+# https://docs.djangoproject.com/en/1.8/topics/i18n/
+
LANGUAGE_CODE = 'en-us'
-SITE_ID = 1
+TIME_ZONE = 'Europe/Oslo'
-# If you set this to False, Django will make some optimizations so as not
-# to load the internationalization machinery.
USE_I18N = True
-# If you set this to False, Django will not format dates, numbers and
-# calendars according to the current locale
USE_L10N = True
-# Absolute filesystem path to the directory that will hold user-uploaded files.
-# Example: "/home/media/media.lawrence.com/media/"
-MEDIA_ROOT = os.path.abspath(os.path.dirname(__file__)) + '/media/'
+USE_TZ = True
-# URL that handles the media served from MEDIA_ROOT. Make sure to use a
-# trailing slash.
-# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
-MEDIA_URL = '/media/'
-
-# Absolute path to the directory static files should be collected to.
-# Don't put anything in this directory yourself; store your static files
-# in apps' "static/" subdirectories and in STATICFILES_DIRS.
-# Example: "/home/media/media.lawrence.com/static/"
-STATIC_ROOT = os.path.abspath(os.path.dirname(__file__)) + '/static/'
-# URL prefix for static files.
-# Example: "http://media.lawrence.com/static/"
+# Static files (CSS, JavaScript, Images)
STATIC_URL = '/static/'
-# URL prefix for admin static files -- CSS, JavaScript and images.
-# Make sure to use a trailing slash.
-# Examples: "http://foo.com/static/admin/", "/static/admin/".
-ADMIN_MEDIA_PREFIX = '/static/admin/'
-
-# Additional locations of static files
-STATICFILES_DIRS = (
- # Put strings here, like "/home/html/static" or "C:/www/django/static".
- # Always use forward slashes, even on Windows.
- # Don't forget to use absolute paths, not relative paths.
-)
+STATICFILES_DIRS = [
+ 'django-jquery-file-upload/static',
+]
-# List of finder classes that know how to find static files in
-# various locations.
-STATICFILES_FINDERS = (
- 'django.contrib.staticfiles.finders.FileSystemFinder',
- 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
-# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
-)
-
-# Make this unique, and don't share it with anybody.
-SECRET_KEY = '9%$in^gpdaig@v3or_to&_z(=n)3)$f1mr3hf9e#kespy2ajlo'
-
-# List of callables that know how to import templates from various sources.
-TEMPLATE_LOADERS = (
- 'django.template.loaders.filesystem.Loader',
- 'django.template.loaders.app_directories.Loader',
-# 'django.template.loaders.eggs.Loader',
-)
-
-MIDDLEWARE_CLASSES = (
- 'django.middleware.common.CommonMiddleware',
- 'django.contrib.sessions.middleware.SessionMiddleware',
- 'django.middleware.csrf.CsrfViewMiddleware',
- 'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.contrib.messages.middleware.MessageMiddleware',
- 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
-)
-
-ROOT_URLCONF = 'django-jquery-file-upload.urls'
-
-TEMPLATE_DIRS = (
- # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
- # Always use forward slashes, even on Windows.
- # Don't forget to use absolute paths, not relative paths.
-)
-
-INSTALLED_APPS = (
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.sites',
- 'django.contrib.messages',
- 'django.contrib.staticfiles',
- 'fileupload',
- # Uncomment the next line to enable the admin:
- 'django.contrib.admin',
- # Uncomment the next line to enable admin documentation:
- # 'django.contrib.admindocs',
-)
-
-# A sample logging configuration. The only tangible logging
-# performed by this configuration is to send an email to
-# the site admins on every HTTP 500 error.
-# See http://docs.djangoproject.com/en/dev/topics/logging for
-# more details on how to customize your logging configuration.
-LOGGING = {
- 'version': 1,
- 'disable_existing_loggers': False,
- 'handlers': {
- 'mail_admins': {
- 'level': 'ERROR',
- 'class': 'django.utils.log.AdminEmailHandler'
- }
- },
- 'loggers': {
- 'django.request': {
- 'handlers': ['mail_admins'],
- 'level': 'ERROR',
- 'propagate': True,
- },
- }
-}
+MEDIA_URL = '/media/'
+MEDIA_ROOT = os.path.join(BASE_DIR, 'django-jquery-file-upload', 'media')
diff --git a/django-jquery-file-upload/urls.py b/django-jquery-file-upload/urls.py
index 7072912..53f314a 100644
--- a/django-jquery-file-upload/urls.py
+++ b/django-jquery-file-upload/urls.py
@@ -1,25 +1,17 @@
-from django.conf.urls import patterns, include, url
+from django.conf.urls import include, url
from django.http import HttpResponseRedirect
+from django.conf import settings
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
-urlpatterns = patterns('',
- # Examples:
- # url(r'^$', 'upload.views.home', name='home'),
-
+urlpatterns = [
url(r'^$', lambda x: HttpResponseRedirect('/upload/new/')),
url(r'^upload/', include('fileupload.urls')),
-
- # Uncomment the admin/doc line below to enable admin documentation:
- # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
-
- # Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
-)
+]
-from os.path import join, abspath, dirname
-urlpatterns += patterns('',
- (r'^media/(.*)$', 'django.views.static.serve', {'document_root': join(abspath(dirname(__file__)), 'media')}),
-)
+if settings.DEBUG:
+ from django.conf.urls.static import static
+ urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
diff --git a/django-jquery-file-upload/wsgi.py b/django-jquery-file-upload/wsgi.py
new file mode 100644
index 0000000..8e47fba
--- /dev/null
+++ b/django-jquery-file-upload/wsgi.py
@@ -0,0 +1,11 @@
+"""
+WSGI config for django-jquery-file-upload project.
+"""
+
+import os
+
+from django.core.wsgi import get_wsgi_application
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django-jquery-file-upload.settings")
+
+application = get_wsgi_application()
diff --git a/fileupload/apps.py b/fileupload/apps.py
new file mode 100644
index 0000000..ff22d3e
--- /dev/null
+++ b/fileupload/apps.py
@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class FileuploadConfig(AppConfig):
+ name = 'fileupload'
+
diff --git a/fileupload/migrations/0001_initial.py b/fileupload/migrations/0001_initial.py
new file mode 100644
index 0000000..0c157ef
--- /dev/null
+++ b/fileupload/migrations/0001_initial.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.6 on 2016-06-07 19:15
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Picture',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('file', models.ImageField(upload_to='pictures')),
+ ('slug', models.SlugField(blank=True)),
+ ],
+ ),
+ ]
diff --git a/fileupload/migrations/__init__.py b/fileupload/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/fileupload/models.py b/fileupload/models.py
index f28d242..81a20a3 100644
--- a/fileupload/models.py
+++ b/fileupload/models.py
@@ -12,7 +12,7 @@ class Picture(models.Model):
file = models.ImageField(upload_to="pictures")
slug = models.SlugField(max_length=50, blank=True)
- def __unicode__(self):
+ def __str__(self):
return self.file.name
@models.permalink
diff --git a/fileupload/templates/fileupload/picture_angular_form.html b/fileupload/templates/fileupload/picture_angular_form.html
index a5ac9c0..a6add16 100644
--- a/fileupload/templates/fileupload/picture_angular_form.html
+++ b/fileupload/templates/fileupload/picture_angular_form.html
@@ -24,13 +24,13 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -206,34 +206,34 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
diff --git a/fileupload/urls.py b/fileupload/urls.py
index dbbcbca..7a52c3a 100644
--- a/fileupload/urls.py
+++ b/fileupload/urls.py
@@ -1,12 +1,12 @@
# encoding: utf-8
-from django.conf.urls import patterns, url
+from django.conf.urls import url
from fileupload.views import (
BasicVersionCreateView, BasicPlusVersionCreateView,
jQueryVersionCreateView, AngularVersionCreateView,
PictureCreateView, PictureDeleteView, PictureListView,
)
-urlpatterns = patterns('',
+urlpatterns = [
url(r'^basic/$', BasicVersionCreateView.as_view(), name='upload-basic'),
url(r'^basic/plus/$', BasicPlusVersionCreateView.as_view(), name='upload-basic-plus'),
url(r'^new/$', PictureCreateView.as_view(), name='upload-new'),
@@ -14,4 +14,4 @@
url(r'^jquery-ui/$', jQueryVersionCreateView.as_view(), name='upload-jquery'),
url(r'^delete/(?P\d+)$', PictureDeleteView.as_view(), name='upload-delete'),
url(r'^view/$', PictureListView.as_view(), name='upload-view'),
-)
+]
From ff8631f0453fea82caa08ca9dc78338e122be708 Mon Sep 17 00:00:00 2001
From: Sigurd Gartmann
Date: Tue, 7 Jun 2016 22:25:59 +0200
Subject: [PATCH 07/15] Update README to use migrate instead of syncdb.
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 8f185a9..d28dde2 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ Installation
============
* pip install -r requirements.txt (will install django and pillow)
-* python manage.py syncdb
+* python manage.py migrate
* python manage.py runserver
* go to localhost:8000/upload/new/ and upload some files
From da99c92b0f3ecb19d4b1b44ce99e96d33060ccfc Mon Sep 17 00:00:00 2001
From: Sigurd Gartmann
Date: Wed, 8 Jun 2016 00:22:51 +0200
Subject: [PATCH 08/15] Escaping rules has changed in Django 1.9.
Using mark_safe for the template.
Fixes #61
---
fileupload/templatetags/upload_tags.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fileupload/templatetags/upload_tags.py b/fileupload/templatetags/upload_tags.py
index d492e0b..dd667e4 100644
--- a/fileupload/templatetags/upload_tags.py
+++ b/fileupload/templatetags/upload_tags.py
@@ -1,10 +1,11 @@
from django import template
+from django.utils.safestring import mark_safe
register = template.Library()
@register.simple_tag
def upload_js():
- return """
+ return mark_safe("""
-"""
+""")
From d9ac52d332a0529a675a5c5892e03324591a49ff Mon Sep 17 00:00:00 2001
From: Alejandro Brunacci
Date: Wed, 24 Jan 2018 13:22:28 -0300
Subject: [PATCH 09/15] Fix requirements.txt: Setting django version to 1.9 and
pillow to 5.0.0
---
requirements.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/requirements.txt b/requirements.txt
index 67a04d6..64f06b0 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,2 @@
-django
-pillow
+django==1.9
+pillow==5.0.0
\ No newline at end of file
From 74e34df1e1691bef2f0eb81e5ab2fdb85e814bba Mon Sep 17 00:00:00 2001
From: Sigurd Gartmann
Date: Wed, 14 Feb 2018 23:44:19 +0100
Subject: [PATCH 10/15] Upgrade to Django 2.0(.2)
Changes needed since url library has been rewritten in this version of
Django.
---
django-jquery-file-upload/urls.py | 8 ++++----
fileupload/serialize.py | 2 +-
fileupload/urls.py | 16 ++++++++--------
requirements.txt | 4 ++--
4 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/django-jquery-file-upload/urls.py b/django-jquery-file-upload/urls.py
index 53f314a..8f26ec4 100644
--- a/django-jquery-file-upload/urls.py
+++ b/django-jquery-file-upload/urls.py
@@ -1,4 +1,4 @@
-from django.conf.urls import include, url
+from django.urls import include, path
from django.http import HttpResponseRedirect
from django.conf import settings
@@ -7,9 +7,9 @@
admin.autodiscover()
urlpatterns = [
- url(r'^$', lambda x: HttpResponseRedirect('/upload/new/')),
- url(r'^upload/', include('fileupload.urls')),
- url(r'^admin/', include(admin.site.urls)),
+ path('', lambda x: HttpResponseRedirect('/upload/new/')),
+ path('upload/', include('fileupload.urls')),
+ path('admin/', admin.site.urls),
]
if settings.DEBUG:
diff --git a/fileupload/serialize.py b/fileupload/serialize.py
index 4494e79..96749af 100644
--- a/fileupload/serialize.py
+++ b/fileupload/serialize.py
@@ -1,7 +1,7 @@
# encoding: utf-8
import mimetypes
import re
-from django.core.urlresolvers import reverse
+from django.urls import reverse
def order_name(name):
diff --git a/fileupload/urls.py b/fileupload/urls.py
index 7a52c3a..1dbfa7b 100644
--- a/fileupload/urls.py
+++ b/fileupload/urls.py
@@ -1,5 +1,5 @@
# encoding: utf-8
-from django.conf.urls import url
+from django.urls import path
from fileupload.views import (
BasicVersionCreateView, BasicPlusVersionCreateView,
jQueryVersionCreateView, AngularVersionCreateView,
@@ -7,11 +7,11 @@
)
urlpatterns = [
- url(r'^basic/$', BasicVersionCreateView.as_view(), name='upload-basic'),
- url(r'^basic/plus/$', BasicPlusVersionCreateView.as_view(), name='upload-basic-plus'),
- url(r'^new/$', PictureCreateView.as_view(), name='upload-new'),
- url(r'^angular/$', AngularVersionCreateView.as_view(), name='upload-angular'),
- url(r'^jquery-ui/$', jQueryVersionCreateView.as_view(), name='upload-jquery'),
- url(r'^delete/(?P\d+)$', PictureDeleteView.as_view(), name='upload-delete'),
- url(r'^view/$', PictureListView.as_view(), name='upload-view'),
+ path('basic/', BasicVersionCreateView.as_view(), name='upload-basic'),
+ path('basic/plus/', BasicPlusVersionCreateView.as_view(), name='upload-basic-plus'),
+ path('new/', PictureCreateView.as_view(), name='upload-new'),
+ path('angular/', AngularVersionCreateView.as_view(), name='upload-angular'),
+ path('jquery-ui/', jQueryVersionCreateView.as_view(), name='upload-jquery'),
+ path('delete/', PictureDeleteView.as_view(), name='upload-delete'),
+ path('view/', PictureListView.as_view(), name='upload-view'),
]
diff --git a/requirements.txt b/requirements.txt
index 64f06b0..8e1f459 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,2 @@
-django==1.9
-pillow==5.0.0
\ No newline at end of file
+django>=2.0.2,<2.0.99
+pillow==5.0.0
From 04efb0ce040a3acf4ac16827bcd48a598fd0280d Mon Sep 17 00:00:00 2001
From: Sigurd Gartmann
Date: Wed, 14 Feb 2018 23:51:59 +0100
Subject: [PATCH 11/15] Upgrade README after upgrading to Django 2 and Python 3
---
README.md | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index d28dde2..3498b31 100644
--- a/README.md
+++ b/README.md
@@ -32,10 +32,17 @@ fileupload/models.py as commented in the file.
Installation
============
-* pip install -r requirements.txt (will install django and pillow)
-* python manage.py migrate
-* python manage.py runserver
-* go to localhost:8000/upload/new/ and upload some files
+I recommend to install this within a virtualenv.
+
+```sh
+virtualenv -p python3 venv
+source venv/bin/activate
+pip install -r requirements.txt
+./manage.py migrate
+./manage.py runserver
+```
+
+And then go to localhost:8000 and try to upload some files.
License
=======
From f487163413fdf5c3e70240f71e51ba91db21289b Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 22 Oct 2019 20:41:44 +0000
Subject: [PATCH 12/15] Bump pillow from 5.0.0 to 6.2.0
Bumps [pillow](https://github.com/python-pillow/Pillow) from 5.0.0 to 6.2.0.
- [Release notes](https://github.com/python-pillow/Pillow/releases)
- [Changelog](https://github.com/python-pillow/Pillow/blob/master/CHANGES.rst)
- [Commits](https://github.com/python-pillow/Pillow/compare/5.0.0...6.2.0)
Signed-off-by: dependabot[bot]
---
requirements.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/requirements.txt b/requirements.txt
index 8e1f459..ee31b04 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,2 @@
django>=2.0.2,<2.0.99
-pillow==5.0.0
+pillow==6.2.0
From eb4d548d39c5b5f9aa7093447898cfde039d2339 Mon Sep 17 00:00:00 2001
From: Matt Chatterley
Date: Thu, 30 Apr 2020 09:05:27 +0100
Subject: [PATCH 13/15] Add trailing slashes for newer versions of Django
(default settings)
---
.../templates/fileupload/picture_basic_form.html | 10 +++++-----
.../templates/fileupload/picture_basicplus_form.html | 10 +++++-----
fileupload/templates/fileupload/picture_form.html | 8 ++++----
.../templates/fileupload/picture_jquery_form.html | 10 +++++-----
4 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/fileupload/templates/fileupload/picture_basic_form.html b/fileupload/templates/fileupload/picture_basic_form.html
index 69993d0..98ab055 100644
--- a/fileupload/templates/fileupload/picture_basic_form.html
+++ b/fileupload/templates/fileupload/picture_basic_form.html
@@ -38,11 +38,11 @@
Django jQuery File Upload Demo
Basic version
diff --git a/fileupload/templates/fileupload/picture_basicplus_form.html b/fileupload/templates/fileupload/picture_basicplus_form.html
index 2d2069e..e52d1fd 100644
--- a/fileupload/templates/fileupload/picture_basicplus_form.html
+++ b/fileupload/templates/fileupload/picture_basicplus_form.html
@@ -38,11 +38,11 @@
Django jQuery File Upload Demo
Basic Plus version
diff --git a/fileupload/templates/fileupload/picture_form.html b/fileupload/templates/fileupload/picture_form.html
index d77a925..1f352e8 100644
--- a/fileupload/templates/fileupload/picture_form.html
+++ b/fileupload/templates/fileupload/picture_form.html
@@ -6,11 +6,11 @@
Django jQuery File Upload Demo
Basic Plus UI version
diff --git a/fileupload/templates/fileupload/picture_jquery_form.html b/fileupload/templates/fileupload/picture_jquery_form.html
index 0332c31..3de8b18 100644
--- a/fileupload/templates/fileupload/picture_jquery_form.html
+++ b/fileupload/templates/fileupload/picture_jquery_form.html
@@ -82,11 +82,11 @@ jQuery UI version
File Upload widget with multiple file selection, drag&drop support, progress bars, validation and preview images, audio and video for jQuery UI.
From 8a5745402b5182670b7991097b522942f04b8322 Mon Sep 17 00:00:00 2001
From: Sigurd Gartmann
Date: Tue, 11 Aug 2020 23:07:11 +0200
Subject: [PATCH 14/15] Update django dependency to newer django 2
---
requirements.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/requirements.txt b/requirements.txt
index ee31b04..05a617c 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,2 @@
-django>=2.0.2,<2.0.99
+django>=2.2.13,<2.0.99
pillow==6.2.0
From 0f819ad5ae763e895a03c77a083996168d37100c Mon Sep 17 00:00:00 2001
From: Sigurd Gartmann
Date: Tue, 11 Aug 2020 23:08:38 +0200
Subject: [PATCH 15/15] Update pillow dependency
Not tested. Will archive repository soon.
---
requirements.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/requirements.txt b/requirements.txt
index 05a617c..c87429b 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,2 @@
django>=2.2.13,<2.0.99
-pillow==6.2.0
+pillow>=7.1.0