Skip to content
This repository was archived by the owner on Aug 12, 2020. It is now read-only.

Commit 07f7a8a

Browse files
committed
Revamped old project
1 parent 8b7bb90 commit 07f7a8a

File tree

13 files changed

+322
-348
lines changed

13 files changed

+322
-348
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
db
1+
db.sqlite3
22
/media
33
/bin
44
/include

django-jquery-file-upload/settings.py

Lines changed: 86 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,23 @@
1-
import os
2-
3-
DEBUG = True
4-
TEMPLATE_DEBUG = DEBUG
5-
6-
SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
7-
8-
ADMINS = (
9-
# ('Your Name', 'your_email@example.com'),
10-
)
11-
12-
MANAGERS = ADMINS
1+
"""
2+
Django settings for this project.
133
14-
DATABASES = {
15-
'default': {
16-
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
17-
'NAME': os.path.join(SITE_ROOT, 'db'), # Or path to database file if using sqlite3.
18-
'USER': '', # Not used with sqlite3.
19-
'PASSWORD': '', # Not used with sqlite3.
20-
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
21-
'PORT': '', # Set to empty string for default. Not used with sqlite3.
22-
}
23-
}
4+
Generated by 'django-admin startproject' using Django 1.9.
245
25-
# Local time zone for this installation. Choices can be found here:
26-
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
27-
# although not all choices may be available on all operating systems.
28-
# On Unix systems, a value of None will cause Django to use the same
29-
# timezone as the operating system.
30-
# If running in a Windows environment this must be set to the same as your
31-
# system time zone.
32-
TIME_ZONE = 'America/Chicago'
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/1.9/topics/settings/
338
34-
# Language code for this installation. All choices can be found here:
35-
# http://www.i18nguy.com/unicode/language-identifiers.html
36-
LANGUAGE_CODE = 'en-us'
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/1.9/ref/settings/
11+
"""
12+
import os
3713

38-
SITE_ID = 1
14+
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
15+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
3916

40-
# If you set this to False, Django will make some optimizations so as not
41-
# to load the internationalization machinery.
42-
USE_I18N = True
17+
# Make this unique, and don't share it with anybody.
18+
SECRET_KEY = '9%$in^gpdaig@v3or_to&_z(=n)3)$f1mr3hf9e#kespy2ajlo'
4319

44-
# If you set this to False, Django will not format dates, numbers and
45-
# calendars according to the current locale
46-
USE_L10N = True
20+
DEBUG = True
4721

4822
# Absolute filesystem path to the directory that will hold user-uploaded files.
4923
# Example: "/home/media/media.lawrence.com/media/"
@@ -69,29 +43,28 @@
6943
# Examples: "http://foo.com/static/admin/", "/static/admin/".
7044
ADMIN_MEDIA_PREFIX = '/static/admin/'
7145

72-
# Additional locations of static files
73-
STATICFILES_DIRS = (
74-
# Put strings here, like "/home/html/static" or "C:/www/django/static".
75-
# Always use forward slashes, even on Windows.
76-
# Don't forget to use absolute paths, not relative paths.
46+
ADMINS = (
47+
# ('Your Name', 'your_email@example.com'),
48+
)
49+
50+
MANAGERS = ADMINS
51+
52+
INSTALLED_APPS = (
53+
'django.contrib.auth',
54+
'django.contrib.contenttypes',
55+
'django.contrib.sessions',
56+
'django.contrib.sites',
57+
'django.contrib.messages',
58+
'django.contrib.staticfiles',
59+
'django.contrib.admin',
60+
'fileupload',
7761
)
7862

7963
# List of finder classes that know how to find static files in
8064
# various locations.
8165
STATICFILES_FINDERS = (
8266
'django.contrib.staticfiles.finders.FileSystemFinder',
8367
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
84-
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
85-
)
86-
87-
# Make this unique, and don't share it with anybody.
88-
SECRET_KEY = '9%$in^gpdaig@v3or_to&_z(=n)3)$f1mr3hf9e#kespy2ajlo'
89-
90-
# List of callables that know how to import templates from various sources.
91-
TEMPLATE_LOADERS = (
92-
'django.template.loaders.filesystem.Loader',
93-
'django.template.loaders.app_directories.Loader',
94-
# 'django.template.loaders.eggs.Loader',
9568
)
9669

9770
MIDDLEWARE_CLASSES = (
@@ -105,25 +78,50 @@
10578

10679
ROOT_URLCONF = 'django-jquery-file-upload.urls'
10780

108-
TEMPLATE_DIRS = (
109-
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
110-
# Always use forward slashes, even on Windows.
111-
# Don't forget to use absolute paths, not relative paths.
112-
)
81+
TEMPLATES = [
82+
{
83+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
84+
'DIRS': [],
85+
'APP_DIRS': True,
86+
'OPTIONS': {
87+
'context_processors': [
88+
'django.template.context_processors.debug',
89+
'django.template.context_processors.request',
90+
'django.contrib.auth.context_processors.auth',
91+
'django.contrib.messages.context_processors.messages',
92+
],
93+
},
94+
},
95+
]
11396

114-
INSTALLED_APPS = (
115-
'django.contrib.auth',
116-
'django.contrib.contenttypes',
117-
'django.contrib.sessions',
118-
'django.contrib.sites',
119-
'django.contrib.messages',
120-
'django.contrib.staticfiles',
121-
'fileupload',
122-
# Uncomment the next line to enable the admin:
123-
'django.contrib.admin',
124-
# Uncomment the next line to enable admin documentation:
125-
# 'django.contrib.admindocs',
126-
)
97+
DATABASES = {
98+
'default': {
99+
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
100+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), # Or path to database file if using sqlite3.
101+
'USER': '', # Not used with sqlite3.
102+
'PASSWORD': '', # Not used with sqlite3.
103+
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
104+
'PORT': '', # Set to empty string for default. Not used with sqlite3.
105+
}
106+
}
107+
108+
# Password validation
109+
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
110+
111+
AUTH_PASSWORD_VALIDATORS = [
112+
{
113+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
114+
},
115+
{
116+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
117+
},
118+
{
119+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
120+
},
121+
{
122+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
123+
},
124+
]
127125

128126
# A sample logging configuration. The only tangible logging
129127
# performed by this configuration is to send an email to
@@ -147,3 +145,17 @@
147145
},
148146
}
149147
}
148+
149+
# Language code for this installation. All choices can be found here:
150+
# http://www.i18nguy.com/unicode/language-identifiers.html
151+
LANGUAGE_CODE = 'en-us'
152+
153+
SITE_ID = 1
154+
155+
# If you set this to False, Django will make some optimizations so as not
156+
# to load the internationalization machinery.
157+
USE_I18N = True
158+
159+
# If you set this to False, Django will not format dates, numbers and
160+
# calendars according to the current locale
161+
USE_L10N = True

django-jquery-file-upload/urls.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
from django.conf.urls import patterns, include, url
22
from django.http import HttpResponseRedirect
33

4+
from django.views.static import serve
5+
46
# Uncomment the next two lines to enable the admin:
57
from django.contrib import admin
68
admin.autodiscover()
79

8-
urlpatterns = patterns('',
9-
# Examples:
10-
# url(r'^$', 'upload.views.home', name='home'),
11-
10+
urlpatterns = [
1211
url(r'^$', lambda x: HttpResponseRedirect('/upload/new/')),
1312
url(r'^upload/', include('fileupload.urls')),
14-
15-
# Uncomment the admin/doc line below to enable admin documentation:
16-
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
17-
18-
# Uncomment the next line to enable the admin:
1913
url(r'^admin/', include(admin.site.urls)),
20-
)
14+
]
2115

2216
from os.path import join, abspath, dirname
23-
urlpatterns += patterns('',
24-
(r'^media/(.*)$', 'django.views.static.serve', {'document_root': join(abspath(dirname(__file__)), 'media')}),
25-
)
17+
urlpatterns += [
18+
url(r'^media/(.*)$', serve, {'document_root': join(abspath(dirname(__file__)), 'media')}),
19+
]

fileupload/admin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from fileupload.models import Picture
1+
from fileupload.models import File
22
from django.contrib import admin
33

4-
admin.site.register(Picture)
4+
admin.site.register(File)

fileupload/migrations/0001_initial.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.9 on 2015-12-19 13:27
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
initial = True
11+
12+
dependencies = [
13+
]
14+
15+
operations = [
16+
migrations.CreateModel(
17+
name='File',
18+
fields=[
19+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
20+
('file', models.FileField(upload_to='')),
21+
('slug', models.SlugField(blank=True)),
22+
],
23+
),
24+
]

fileupload/migrations/__init__.py

Whitespace-only changes.

fileupload/models.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# encoding: utf-8
22
from django.db import models
33

4-
5-
class Picture(models.Model):
4+
class File(models.Model):
65
"""This is a small demo using just two fields. The slug field is really not
76
necessary, but makes the code simpler. ImageField depends on PIL or
87
pillow (where Pillow is easily installable in a virtualenv. If you have
98
problems installing pillow, use a more generic FileField instead.
109
1110
"""
12-
file = models.ImageField(upload_to="pictures")
11+
file = models.FileField()
1312
slug = models.SlugField(max_length=50, blank=True)
1413

1514
def __unicode__(self):
@@ -21,9 +20,9 @@ def get_absolute_url(self):
2120

2221
def save(self, *args, **kwargs):
2322
self.slug = self.file.name
24-
super(Picture, self).save(*args, **kwargs)
23+
super(File, self).save(*args, **kwargs)
2524

2625
def delete(self, *args, **kwargs):
2726
"""delete -- Remove to leave file."""
2827
self.file.delete(False)
29-
super(Picture, self).delete(*args, **kwargs)
28+
super(File, self).delete(*args, **kwargs)

fileupload/serialize.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ def order_name(name):
1818

1919

2020
def serialize(instance, file_attr='file'):
21-
"""serialize -- Serialize a Picture instance into a dict.
21+
"""serialize -- Serialize a File instance into a dict.
2222
23-
instance -- Picture instance
23+
instance -- File instance
2424
file_attr -- attribute name that contains the FileField or ImageField
2525
2626
"""
@@ -34,5 +34,3 @@ def serialize(instance, file_attr='file'):
3434
'deleteUrl': reverse('upload-delete', args=[instance.pk]),
3535
'deleteType': 'DELETE',
3636
}
37-
38-

0 commit comments

Comments
 (0)