Move everything around, cleanups
No files matched your search
@@ -2,6 +2,6 @@ venv
|
||||
.idea
|
||||
*.pyc
|
||||
*.swp
|
||||
bestillingsskjema.db
|
||||
bestilling/bestilling/settings.py
|
||||
db.sqlite3
|
||||
bestilling/local_settings.py
|
||||
uploads
|
||||
@@ -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
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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
|
||||
@@ -176,3 +168,8 @@ 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']
|
||||
|
||||
try:
|
||||
from local_settings import *
|
||||
except ImportError:
|
||||
pass
|
||||
@@ -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<path>.*)$', 'django.views.static.serve', {
|
||||
'document_root': settings.MEDIA_ROOT,
|
||||
}),
|
||||
@@ -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)
|
||||
|
||||
@@ -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<order_id>[a-zA-Z0-9-]+)/', DesignOrderView.as_view()),
|
||||
)
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
@@ -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<order_id>[a-zA-Z0-9-]+)/', PrmOrderView.as_view()),
|
||||
)
|
||||
@@ -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"
|
||||
|
||||
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 180 B After Width: | Height: | Size: 180 B |
|
Before Width: | Height: | Size: 178 B After Width: | Height: | Size: 178 B |
|
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 120 B |
|
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 105 B |
|
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 111 B |
|
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 110 B |
|
Before Width: | Height: | Size: 119 B After Width: | Height: | Size: 119 B |
|
Before Width: | Height: | Size: 101 B After Width: | Height: | Size: 101 B |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
@@ -18,7 +18,7 @@
|
||||
// Register as an anonymous AMD module:
|
||||
define([
|
||||
'jquery',
|
||||
'jquery.ui.widget'
|
||||
'jquery.ui.widget.js'
|
||||
], factory);
|
||||
} else {
|
||||
// Browser globals:
|
||||
@@ -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)
|
||||
@@ -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<order_id>[a-zA-Z0-9-]+)/', TekstOrderView.as_view()),
|
||||
)
|
||||
@@ -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"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% extends "order_base.html"%}
|
||||
{% extends "order_base.html" %}
|
||||
|
||||
{% block title %}Kommunikasjonsavdelingen - Designoppdrag nr {{ order.id }}{% endblock%}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</script>
|
||||
<h3 style="margin-left:15px;">{% block header %}{% endblock %}</h3>
|
||||
|
||||
<form method="post" action="." method="post" id="bestilling">{% csrf_token %}
|
||||
<form method="post" action="" method="post" id="bestilling">{% csrf_token %}
|
||||
|
||||
<div class="formitem">
|
||||
<legend>Forening</legend>
|
||||