python3! Major work inside

This commit is contained in:
nikolark committed 2016-03-22 16:17:34 +01:00
1 parent 0f6fef809f
commit ce976101a1
34 files changed
+305 -304

No files matched your search

+3 -3
View File
@@ -1,5 +1,5 @@
from django.contrib import admin from django.contrib import admin
from django.contrib.contenttypes import generic from django.contrib.contenttypes.admin import GenericTabularInline
from bestilling.models import Attachment from bestilling.models import Attachment
from prm.models import PrmOrder from prm.models import PrmOrder
@@ -7,7 +7,7 @@ from tekst.models import TekstOrder
from design.models import DesignOrder from design.models import DesignOrder
class UploadedFileline(generic.GenericTabularInline): class UploadedFileline(GenericTabularInline):
model = Attachment model = Attachment
extra = 1 extra = 1
@@ -20,4 +20,4 @@ class OrderAdmin(admin.ModelAdmin):
admin.site.register(PrmOrder, OrderAdmin) admin.site.register(PrmOrder, OrderAdmin)
admin.site.register(TekstOrder, OrderAdmin) admin.site.register(TekstOrder, OrderAdmin)
admin.site.register(DesignOrder, OrderAdmin) admin.site.register(DesignOrder, OrderAdmin)
admin.site.register(Attachment) admin.site.register(Attachment)
+2 -2
View File
@@ -12,9 +12,9 @@ from django.conf import settings
import trello import trello
from bestilling import utils from bestilling import utils
from bestilling.models import Attachment from bestilling.models import Attachment
class BaseFormView(TemplateView): class BaseFormView(TemplateView):
mail_template_name = "confirmation_mail.txt" mail_template_name = "confirmation_mail.txt"
mail_from = 'no-reply@studentersamfundet.no' mail_from = 'no-reply@studentersamfundet.no'
@@ -79,7 +79,7 @@ class BaseFormView(TemplateView):
board = client.get_board(self.trello_board_id) board = client.get_board(self.trello_board_id)
all_lists = board.all_lists() all_lists = board.all_lists()
order_list = filter(lambda x: x.name == list_name and (x.fetch() or x.closed == False), all_lists) order_list = list(filter(lambda x: x.name.decode('utf-8') == list_name and (x.fetch() or x.closed is False), all_lists))
if len(order_list) == 0: if len(order_list) == 0:
order_list.append(board.add_list(list_name)) order_list.append(board.add_list(list_name))
+21 -15
View File
@@ -1,20 +1,26 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime from __future__ import unicode_literals
from south.db import db
from south.v2 import SchemaMigration from django.db import migrations, models
from django.db import models import bestilling.utils
class Migration(SchemaMigration): class Migration(migrations.Migration):
def forwards(self, orm): dependencies = [
pass ('contenttypes', '0002_remove_content_type_name'),
]
def backwards(self, orm): operations = [
pass migrations.CreateModel(
name='Attachment',
models = { fields=[
('id', models.AutoField(verbose_name='ID', auto_created=True, serialize=False, primary_key=True)),
} ('uploaded_file', models.FileField(validators=[bestilling.utils.validate_file_extension], upload_to='uploads')),
('trello_id', models.CharField(null=True, max_length=40, blank=True)),
complete_apps = ['bestilling'] ('created', models.DateTimeField(auto_now_add=True)),
('object_id', models.PositiveIntegerField()),
('content_type', models.ForeignKey(to='contenttypes.ContentType')),
],
),
]
@@ -1,47 +0,0 @@
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding model 'Attachment'
db.create_table(u'bestilling_attachment', (
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('uploaded_file', self.gf('django.db.models.fields.files.FileField')(max_length=100)),
('trello_id', self.gf('django.db.models.fields.CharField')(max_length=40, null=True, blank=True)),
('created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
('content_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['contenttypes.ContentType'])),
('object_id', self.gf('django.db.models.fields.PositiveIntegerField')()),
))
db.send_create_signal(u'bestilling', ['Attachment'])
def backwards(self, orm):
# Deleting model 'Attachment'
db.delete_table(u'bestilling_attachment')
models = {
u'bestilling.attachment': {
'Meta': {'object_name': 'Attachment'},
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
'trello_id': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'blank': 'True'}),
'uploaded_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'})
},
u'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
}
}
complete_apps = ['bestilling']
+6 -4
View File
@@ -1,6 +1,7 @@
import uuid
from django.contrib.contenttypes.fields import GenericForeignKey
from django.db import models from django.db import models
from django_extensions.db.fields import UUIDField
from django.contrib.contenttypes import generic
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from bestilling.utils import validate_file_extension from bestilling.utils import validate_file_extension
@@ -18,11 +19,12 @@ class Attachment(models.Model):
content_type = models.ForeignKey(ContentType, limit_choices_to=_limit_order_choices) content_type = models.ForeignKey(ContentType, limit_choices_to=_limit_order_choices)
object_id = models.PositiveIntegerField() object_id = models.PositiveIntegerField()
order_object = generic.GenericForeignKey('content_type', 'object_id') order_object = GenericForeignKey('content_type', 'object_id')
class Order(models.Model): class Order(models.Model):
uuid = UUIDField(unique=True, auto=True, version=1) # version 1 guarantees no collisions # uuid = UUIDField(unique=True, auto=True, version=1) # version 1 guarantees no collisions
uuid = models.UUIDField(unique=True, default=uuid.uuid4) # auto=True, version=1
client = models.CharField(max_length=50) client = models.CharField(max_length=50)
deadline = models.DateField() deadline = models.DateField()
contact_name = models.CharField(max_length=50) contact_name = models.CharField(max_length=50)
+1 -1
View File
@@ -7,4 +7,4 @@ class AttachmentSerializer(ModelSerializer):
class Meta: class Meta:
model = Attachment model = Attachment
fields = ('id', 'uploaded_file', 'trello_id', 'object_id', 'content_type') fields = ('id', 'uploaded_file', 'trello_id', 'object_id', 'content_type')
read_only_fields = ('id',) read_only_fields = ('id',)
+32 -92
View File
@@ -1,8 +1,6 @@
# Copy and change variables marked with TODO to local_settings.py to make it work.
import os import os
DEBUG = True DEBUG = True
TEMPLATE_DEBUG = DEBUG
# Path of our project: # Path of our project:
BASE_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), os.pardir)) BASE_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), os.pardir))
@@ -10,74 +8,29 @@ BASE_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), os.pardir))
ADMINS = ( ADMINS = (
# ('Your Name', 'your_email@example.com'), # ('Your Name', 'your_email@example.com'),
) )
MANAGERS = ADMINS MANAGERS = ADMINS
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.sqlite3', 'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'db.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
} }
} }
# Trello keys, tokens and board ids
TRELLO_API_KEY = "" # TODO
TRELLO_TOKEN = "" # TODO
TRELLO_DESIGN_BOARD_ID = "" # TODO
TRELLO_TEKST_BOARD_ID = "" # TODO
TRELLO_PRM_BOARD_ID = "" # TODO
# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = [] ALLOWED_HOSTS = []
# 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.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'Europe/Oslo' TIME_ZONE = 'Europe/Oslo'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'nb' LANGUAGE_CODE = 'nb'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True 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 USE_L10N = True
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True USE_TZ = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL = '/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: "/var/www/example.com/static/"
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/' STATIC_URL = '/static/'
# Additional locations of static files # Additional locations of static files
STATICFILES_DIRS = ( 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.
os.path.join(BASE_DIR, 'static'), os.path.join(BASE_DIR, 'static'),
) )
@@ -91,17 +44,30 @@ STATICFILES_FINDERS = (
# Make this unique, and don't share it with anybody. # Make this unique, and don't share it with anybody.
SECRET_KEY = 'asdf123' SECRET_KEY = 'asdf123'
# List of callables that know how to import templates from various sources. TEMPLATES = [
TEMPLATE_LOADERS = ( {
'django.template.loaders.filesystem.Loader', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'django.template.loaders.app_directories.Loader', 'DIRS': [
) os.path.join(BASE_DIR, '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',
],
},
},
]
MIDDLEWARE_CLASSES = ( MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
) )
@@ -110,13 +76,6 @@ ROOT_URLCONF = 'bestilling.urls'
# Python dotted path to the WSGI application used by Django's runserver. # Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'bestilling.wsgi.application' WSGI_APPLICATION = 'bestilling.wsgi.application'
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.
os.path.join(BASE_DIR, 'templates'),
)
INSTALLED_APPS = ( INSTALLED_APPS = (
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',
@@ -127,41 +86,22 @@ INSTALLED_APPS = (
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.admindocs', 'django.contrib.admindocs',
'rest_framework', 'rest_framework',
'south', )
INSTALLED_APPS += (
'design', 'design',
'tekst', 'tekst',
'prm', 'prm',
'bestilling' 'bestilling'
) )
# A sample logging configuration. The only tangible logging SITE_ID = 1
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False. # Trello keys, tokens and board ids
# See http://docs.djangoproject.com/en/dev/topics/logging for TRELLO_API_KEY = ""
# more details on how to customize your logging configuration. TRELLO_TOKEN = ""
LOGGING = { TRELLO_DESIGN_BOARD_ID = ""
'version': 1, TRELLO_TEKST_BOARD_ID = ""
'disable_existing_loggers': False, TRELLO_PRM_BOARD_ID = ""
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
MAIL_KAK_DESIGN = 'kak-design@studentersamfundet.no' MAIL_KAK_DESIGN = 'kak-design@studentersamfundet.no'
MAIL_KAK_TEKST = 'kak-tekst@studentersamfundet.no' MAIL_KAK_TEKST = 'kak-tekst@studentersamfundet.no'
@@ -169,9 +109,9 @@ MAIL_KAK_PRM = 'kak-prm@studentersamfundet.no'
UPLOAD_FILENAME_EXTENSIONS_ALLOWED = [ UPLOAD_FILENAME_EXTENSIONS_ALLOWED = [
'png', 'ai', 'eps', 'jpeg', 'jpg', 'tif', 'tiff', 'indd', 'webp' 'png', 'ai', 'eps', 'jpeg', 'jpg', 'tif', 'tiff', 'indd', 'webp'
'pdf', 'doc', 'docx', 'xls', 'xlsx', 'txt', 'zip'] 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'txt', 'zip', '.gif']
try: try:
from local_settings import * from .local_settings import *
except ImportError: except ImportError:
pass pass
+11 -10
View File
@@ -1,24 +1,25 @@
from django.conf.urls import patterns, include, url from django.conf.urls import url, include
from django.contrib import admin from django.contrib import admin
from django.conf import settings from django.conf import settings
from bestilling.views import IndexView, AttachmentView from bestilling.views import IndexView, AttachmentView
from design import urls as design_urls
from tekst import urls as tekst_urls
from prm import urls as prm_urls
admin.autodiscover() admin.autodiscover()
urlpatterns = patterns( urlpatterns = [
'', url(r'^design/', include(design_urls)),
url(r'^design/', include('design.urls')), url(r'^tekst/', include(tekst_urls)),
url(r'^tekst/', include('tekst.urls')), url(r'^prm/', include(prm_urls)),
url(r'^prm/', include('prm.urls')),
url(r'^$', IndexView.as_view()), url(r'^$', IndexView.as_view()),
url(r'^attachments/$', AttachmentView.as_view(), name='attachments'), url(r'^attachments/$', AttachmentView.as_view(), name='attachments'),
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(admin.site.urls)),
) ]
if settings.DEBUG: if settings.DEBUG:
urlpatterns += patterns( urlpatterns += [
'',
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', { url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT, 'document_root': settings.MEDIA_ROOT,
}), }),
) ]
+2 -1
View File
@@ -1,3 +1,4 @@
from __future__ import unicode_literals
import re import re
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.conf import settings from django.conf import settings
@@ -19,4 +20,4 @@ def validate_file_extension(value):
for ext in settings.UPLOAD_FILENAME_EXTENSIONS_ALLOWED: for ext in settings.UPLOAD_FILENAME_EXTENSIONS_ALLOWED:
if value.name.lower().endswith(ext): if value.name.lower().endswith(ext):
return # bail out return # bail out
raise ValidationError(u'Ikke tillatt filendelse i "{0}"'.format(value)) raise ValidationError('Ikke tillatt filendelse i "{0}"'.format(value))
+5 -13
View File
@@ -1,7 +1,4 @@
from django.conf import settings from django.conf import settings
from django.http import HttpResponse
from django.template import Context
from django.template.loader import get_template
from django.views.generic import TemplateView from django.views.generic import TemplateView
from rest_framework import generics from rest_framework import generics
@@ -12,20 +9,15 @@ from bestilling.serializers import AttachmentSerializer
class IndexView(TemplateView): class IndexView(TemplateView):
def get(self, request): template_name = 'index.html'
template = get_template('index.html')
context_data = {}
response = template.render(Context(context_data))
return HttpResponse(response)
class AttachmentView(generics.ListCreateAPIView): class AttachmentView(generics.ListCreateAPIView):
queryset = Attachment.objects.all() queryset = Attachment.objects.all()
serializer_class = AttachmentSerializer serializer_class = AttachmentSerializer
def post_save(self, obj, created=False): def perform_create(self, serializer):
obj = serializer.save()
if obj.order_object is not None: if obj.order_object is not None:
client = trello.TrelloClient(api_key=settings.TRELLO_API_KEY, token=settings.TRELLO_TOKEN) client = trello.TrelloClient(api_key=settings.TRELLO_API_KEY, token=settings.TRELLO_TOKEN)
attachment = client.fetch_json( attachment = client.fetch_json(
@@ -35,4 +27,4 @@ class AttachmentView(generics.ListCreateAPIView):
) )
# Persist trello attachment id # Persist trello attachment id
obj.trello_id = attachment['id'] obj.trello_id = attachment['id']
obj.save() obj.save()
+7 -33
View File
@@ -1,41 +1,15 @@
""" """
WSGI config for bestilling project. WSGI config for bestilling project.
This module contains the WSGI application used by Django's development server It exposes the WSGI callable as a module-level variable named ``application``.
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_APPLICATION`` setting.
Usually you will have the standard Django WSGI application here, but it also
might make sense to replace the whole Django WSGI application with a custom one
that later delegates to the Django one. For example, you could introduce WSGI
middleware here, or combine a Django application with an application of another
framework.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
""" """
import os, sys
from os.path import dirname, join import os
def map_path(target_name=''):
return join(dirname(__file__), target_name).replace('\\', '/')
path = map_path("..")
if path not in sys.path:
sys.path.append(path)
# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks
# if running multiple sites in the same mod_wsgi process. To fix this, use
# mod_wsgi daemon mode with each site in its own daemon process, or use
# os.environ["DJANGO_SETTINGS_MODULE"] = "bestilling.settings"
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bestilling.settings")
# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
# Apply WSGI middleware here.
# from helloworld.wsgi import HelloWorldApplication os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bestilling.settings")
# application = HelloWorldApplication(application) application = get_wsgi_application()
+36
View File
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django_extensions.db.fields
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='DesignOrder',
fields=[
('id', models.AutoField(verbose_name='ID', auto_created=True, serialize=False, primary_key=True)),
('uuid', django_extensions.db.fields.UUIDField(editable=False, version=1, blank=True, unique=True)),
('client', models.CharField(max_length=50)),
('deadline', models.DateField()),
('contact_name', models.CharField(max_length=50)),
('contact_email', models.CharField(max_length=50)),
('contact_number', models.CharField(null=True, max_length=20, blank=True)),
('created', models.DateTimeField(auto_now_add=True)),
('trello_card_id', models.CharField(max_length=40)),
('format_type', models.CharField(choices=[('Trykk - Flyer', 'Trykk - Flyer'), ('Trykk - Plakat', 'Trykk - Plakat'), ('Trykk - Banner', 'Trykk - Banner'), ('Web - Annonse', 'Web - Annonse'), ('Web - Banner', 'Web - Banner'), ('Web - Bilde', 'Web - Bilde')], max_length=50)),
('paper_size', models.CharField(choices=[('A1', 'A1 (594 x 841 mm)'), ('A2', 'A2 (420 x 594 mm)'), ('B3', 'B3 (353 x 500 mm)'), ('A3', 'A3 (297 x 420 mm)'), ('A4', 'A4 (210 x 297 mm)'), ('A5', 'A5 (148 x 210 mm)'), ('A6', 'A6 (105 x 148 mm)')], max_length=50)),
('colour', models.CharField(max_length=50)),
('marger', models.CharField(max_length=50)),
('content', models.TextField(null=True, blank=True)),
],
options={
'abstract': False,
},
),
]
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('design', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='designorder',
name='uuid',
field=models.UUIDField(unique=True),
),
]
View File
Whitespace-only changes.
+1
View File
@@ -1,6 +1,7 @@
from bestilling.models import Order from bestilling.models import Order
from django.db import models from django.db import models
class DesignOrder(Order): class DesignOrder(Order):
PAPER_SIZES = [ PAPER_SIZES = [
('A1', 'A1 (594 x 841 mm)'), ('A1', 'A1 (594 x 841 mm)'),
-15
View File
@@ -1,16 +1 @@
"""
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 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)
+6 -6
View File
@@ -1,8 +1,8 @@
from django.conf.urls import patterns from django.conf.urls import url
from design.views import DesignFormView, DesignOrderView from design.views import DesignFormView, DesignOrderView
urlpatterns = patterns( urlpatterns = [
'design.views', url(r'^$', DesignFormView.as_view()),
(r'^$', DesignFormView.as_view()), url(r'^order/(?P<order_id>[a-zA-Z0-9-]+)/', DesignOrderView.as_view()),
(r'^order/(?P<order_id>[a-zA-Z0-9-]+)/', DesignOrderView.as_view()), ]
)
+23 -22
View File
@@ -38,17 +38,17 @@ class DesignFormView(BaseFormView):
def _get_errors(self, params): def _get_errors(self, params):
errors = super(DesignFormView, self)._get_errors(params) errors = super(DesignFormView, self)._get_errors(params)
errors.update({ errors.update({
'format_error' : params['format'] == '' or len(params['format']) > 50, 'format_error': params['format'] == '' or len(params['format']) > 50,
'format_other_error' : params['format'] == 'other' and (params['format_other'] == '' or len(params['format_other']) > 50), 'format_other_error': params['format'] == 'other' and (params['format_other'] == '' or len(params['format_other']) > 50),
'paper_size_error' : params['paper_size'] == '' or len(params['paper_size']) > 50, 'paper_size_error': params['paper_size'] == '' or len(params['paper_size']) > 50,
'paper_size_other_error' : params['paper_size'] == 'other' and (params['paper_size_other'] == '' or len(params['paper_size_other']) > 50), 'paper_size_other_error': params['paper_size'] == 'other' and (params['paper_size_other'] == '' or len(params['paper_size_other']) > 50),
'colour_error' : params['colour'] == '' or len(params['colour']) > 50, 'colour_error': params['colour'] == '' or len(params['colour']) > 50,
'marger_error' : params['marger'] == '' or len(params['marger']) > 50, 'marger_error': params['marger'] == '' or len(params['marger']) > 50,
'content_error' : False, 'content_error': False,
}) })
# Filter out all errors that are False: # Filter out all errors that are False:
return dict((error, True) for error, has_happened in errors.iteritems() if has_happened is True) return dict((error, True) for error, has_happened in errors.items() if has_happened is True)
def _get_order_url(self, request, order): def _get_order_url(self, request, order):
return request.build_absolute_uri('/design/order/{uuid}/'.format(uuid=order.uuid)) return request.build_absolute_uri('/design/order/{uuid}/'.format(uuid=order.uuid))
@@ -60,26 +60,26 @@ class DesignFormView(BaseFormView):
deadline = datetime.strptime(params['deadline'], '%Y-%m-%d') deadline = datetime.strptime(params['deadline'], '%Y-%m-%d')
card = self._save_to_trello( card = self._save_to_trello(
card_name = params['client'], card_name=params['client'],
card_description = "", card_description="",
card_due=datetime.strftime(deadline, '%m/%d/%y'), card_due=datetime.strftime(deadline, '%m/%d/%y'),
) )
card_id = card.id card_id = card.id
order = DesignOrder( order = DesignOrder(
client = params['client'], client=params['client'],
deadline = deadline.date(), deadline=deadline.date(),
contact_name = params['contact_name'], contact_name=params['contact_name'],
contact_email = params['contact_email'], contact_email=params['contact_email'],
contact_number = params['contact_number'], contact_number=params['contact_number'],
format_type = params['format_type'], format_type=params['format_type'],
paper_size = params['paper_size'], paper_size=params['paper_size'],
colour = params['colour'], colour=params['colour'],
marger = params['marger'], marger=params['marger'],
content = params['content'], content=params['content'],
trello_card_id = str(card_id) trello_card_id=str(card_id)
) )
order.save() order.save()
params['url'] = request.build_absolute_uri('/design/order/{uuid}/'.format(uuid=order.uuid)) params['url'] = request.build_absolute_uri('/design/order/{uuid}/'.format(uuid=order.uuid))
@@ -89,6 +89,7 @@ class DesignFormView(BaseFormView):
return order return order
class DesignOrderView(BaseOrderView): class DesignOrderView(BaseOrderView):
template_name = "design/order.html" template_name = "design/order.html"
+33
View File
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django_extensions.db.fields
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='PrmOrder',
fields=[
('id', models.AutoField(verbose_name='ID', auto_created=True, serialize=False, primary_key=True)),
('uuid', django_extensions.db.fields.UUIDField(editable=False, version=1, blank=True, unique=True)),
('client', models.CharField(max_length=50)),
('deadline', models.DateField()),
('contact_name', models.CharField(max_length=50)),
('contact_email', models.CharField(max_length=50)),
('contact_number', models.CharField(null=True, max_length=20, blank=True)),
('created', models.DateTimeField(auto_now_add=True)),
('trello_card_id', models.CharField(max_length=40)),
('assignment_type', models.CharField(max_length=200)),
('content', models.TextField(null=True, blank=True)),
],
options={
'abstract': False,
},
),
]
+19
View File
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('prm', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='prmorder',
name='uuid',
field=models.UUIDField(unique=True),
),
]
View File
Whitespace-only changes.
-15
View File
@@ -1,16 +1 @@
"""
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 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)
+5 -6
View File
@@ -1,8 +1,7 @@
from django.conf.urls import patterns from django.conf.urls import url
from prm.views import PrmFormView, PrmOrderView from prm.views import PrmFormView, PrmOrderView
urlpatterns = patterns( urlpatterns = [
'tekst.views', url(r'^$', PrmFormView.as_view()),
(r'^$', PrmFormView.as_view()), url(r'^order/(?P<order_id>[a-zA-Z0-9-]+)/', PrmOrderView.as_view()),
(r'^order/(?P<order_id>[a-zA-Z0-9-]+)/', PrmOrderView.as_view()), ]
)
+1 -1
View File
@@ -34,7 +34,7 @@ class PrmFormView(BaseFormView):
}) })
# Filter out all errors that are False: # Filter out all errors that are False:
return dict((error, True) for error, has_happened in errors.iteritems() if has_happened is True) return dict((error, True) for error, has_happened in errors.items() if has_happened is True)
def _get_order_url(self, request, order): def _get_order_url(self, request, order):
return request.build_absolute_uri('/prm/order/{uuid}/'.format(uuid=order.uuid)) return request.build_absolute_uri('/prm/order/{uuid}/'.format(uuid=order.uuid))
+6 -7
View File
@@ -1,7 +1,6 @@
Django>=1.6,<1.7 Django>=1.8,<1.9
django-extensions==1.5.2 django-extensions==1.6.1
djangorestframework==2.4.4 djangorestframework==3.3.3
mysqlclient==1.3.6 mysqlclient==1.3.7
python-dateutil==2.4.2 python-dateutil==2.5.1
py-trello==0.1.6 py-trello==0.4.3
South==1.0.2
+1 -1
View File
@@ -7,7 +7,7 @@ $(function () {
}, },
dataType: 'json', dataType: 'json',
done: function (e, data) { done: function (e, data) {
$('.attachments ul').append('<li><a href="/media/' + data.result.uploaded_file + '">'+ $('.attachments ul').append('<li><a href="' + data.result.uploaded_file + '">'+
data.files[0].name + '</a> (ny)</li>'); data.files[0].name + '</a> (ny)</li>');
/* Reset progress */ /* Reset progress */
+37
View File
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django_extensions.db.fields
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='TekstOrder',
fields=[
('id', models.AutoField(verbose_name='ID', auto_created=True, serialize=False, primary_key=True)),
('uuid', django_extensions.db.fields.UUIDField(editable=False, version=1, blank=True, unique=True)),
('client', models.CharField(max_length=50)),
('deadline', models.DateField()),
('contact_name', models.CharField(max_length=50)),
('contact_email', models.CharField(max_length=50)),
('contact_number', models.CharField(null=True, max_length=20, blank=True)),
('created', models.DateTimeField(auto_now_add=True)),
('trello_card_id', models.CharField(max_length=40)),
('text_type', models.CharField(max_length=50)),
('length', models.CharField(max_length=50)),
('image', models.CharField(max_length=50)),
('interview_name', models.CharField(max_length=20)),
('interview_contact', models.TextField(null=True, blank=True)),
('content', models.TextField(null=True, blank=True)),
],
options={
'abstract': False,
},
),
]
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('tekst', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='tekstorder',
name='uuid',
field=models.UUIDField(unique=True),
),
]
View File
Whitespace-only changes.
+5 -6
View File
@@ -1,8 +1,7 @@
from django.conf.urls import patterns from django.conf.urls import url
from tekst.views import TekstFormView, TekstOrderView from tekst.views import TekstFormView, TekstOrderView
urlpatterns = patterns( urlpatterns = [
'tekst.views', url(r'^$', TekstFormView.as_view()),
(r'^$', TekstFormView.as_view()), url(r'^order/(?P<order_id>[a-zA-Z0-9-]+)/', TekstOrderView.as_view()),
(r'^order/(?P<order_id>[a-zA-Z0-9-]+)/', TekstOrderView.as_view()), ]
)
+1 -1
View File
@@ -40,7 +40,7 @@ class TekstFormView(BaseFormView):
}) })
# Filter out all errors that are False: # Filter out all errors that are False:
return dict((error, True) for error, has_happened in errors.iteritems() if has_happened is True) return dict((error, True) for error, has_happened in errors.items() if has_happened is True)
def _get_order_url(self, request, order): def _get_order_url(self, request, order):
return request.build_absolute_uri('/tekst/order/{uuid}/'.format(uuid=order.uuid)) return request.build_absolute_uri('/tekst/order/{uuid}/'.format(uuid=order.uuid))
+1 -1
View File
@@ -1,4 +1,4 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>{% block title %}{% endblock %}</title> <title>{% block title %}{% endblock %}</title>
+1 -1
View File
@@ -1,4 +1,4 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>Kommunikasjonsavdelingen - Bestillingen er sendt</title> <title>Kommunikasjonsavdelingen - Bestillingen er sendt</title>
+1 -1
View File
@@ -1,4 +1,4 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>{% block title %}{% endblock %}</title> <title>{% block title %}{% endblock %}</title>