From 6b01bc326ea236da1d141c4fb19e2d50ae1f5e7d Mon Sep 17 00:00:00 2001 From: Nikolai R Kristiansen Date: Mon, 6 Apr 2015 13:17:53 +0200 Subject: [PATCH] Move everything around, cleanups --- .gitignore | 4 +- bestilling/{bestilling => }/__init__.py | 0 bestilling/{bestilling => }/admin.py | 0 bestilling/{bestilling => }/baseviews.py | 2 +- .../migrations/0001_initial.py | 0 .../migrations/0002_auto__add_uploadedfile.py | 0 .../{bestilling => }/migrations/__init__.py | 0 bestilling/{bestilling => }/models.py | 11 ++-- bestilling/{bestilling => }/serializers.py | 0 .../settings-sample.py => settings.py} | 41 ++++++------- bestilling/{bestilling => }/urls.py | 6 +- bestilling/{bestilling => }/utils.py | 0 bestilling/{bestilling => }/views.py | 0 bestilling/{bestilling => }/wsgi.py | 0 {bestilling/design => design}/__init__.py | 0 {bestilling/design => design}/models.py | 1 - {bestilling/design => design}/tests.py | 0 {bestilling/design => design}/urls.py | 5 +- {bestilling/design => design}/views.py | 4 +- bestilling/manage.py => manage.py | 0 {bestilling/prm => prm}/__init__.py | 0 {bestilling/prm => prm}/models.py | 1 + {bestilling/prm => prm}/tests.py | 0 {bestilling/prm => prm}/urls.py | 5 +- {bestilling/prm => prm}/views.py | 39 +++++++------ .../css/bootstrap-responsive.css | 0 .../static => static}/css/bootstrap.css | 0 .../static => static}/css/design/style.css | 0 .../css/images/animated-overlay.gif | Bin .../css/images/glyphicons-halflings-white.png | Bin .../css/images/glyphicons-halflings.png | Bin .../css/images/ui-bg_flat_0_aaaaaa_40x100.png | Bin .../images/ui-bg_flat_75_ffffff_40x100.png | Bin .../images/ui-bg_glass_55_fbf9ee_1x400.png | Bin .../images/ui-bg_glass_65_ffffff_1x400.png | Bin .../images/ui-bg_glass_75_dadada_1x400.png | Bin .../images/ui-bg_glass_75_e6e6e6_1x400.png | Bin .../images/ui-bg_glass_95_fef1ec_1x400.png | Bin .../ui-bg_highlight-soft_75_cccccc_1x100.png | Bin .../css/images/ui-icons_222222_256x240.png | Bin .../css/images/ui-icons_2e83ff_256x240.png | Bin .../css/images/ui-icons_454545_256x240.png | Bin .../css/images/ui-icons_888888_256x240.png | Bin .../css/images/ui-icons_cd0a0a_256x240.png | Bin .../static => static}/css/jquery.ui.css | 0 .../css/jquery.ui.datepicker.css | 0 {bestilling/static => static}/img/design.png | Bin .../static => static}/img/kak_logo.png | Bin {bestilling/static => static}/img/prm.png | Bin {bestilling/static => static}/img/tekst.png | Bin .../static => static}/js/attachments.js | 0 {bestilling/static => static}/js/bootstrap.js | 0 .../static => static}/js/jquery-2.0.0.js | 0 .../static => static}/js/jquery.fileupload.js | 2 +- .../js/jquery.iframe-transport.js | 0 .../static => static}/js/jquery.ui.core.js | 0 .../js/jquery.ui.datepicker.js | 0 .../static => static}/js/jquery.ui.widget.js | 0 {bestilling/tekst => tekst}/__init__.py | 0 {bestilling/tekst => tekst}/models.py | 1 + {bestilling/tekst => tekst}/tests.py | 0 {bestilling/tekst => tekst}/urls.py | 5 +- {bestilling/tekst => tekst}/views.py | 54 +++++++++--------- .../confirmation_mail.txt | 0 .../templates => templates}/design/form.html | 0 .../templates => templates}/design/order.html | 2 +- .../templates => templates}/form_base.html | 2 +- .../templates => templates}/form_success.html | 0 .../templates => templates}/index.html | 0 .../templates => templates}/order_base.html | 0 .../templates => templates}/prm/form.html | 0 .../templates => templates}/prm/order.html | 0 .../templates => templates}/tekst/form.html | 0 .../templates => templates}/tekst/order.html | 0 .../templates => templates}/trello_card.txt | 0 75 files changed, 93 insertions(+), 92 deletions(-) rename bestilling/{bestilling => }/__init__.py (100%) rename bestilling/{bestilling => }/admin.py (100%) rename bestilling/{bestilling => }/baseviews.py (99%) rename bestilling/{bestilling => }/migrations/0001_initial.py (100%) rename bestilling/{bestilling => }/migrations/0002_auto__add_uploadedfile.py (100%) rename bestilling/{bestilling => }/migrations/__init__.py (100%) rename bestilling/{bestilling => }/models.py (82%) rename bestilling/{bestilling => }/serializers.py (100%) rename bestilling/{bestilling/settings-sample.py => settings.py} (79%) rename bestilling/{bestilling => }/urls.py (89%) rename bestilling/{bestilling => }/utils.py (100%) rename bestilling/{bestilling => }/views.py (100%) rename bestilling/{bestilling => }/wsgi.py (100%) rename {bestilling/design => design}/__init__.py (100%) rename {bestilling/design => design}/models.py (99%) rename {bestilling/design => design}/tests.py (100%) rename {bestilling/design => design}/urls.py (65%) rename {bestilling/design => design}/views.py (96%) rename bestilling/manage.py => manage.py (100%) rename {bestilling/prm => prm}/__init__.py (100%) rename {bestilling/prm => prm}/models.py (99%) rename {bestilling/prm => prm}/tests.py (100%) rename {bestilling/prm => prm}/urls.py (63%) rename {bestilling/prm => prm}/views.py (61%) rename {bestilling/static => static}/css/bootstrap-responsive.css (100%) rename {bestilling/static => static}/css/bootstrap.css (100%) rename {bestilling/static => static}/css/design/style.css (100%) rename {bestilling/static => static}/css/images/animated-overlay.gif (100%) rename {bestilling/static => static}/css/images/glyphicons-halflings-white.png (100%) rename {bestilling/static => static}/css/images/glyphicons-halflings.png (100%) rename {bestilling/static => static}/css/images/ui-bg_flat_0_aaaaaa_40x100.png (100%) rename {bestilling/static => static}/css/images/ui-bg_flat_75_ffffff_40x100.png (100%) rename {bestilling/static => static}/css/images/ui-bg_glass_55_fbf9ee_1x400.png (100%) rename {bestilling/static => static}/css/images/ui-bg_glass_65_ffffff_1x400.png (100%) rename {bestilling/static => static}/css/images/ui-bg_glass_75_dadada_1x400.png (100%) rename {bestilling/static => static}/css/images/ui-bg_glass_75_e6e6e6_1x400.png (100%) rename {bestilling/static => static}/css/images/ui-bg_glass_95_fef1ec_1x400.png (100%) rename {bestilling/static => static}/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png (100%) rename {bestilling/static => static}/css/images/ui-icons_222222_256x240.png (100%) rename {bestilling/static => static}/css/images/ui-icons_2e83ff_256x240.png (100%) rename {bestilling/static => static}/css/images/ui-icons_454545_256x240.png (100%) rename {bestilling/static => static}/css/images/ui-icons_888888_256x240.png (100%) rename {bestilling/static => static}/css/images/ui-icons_cd0a0a_256x240.png (100%) rename {bestilling/static => static}/css/jquery.ui.css (100%) rename {bestilling/static => static}/css/jquery.ui.datepicker.css (100%) rename {bestilling/static => static}/img/design.png (100%) rename {bestilling/static => static}/img/kak_logo.png (100%) rename {bestilling/static => static}/img/prm.png (100%) rename {bestilling/static => static}/img/tekst.png (100%) rename {bestilling/static => static}/js/attachments.js (100%) rename {bestilling/static => static}/js/bootstrap.js (100%) rename {bestilling/static => static}/js/jquery-2.0.0.js (100%) rename {bestilling/static => static}/js/jquery.fileupload.js (99%) rename {bestilling/static => static}/js/jquery.iframe-transport.js (100%) rename {bestilling/static => static}/js/jquery.ui.core.js (100%) rename {bestilling/static => static}/js/jquery.ui.datepicker.js (100%) rename {bestilling/static => static}/js/jquery.ui.widget.js (100%) rename {bestilling/tekst => tekst}/__init__.py (100%) rename {bestilling/tekst => tekst}/models.py (99%) rename {bestilling/tekst => tekst}/tests.py (100%) rename {bestilling/tekst => tekst}/urls.py (64%) rename {bestilling/tekst => tekst}/views.py (56%) rename {bestilling/templates => templates}/confirmation_mail.txt (100%) rename {bestilling/templates => templates}/design/form.html (100%) rename {bestilling/templates => templates}/design/order.html (94%) rename {bestilling/templates => templates}/form_base.html (97%) rename {bestilling/templates => templates}/form_success.html (100%) rename {bestilling/templates => templates}/index.html (100%) rename {bestilling/templates => templates}/order_base.html (100%) rename {bestilling/templates => templates}/prm/form.html (100%) rename {bestilling/templates => templates}/prm/order.html (100%) rename {bestilling/templates => templates}/tekst/form.html (100%) rename {bestilling/templates => templates}/tekst/order.html (100%) rename {bestilling/templates => templates}/trello_card.txt (100%) diff --git a/.gitignore b/.gitignore index 1701e65..ee17df1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,6 @@ venv .idea *.pyc *.swp -bestillingsskjema.db -bestilling/bestilling/settings.py +db.sqlite3 +bestilling/local_settings.py uploads diff --git a/bestilling/bestilling/__init__.py b/bestilling/__init__.py similarity index 100% rename from bestilling/bestilling/__init__.py rename to bestilling/__init__.py diff --git a/bestilling/bestilling/admin.py b/bestilling/admin.py similarity index 100% rename from bestilling/bestilling/admin.py rename to bestilling/admin.py diff --git a/bestilling/bestilling/baseviews.py b/bestilling/baseviews.py similarity index 99% rename from bestilling/bestilling/baseviews.py rename to bestilling/baseviews.py index 3d7af78..6d45ac2 100644 --- a/bestilling/bestilling/baseviews.py +++ b/bestilling/baseviews.py @@ -11,7 +11,7 @@ from django.views.generic import TemplateView from django.conf import settings import trello -import utils +from bestilling import utils from bestilling.models import Attachment diff --git a/bestilling/bestilling/migrations/0001_initial.py b/bestilling/migrations/0001_initial.py similarity index 100% rename from bestilling/bestilling/migrations/0001_initial.py rename to bestilling/migrations/0001_initial.py diff --git a/bestilling/bestilling/migrations/0002_auto__add_uploadedfile.py b/bestilling/migrations/0002_auto__add_uploadedfile.py similarity index 100% rename from bestilling/bestilling/migrations/0002_auto__add_uploadedfile.py rename to bestilling/migrations/0002_auto__add_uploadedfile.py diff --git a/bestilling/bestilling/migrations/__init__.py b/bestilling/migrations/__init__.py similarity index 100% rename from bestilling/bestilling/migrations/__init__.py rename to bestilling/migrations/__init__.py diff --git a/bestilling/bestilling/models.py b/bestilling/models.py similarity index 82% rename from bestilling/bestilling/models.py rename to bestilling/models.py index a5d8408..a0de841 100644 --- a/bestilling/bestilling/models.py +++ b/bestilling/models.py @@ -7,17 +7,16 @@ from bestilling.utils import validate_file_extension class Attachment(models.Model): - def limit_order_choices(): - q = models.Q(app_label='design', model='designorder') \ - | models.Q(app_label='tekst', model='tekstorder') \ - | models.Q(app_label='prm', model='prmorder') - return q + + _limit_order_choices = models.Q(app_label='design', model='designorder') \ + | models.Q(app_label='tekst', model='tekstorder') \ + | models.Q(app_label='prm', model='prmorder') uploaded_file = models.FileField(upload_to='uploads', validators=[validate_file_extension]) trello_id = models.CharField(max_length=40, blank=True, null=True) created = models.DateTimeField(auto_now_add=True) - 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() order_object = generic.GenericForeignKey('content_type', 'object_id') diff --git a/bestilling/bestilling/serializers.py b/bestilling/serializers.py similarity index 100% rename from bestilling/bestilling/serializers.py rename to bestilling/serializers.py diff --git a/bestilling/bestilling/settings-sample.py b/bestilling/settings.py similarity index 79% rename from bestilling/bestilling/settings-sample.py rename to bestilling/settings.py index a25c8ea..5d6017f 100644 --- a/bestilling/bestilling/settings-sample.py +++ b/bestilling/settings.py @@ -1,11 +1,11 @@ -# Django settings for bestilling project. Fill out variables marked with TODO to make it work. +# Copy and change variables marked with TODO to local_settings.py to make it work. import os DEBUG = True TEMPLATE_DEBUG = DEBUG # Path of our project: -PROJECT_PATH = 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)) ADMINS = ( # ('Your Name', 'your_email@example.com'), @@ -15,22 +15,17 @@ MANAGERS = ADMINS DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.', # TODO Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. - 'NAME': 'bestillingsskjema', # Or path to database file if using sqlite3. - # The following settings are not used with sqlite3: - 'USER': '', - 'PASSWORD': '', - 'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP. - 'PORT': '', # Set to empty string for default. + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': '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 +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 @@ -72,7 +67,7 @@ MEDIA_URL = '' # 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 = '' +STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') # URL prefix for static files. # Example: "http://example.com/static/", "http://static.example.com/" @@ -83,7 +78,7 @@ 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. - PROJECT_PATH + '/static/', + os.path.join(BASE_DIR, 'static'), ) # List of finder classes that know how to find static files in @@ -91,7 +86,6 @@ STATICFILES_DIRS = ( 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. @@ -101,7 +95,6 @@ SECRET_KEY = '' TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', -# 'django.template.loaders.eggs.Loader', ) MIDDLEWARE_CLASSES = ( @@ -110,8 +103,6 @@ MIDDLEWARE_CLASSES = ( 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', - # Uncomment the next line for simple clickjacking protection: - # 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) ROOT_URLCONF = 'bestilling.urls' @@ -123,7 +114,7 @@ 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. - PROJECT_PATH + '/templates/', + os.path.join(BASE_DIR, 'templates'), ) INSTALLED_APPS = ( @@ -138,6 +129,7 @@ INSTALLED_APPS = ( 'design', 'tekst', 'prm', + 'bestilling' ) # A sample logging configuration. The only tangible logging @@ -175,4 +167,9 @@ MAIL_KAK_PRM = 'kak-prm@studentersamfundet.no' UPLOAD_FILENAME_EXTENSIONS_ALLOWED = [ 'png', 'ai', 'eps', 'jpeg', 'jpg', 'tif', 'tiff', 'indd', 'webp' - 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'txt', 'zip'] \ No newline at end of file + 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'txt', 'zip'] + +try: + from local_settings import * +except ImportError: + pass \ No newline at end of file diff --git a/bestilling/bestilling/urls.py b/bestilling/urls.py similarity index 89% rename from bestilling/bestilling/urls.py rename to bestilling/urls.py index 2e33985..132ac70 100644 --- a/bestilling/bestilling/urls.py +++ b/bestilling/urls.py @@ -6,7 +6,8 @@ from bestilling.views import IndexView, AttachmentView admin.autodiscover() -urlpatterns = patterns('', +urlpatterns = patterns( + '', url(r'^design/', include('design.urls')), url(r'^tekst/', include('tekst.urls')), url(r'^prm/', include('prm.urls')), @@ -15,7 +16,8 @@ urlpatterns = patterns('', url(r'^admin/', include(admin.site.urls)), ) if settings.DEBUG: - urlpatterns += patterns('', + urlpatterns += patterns( + '', url(r'^media/(?P.*)$', 'django.views.static.serve', { 'document_root': settings.MEDIA_ROOT, }), diff --git a/bestilling/bestilling/utils.py b/bestilling/utils.py similarity index 100% rename from bestilling/bestilling/utils.py rename to bestilling/utils.py diff --git a/bestilling/bestilling/views.py b/bestilling/views.py similarity index 100% rename from bestilling/bestilling/views.py rename to bestilling/views.py diff --git a/bestilling/bestilling/wsgi.py b/bestilling/wsgi.py similarity index 100% rename from bestilling/bestilling/wsgi.py rename to bestilling/wsgi.py diff --git a/bestilling/design/__init__.py b/design/__init__.py similarity index 100% rename from bestilling/design/__init__.py rename to design/__init__.py diff --git a/bestilling/design/models.py b/design/models.py similarity index 99% rename from bestilling/design/models.py rename to design/models.py index 64516c1..a2a3240 100644 --- a/bestilling/design/models.py +++ b/design/models.py @@ -26,4 +26,3 @@ class DesignOrder(Order): colour = models.CharField(max_length=50) marger = models.CharField(max_length=50) content = models.TextField(blank=True, null=True) - diff --git a/bestilling/design/tests.py b/design/tests.py similarity index 100% rename from bestilling/design/tests.py rename to design/tests.py diff --git a/bestilling/design/urls.py b/design/urls.py similarity index 65% rename from bestilling/design/urls.py rename to design/urls.py index 502feba..de9b267 100644 --- a/bestilling/design/urls.py +++ b/design/urls.py @@ -1,7 +1,8 @@ -from django.conf.urls import patterns, include, url +from django.conf.urls import patterns from design.views import DesignFormView, DesignOrderView -urlpatterns = patterns('design.views', +urlpatterns = patterns( + 'design.views', (r'^$', DesignFormView.as_view()), (r'^order/(?P[a-zA-Z0-9-]+)/', DesignOrderView.as_view()), ) diff --git a/bestilling/design/views.py b/design/views.py similarity index 96% rename from bestilling/design/views.py rename to design/views.py index 3202466..820be3a 100644 --- a/bestilling/design/views.py +++ b/design/views.py @@ -4,9 +4,7 @@ from bestilling import settings from bestilling.baseviews import BaseFormView, BaseOrderView from datetime import datetime from design.models import DesignOrder -from django.core.context_processors import csrf -from django.http import HttpResponse, Http404 -from django.template import Context, Template +from django.template import Context from django.template.loader import get_template diff --git a/bestilling/manage.py b/manage.py similarity index 100% rename from bestilling/manage.py rename to manage.py diff --git a/bestilling/prm/__init__.py b/prm/__init__.py similarity index 100% rename from bestilling/prm/__init__.py rename to prm/__init__.py diff --git a/bestilling/prm/models.py b/prm/models.py similarity index 99% rename from bestilling/prm/models.py rename to prm/models.py index 7085458..1984044 100644 --- a/bestilling/prm/models.py +++ b/prm/models.py @@ -1,6 +1,7 @@ from bestilling.models import Order from django.db import models + class PrmOrder(Order): assignment_type = models.CharField(max_length=200) content = models.TextField(blank=True, null=True) diff --git a/bestilling/prm/tests.py b/prm/tests.py similarity index 100% rename from bestilling/prm/tests.py rename to prm/tests.py diff --git a/bestilling/prm/urls.py b/prm/urls.py similarity index 63% rename from bestilling/prm/urls.py rename to prm/urls.py index 0ac0184..a9a3cc1 100644 --- a/bestilling/prm/urls.py +++ b/prm/urls.py @@ -1,7 +1,8 @@ -from django.conf.urls import patterns, include, url +from django.conf.urls import patterns from prm.views import PrmFormView, PrmOrderView -urlpatterns = patterns('tekst.views', +urlpatterns = patterns( + 'tekst.views', (r'^$', PrmFormView.as_view()), (r'^order/(?P[a-zA-Z0-9-]+)/', PrmOrderView.as_view()), ) diff --git a/bestilling/prm/views.py b/prm/views.py similarity index 61% rename from bestilling/prm/views.py rename to prm/views.py index 3bac33a..dd040a2 100644 --- a/bestilling/prm/views.py +++ b/prm/views.py @@ -1,15 +1,15 @@ -#-*- encoding: utf-8 -*- +# -*- encoding: utf-8 -*- -from bestilling import settings -from bestilling.baseviews import BaseFormView, BaseOrderView from datetime import datetime -from django.core.context_processors import csrf -from django.http import HttpResponse, Http404 +from django.conf import settings from django.template import Context from django.template.loader import get_template + +from bestilling.baseviews import BaseFormView, BaseOrderView from prm.models import PrmOrder + class PrmFormView(BaseFormView): form_template_name = 'prm/form.html' trello_board_id = settings.TRELLO_PRM_BOARD_ID @@ -28,9 +28,9 @@ class PrmFormView(BaseFormView): def _get_errors(self, params): errors = super(PrmFormView, self)._get_errors(params) errors.update({ - 'assignment_type_error' : params['assignment_type'] == '' or len(params['assignment_type']) > 200, - 'assignment_type_other_error' : params['assignment_type'] == 'other' and (params['assignment_type_other'] == '' or len(params['assignment_type_other']) > 200), - 'content_error' : params['content'] == '', + 'assignment_type_error': params['assignment_type'] == '' or len(params['assignment_type']) > 200, + 'assignment_type_other_error': params['assignment_type'] == 'other' and (params['assignment_type_other'] == '' or len(params['assignment_type_other']) > 200), + 'content_error': params['content'] == '', }) # Filter out all errors that are False: @@ -41,28 +41,28 @@ class PrmFormView(BaseFormView): def _save_data(self, request, params): params.update({ - 'assignment_type' : params['assignment_type'] if params['assignment_type'] != 'other' else params['assignment_type_other'], + 'assignment_type': params['assignment_type'] if params['assignment_type'] != 'other' else params['assignment_type_other'], }) deadline = datetime.strptime(params['deadline'], '%Y-%m-%d') card = self._save_to_trello( - card_name = params['client'], - card_description = "", + card_name=params['client'], + card_description="", card_due=datetime.strftime(deadline, '%m/%d/%y'), ) card_id = card.id order = PrmOrder( - client = params['client'], - deadline = deadline.date(), - contact_name = params['contact_name'], - contact_email = params['contact_email'], - contact_number = params['contact_number'], - assignment_type = params['assignment_type'], - content = params['content'], - trello_card_id = str(card_id) + client=params['client'], + deadline=deadline.date(), + contact_name=params['contact_name'], + contact_email=params['contact_email'], + contact_number=params['contact_number'], + assignment_type=params['assignment_type'], + content=params['content'], + trello_card_id=str(card_id) ) order.save() @@ -73,6 +73,7 @@ class PrmFormView(BaseFormView): return order + class PrmOrderView(BaseOrderView): template_name = "prm/order.html" diff --git a/bestilling/static/css/bootstrap-responsive.css b/static/css/bootstrap-responsive.css similarity index 100% rename from bestilling/static/css/bootstrap-responsive.css rename to static/css/bootstrap-responsive.css diff --git a/bestilling/static/css/bootstrap.css b/static/css/bootstrap.css similarity index 100% rename from bestilling/static/css/bootstrap.css rename to static/css/bootstrap.css diff --git a/bestilling/static/css/design/style.css b/static/css/design/style.css similarity index 100% rename from bestilling/static/css/design/style.css rename to static/css/design/style.css diff --git a/bestilling/static/css/images/animated-overlay.gif b/static/css/images/animated-overlay.gif similarity index 100% rename from bestilling/static/css/images/animated-overlay.gif rename to static/css/images/animated-overlay.gif diff --git a/bestilling/static/css/images/glyphicons-halflings-white.png b/static/css/images/glyphicons-halflings-white.png similarity index 100% rename from bestilling/static/css/images/glyphicons-halflings-white.png rename to static/css/images/glyphicons-halflings-white.png diff --git a/bestilling/static/css/images/glyphicons-halflings.png b/static/css/images/glyphicons-halflings.png similarity index 100% rename from bestilling/static/css/images/glyphicons-halflings.png rename to static/css/images/glyphicons-halflings.png diff --git a/bestilling/static/css/images/ui-bg_flat_0_aaaaaa_40x100.png b/static/css/images/ui-bg_flat_0_aaaaaa_40x100.png similarity index 100% rename from bestilling/static/css/images/ui-bg_flat_0_aaaaaa_40x100.png rename to static/css/images/ui-bg_flat_0_aaaaaa_40x100.png diff --git a/bestilling/static/css/images/ui-bg_flat_75_ffffff_40x100.png b/static/css/images/ui-bg_flat_75_ffffff_40x100.png similarity index 100% rename from bestilling/static/css/images/ui-bg_flat_75_ffffff_40x100.png rename to static/css/images/ui-bg_flat_75_ffffff_40x100.png diff --git a/bestilling/static/css/images/ui-bg_glass_55_fbf9ee_1x400.png b/static/css/images/ui-bg_glass_55_fbf9ee_1x400.png similarity index 100% rename from bestilling/static/css/images/ui-bg_glass_55_fbf9ee_1x400.png rename to static/css/images/ui-bg_glass_55_fbf9ee_1x400.png diff --git a/bestilling/static/css/images/ui-bg_glass_65_ffffff_1x400.png b/static/css/images/ui-bg_glass_65_ffffff_1x400.png similarity index 100% rename from bestilling/static/css/images/ui-bg_glass_65_ffffff_1x400.png rename to static/css/images/ui-bg_glass_65_ffffff_1x400.png diff --git a/bestilling/static/css/images/ui-bg_glass_75_dadada_1x400.png b/static/css/images/ui-bg_glass_75_dadada_1x400.png similarity index 100% rename from bestilling/static/css/images/ui-bg_glass_75_dadada_1x400.png rename to static/css/images/ui-bg_glass_75_dadada_1x400.png diff --git a/bestilling/static/css/images/ui-bg_glass_75_e6e6e6_1x400.png b/static/css/images/ui-bg_glass_75_e6e6e6_1x400.png similarity index 100% rename from bestilling/static/css/images/ui-bg_glass_75_e6e6e6_1x400.png rename to static/css/images/ui-bg_glass_75_e6e6e6_1x400.png diff --git a/bestilling/static/css/images/ui-bg_glass_95_fef1ec_1x400.png b/static/css/images/ui-bg_glass_95_fef1ec_1x400.png similarity index 100% rename from bestilling/static/css/images/ui-bg_glass_95_fef1ec_1x400.png rename to static/css/images/ui-bg_glass_95_fef1ec_1x400.png diff --git a/bestilling/static/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png b/static/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png similarity index 100% rename from bestilling/static/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png rename to static/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png diff --git a/bestilling/static/css/images/ui-icons_222222_256x240.png b/static/css/images/ui-icons_222222_256x240.png similarity index 100% rename from bestilling/static/css/images/ui-icons_222222_256x240.png rename to static/css/images/ui-icons_222222_256x240.png diff --git a/bestilling/static/css/images/ui-icons_2e83ff_256x240.png b/static/css/images/ui-icons_2e83ff_256x240.png similarity index 100% rename from bestilling/static/css/images/ui-icons_2e83ff_256x240.png rename to static/css/images/ui-icons_2e83ff_256x240.png diff --git a/bestilling/static/css/images/ui-icons_454545_256x240.png b/static/css/images/ui-icons_454545_256x240.png similarity index 100% rename from bestilling/static/css/images/ui-icons_454545_256x240.png rename to static/css/images/ui-icons_454545_256x240.png diff --git a/bestilling/static/css/images/ui-icons_888888_256x240.png b/static/css/images/ui-icons_888888_256x240.png similarity index 100% rename from bestilling/static/css/images/ui-icons_888888_256x240.png rename to static/css/images/ui-icons_888888_256x240.png diff --git a/bestilling/static/css/images/ui-icons_cd0a0a_256x240.png b/static/css/images/ui-icons_cd0a0a_256x240.png similarity index 100% rename from bestilling/static/css/images/ui-icons_cd0a0a_256x240.png rename to static/css/images/ui-icons_cd0a0a_256x240.png diff --git a/bestilling/static/css/jquery.ui.css b/static/css/jquery.ui.css similarity index 100% rename from bestilling/static/css/jquery.ui.css rename to static/css/jquery.ui.css diff --git a/bestilling/static/css/jquery.ui.datepicker.css b/static/css/jquery.ui.datepicker.css similarity index 100% rename from bestilling/static/css/jquery.ui.datepicker.css rename to static/css/jquery.ui.datepicker.css diff --git a/bestilling/static/img/design.png b/static/img/design.png similarity index 100% rename from bestilling/static/img/design.png rename to static/img/design.png diff --git a/bestilling/static/img/kak_logo.png b/static/img/kak_logo.png similarity index 100% rename from bestilling/static/img/kak_logo.png rename to static/img/kak_logo.png diff --git a/bestilling/static/img/prm.png b/static/img/prm.png similarity index 100% rename from bestilling/static/img/prm.png rename to static/img/prm.png diff --git a/bestilling/static/img/tekst.png b/static/img/tekst.png similarity index 100% rename from bestilling/static/img/tekst.png rename to static/img/tekst.png diff --git a/bestilling/static/js/attachments.js b/static/js/attachments.js similarity index 100% rename from bestilling/static/js/attachments.js rename to static/js/attachments.js diff --git a/bestilling/static/js/bootstrap.js b/static/js/bootstrap.js similarity index 100% rename from bestilling/static/js/bootstrap.js rename to static/js/bootstrap.js diff --git a/bestilling/static/js/jquery-2.0.0.js b/static/js/jquery-2.0.0.js similarity index 100% rename from bestilling/static/js/jquery-2.0.0.js rename to static/js/jquery-2.0.0.js diff --git a/bestilling/static/js/jquery.fileupload.js b/static/js/jquery.fileupload.js similarity index 99% rename from bestilling/static/js/jquery.fileupload.js rename to static/js/jquery.fileupload.js index a4cfdc0..6689f65 100644 --- a/bestilling/static/js/jquery.fileupload.js +++ b/static/js/jquery.fileupload.js @@ -18,7 +18,7 @@ // Register as an anonymous AMD module: define([ 'jquery', - 'jquery.ui.widget' + 'jquery.ui.widget.js' ], factory); } else { // Browser globals: diff --git a/bestilling/static/js/jquery.iframe-transport.js b/static/js/jquery.iframe-transport.js similarity index 100% rename from bestilling/static/js/jquery.iframe-transport.js rename to static/js/jquery.iframe-transport.js diff --git a/bestilling/static/js/jquery.ui.core.js b/static/js/jquery.ui.core.js similarity index 100% rename from bestilling/static/js/jquery.ui.core.js rename to static/js/jquery.ui.core.js diff --git a/bestilling/static/js/jquery.ui.datepicker.js b/static/js/jquery.ui.datepicker.js similarity index 100% rename from bestilling/static/js/jquery.ui.datepicker.js rename to static/js/jquery.ui.datepicker.js diff --git a/bestilling/static/js/jquery.ui.widget.js b/static/js/jquery.ui.widget.js similarity index 100% rename from bestilling/static/js/jquery.ui.widget.js rename to static/js/jquery.ui.widget.js diff --git a/bestilling/tekst/__init__.py b/tekst/__init__.py similarity index 100% rename from bestilling/tekst/__init__.py rename to tekst/__init__.py diff --git a/bestilling/tekst/models.py b/tekst/models.py similarity index 99% rename from bestilling/tekst/models.py rename to tekst/models.py index cfa941a..91144f2 100644 --- a/bestilling/tekst/models.py +++ b/tekst/models.py @@ -1,6 +1,7 @@ from bestilling.models import Order from django.db import models + class TekstOrder(Order): text_type = models.CharField(max_length=50) length = models.CharField(max_length=50) diff --git a/bestilling/tekst/tests.py b/tekst/tests.py similarity index 100% rename from bestilling/tekst/tests.py rename to tekst/tests.py diff --git a/bestilling/tekst/urls.py b/tekst/urls.py similarity index 64% rename from bestilling/tekst/urls.py rename to tekst/urls.py index b93be77..0d3abff 100644 --- a/bestilling/tekst/urls.py +++ b/tekst/urls.py @@ -1,7 +1,8 @@ -from django.conf.urls import patterns, include, url +from django.conf.urls import patterns from tekst.views import TekstFormView, TekstOrderView -urlpatterns = patterns('tekst.views', +urlpatterns = patterns( + 'tekst.views', (r'^$', TekstFormView.as_view()), (r'^order/(?P[a-zA-Z0-9-]+)/', TekstOrderView.as_view()), ) diff --git a/bestilling/tekst/views.py b/tekst/views.py similarity index 56% rename from bestilling/tekst/views.py rename to tekst/views.py index 3ae544e..de038f0 100644 --- a/bestilling/tekst/views.py +++ b/tekst/views.py @@ -1,15 +1,14 @@ -#-*- encoding: utf-8 -*- +# -*- encoding: utf-8 -*- - -from bestilling import settings -from bestilling.baseviews import BaseFormView, BaseOrderView from datetime import datetime -from django.core.context_processors import csrf -from django.http import HttpResponse, Http404 +from django.conf import settings from django.template import Context from django.template.loader import get_template + +from bestilling.baseviews import BaseFormView, BaseOrderView from tekst.models import TekstOrder + class TekstFormView(BaseFormView): form_template_name = 'tekst/form.html' trello_board_id = settings.TRELLO_TEKST_BOARD_ID @@ -32,12 +31,12 @@ class TekstFormView(BaseFormView): def _get_errors(self, params): errors = super(TekstFormView, self)._get_errors(params) errors.update({ - 'text_type_error' : params['text_type'] == '' or len(params['text_type']) > 50, - 'text_type_other_error' : params['text_type'] == 'other' and (params['text_type_other'] == '' or len(params['text_type_other']) > 50), - 'length_error' : params['length'] == '' or len(params['length']) > 50, - 'image_error' : params['image'] == '' or len(params['image']) > 50, - 'interview_name_error' : len(params['interview_name']) > 20, - 'content_error' : False, + 'text_type_error': params['text_type'] == '' or len(params['text_type']) > 50, + 'text_type_other_error': params['text_type'] == 'other' and (params['text_type_other'] == '' or len(params['text_type_other']) > 50), + 'length_error': params['length'] == '' or len(params['length']) > 50, + 'image_error': params['image'] == '' or len(params['image']) > 50, + 'interview_name_error': len(params['interview_name']) > 20, + 'content_error': False, }) # Filter out all errors that are False: @@ -48,32 +47,32 @@ class TekstFormView(BaseFormView): def _save_data(self, request, params): params.update({ - 'text_type' : params['text_type'] if params['text_type'] != 'other' else params['text_type_other'], + 'text_type': params['text_type'] if params['text_type'] != 'other' else params['text_type_other'], }) deadline = datetime.strptime(params['deadline'], '%Y-%m-%d') card = self._save_to_trello( - card_name = params['client'], - card_description = "", + card_name=params['client'], + card_description="", card_due=datetime.strftime(deadline, '%m/%d/%y'), ) card_id = card.id order = TekstOrder( - client = params['client'], - deadline = deadline.date(), - contact_name = params['contact_name'], - contact_email = params['contact_email'], - contact_number = params['contact_number'], - text_type = params['text_type'], - length = params['length'], - image = params['image'], - interview_name = params['interview_name'], - interview_contact = params['interview_contact'], - content = params['content'], - trello_card_id = str(card_id) + client=params['client'], + deadline=deadline.date(), + contact_name=params['contact_name'], + contact_email=params['contact_email'], + contact_number=params['contact_number'], + text_type=params['text_type'], + length=params['length'], + image=params['image'], + interview_name=params['interview_name'], + interview_contact=params['interview_contact'], + content=params['content'], + trello_card_id=str(card_id) ) order.save() @@ -84,6 +83,7 @@ class TekstFormView(BaseFormView): return order + class TekstOrderView(BaseOrderView): template_name = "tekst/order.html" diff --git a/bestilling/templates/confirmation_mail.txt b/templates/confirmation_mail.txt similarity index 100% rename from bestilling/templates/confirmation_mail.txt rename to templates/confirmation_mail.txt diff --git a/bestilling/templates/design/form.html b/templates/design/form.html similarity index 100% rename from bestilling/templates/design/form.html rename to templates/design/form.html diff --git a/bestilling/templates/design/order.html b/templates/design/order.html similarity index 94% rename from bestilling/templates/design/order.html rename to templates/design/order.html index 4fe99ed..03077c5 100644 --- a/bestilling/templates/design/order.html +++ b/templates/design/order.html @@ -1,4 +1,4 @@ -{% extends "order_base.html"%} +{% extends "order_base.html" %} {% block title %}Kommunikasjonsavdelingen - Designoppdrag nr {{ order.id }}{% endblock%} diff --git a/bestilling/templates/form_base.html b/templates/form_base.html similarity index 97% rename from bestilling/templates/form_base.html rename to templates/form_base.html index 8e2daba..0736085 100644 --- a/bestilling/templates/form_base.html +++ b/templates/form_base.html @@ -24,7 +24,7 @@

{% block header %}{% endblock %}

-
{% csrf_token %} + {% csrf_token %}
Forening diff --git a/bestilling/templates/form_success.html b/templates/form_success.html similarity index 100% rename from bestilling/templates/form_success.html rename to templates/form_success.html diff --git a/bestilling/templates/index.html b/templates/index.html similarity index 100% rename from bestilling/templates/index.html rename to templates/index.html diff --git a/bestilling/templates/order_base.html b/templates/order_base.html similarity index 100% rename from bestilling/templates/order_base.html rename to templates/order_base.html diff --git a/bestilling/templates/prm/form.html b/templates/prm/form.html similarity index 100% rename from bestilling/templates/prm/form.html rename to templates/prm/form.html diff --git a/bestilling/templates/prm/order.html b/templates/prm/order.html similarity index 100% rename from bestilling/templates/prm/order.html rename to templates/prm/order.html diff --git a/bestilling/templates/tekst/form.html b/templates/tekst/form.html similarity index 100% rename from bestilling/templates/tekst/form.html rename to templates/tekst/form.html diff --git a/bestilling/templates/tekst/order.html b/templates/tekst/order.html similarity index 100% rename from bestilling/templates/tekst/order.html rename to templates/tekst/order.html diff --git a/bestilling/templates/trello_card.txt b/templates/trello_card.txt similarity index 100% rename from bestilling/templates/trello_card.txt rename to templates/trello_card.txt