From 803c8c7ff3e14662eae8c9014234bf1817175f76 Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Tue, 3 Oct 2017 21:14:07 +0200 Subject: [PATCH] Backoffice first steps + add 403.html (#173) * start working on backoffice * add 403.html --- src/backoffice/__init__.py | 0 src/backoffice/apps.py | 5 +++ src/backoffice/migrations/__init__.py | 0 .../templates/backoffice_index.html | 20 ++++++++++ src/backoffice/templates/infodesk.html | 38 +++++++++++++++++++ src/backoffice/urls.py | 8 ++++ src/backoffice/views.py | 26 +++++++++++++ src/bornhack/settings.py | 1 + src/bornhack/urls.py | 5 +++ src/templates/403.html | 9 +++++ 10 files changed, 112 insertions(+) create mode 100644 src/backoffice/__init__.py create mode 100644 src/backoffice/apps.py create mode 100644 src/backoffice/migrations/__init__.py create mode 100644 src/backoffice/templates/backoffice_index.html create mode 100644 src/backoffice/templates/infodesk.html create mode 100644 src/backoffice/urls.py create mode 100644 src/backoffice/views.py create mode 100644 src/templates/403.html diff --git a/src/backoffice/__init__.py b/src/backoffice/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/backoffice/apps.py b/src/backoffice/apps.py new file mode 100644 index 00000000..c0cd7403 --- /dev/null +++ b/src/backoffice/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class BackofficeConfig(AppConfig): + name = 'backoffice' diff --git a/src/backoffice/migrations/__init__.py b/src/backoffice/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/backoffice/templates/backoffice_index.html b/src/backoffice/templates/backoffice_index.html new file mode 100644 index 00000000..774edacc --- /dev/null +++ b/src/backoffice/templates/backoffice_index.html @@ -0,0 +1,20 @@ +{% extends 'base.html' %} +{% load commonmark %} +{% load static from staticfiles %} +{% load imageutils %} +{% block content %} +
+
+ Please select your desired action below. +
+
+
+

+

+

+
+{% endblock content %} + + diff --git a/src/backoffice/templates/infodesk.html b/src/backoffice/templates/infodesk.html new file mode 100644 index 00000000..554b2520 --- /dev/null +++ b/src/backoffice/templates/infodesk.html @@ -0,0 +1,38 @@ +{% extends 'base.html' %} +{% load commonmark %} +{% load static from staticfiles %} +{% load imageutils %} +{% block content %} +
+

Infodesk Backoffice

+
+ Orders with one or more Products that are not handed out +
+
+
+ + + + + + + + + + {% for order in order_list %} + {% for productrel in order.orderproductrelation_set.all %} + + + + + + + + + {% endfor %} + {% endfor %} +
OrderUserOPR IdProductQuantityHanded Out?
Order #{{ order.id }}{{ order.user }}{{ productrel.id }}{{ productrel.product.name }}{{ productrel.quantity }}{{ productrel.handed_out }}
+
+{% endblock content %} + + diff --git a/src/backoffice/urls.py b/src/backoffice/urls.py new file mode 100644 index 00000000..66d05351 --- /dev/null +++ b/src/backoffice/urls.py @@ -0,0 +1,8 @@ +from django.conf.urls import url +from .views import * + +urlpatterns = [ + url(r'^$', BackofficeIndexView.as_view(), name='index'), + url(r'infodesk/$', InfodeskView.as_view(), name='infodesk_index'), +] + diff --git a/src/backoffice/views.py b/src/backoffice/views.py new file mode 100644 index 00000000..8aace71c --- /dev/null +++ b/src/backoffice/views.py @@ -0,0 +1,26 @@ +from django.views.generic import TemplateView, ListView +from django.shortcuts import redirect +from django.views import View +from django.conf import settings +from django.utils.decorators import method_decorator +from django.http import HttpResponseForbidden +from shop.models import Order +import logging +logger = logging.getLogger("bornhack.%s" % __name__) + + +class StaffMemberRequiredMixin(object): + def dispatch(self, request, *args, **kwargs): + if not request.user.is_staff: + return HttpResponseForbidden() + return super().dispatch(request, *args, **kwargs) + + +class BackofficeIndexView(StaffMemberRequiredMixin, TemplateView): + template_name = "backoffice_index.html" + + +class InfodeskView(StaffMemberRequiredMixin, ListView): + template_name = "infodesk.html" + queryset = Order.objects.filter(orderproductrelation__handed_out=False).distinct() + diff --git a/src/bornhack/settings.py b/src/bornhack/settings.py index 699b7956..1a50cd88 100644 --- a/src/bornhack/settings.py +++ b/src/bornhack/settings.py @@ -44,6 +44,7 @@ INSTALLED_APPS = [ 'people', 'tickets', 'bar', + 'backoffice', 'allauth', 'allauth.account', diff --git a/src/bornhack/urls.py b/src/bornhack/urls.py index 6178d8b8..6341b83e 100644 --- a/src/bornhack/urls.py +++ b/src/bornhack/urls.py @@ -114,6 +114,11 @@ urlpatterns = [ name='people', ), + url( + r'^backoffice/', + include('backoffice.urls', namespace='backoffice') + ), + # camp specific urls below here url( diff --git a/src/templates/403.html b/src/templates/403.html new file mode 100644 index 00000000..68e99f80 --- /dev/null +++ b/src/templates/403.html @@ -0,0 +1,9 @@ +{% extends 'base.html' %} + +{% block content %} + +

+ 403 The forbidden fruit. +

+ +{% endblock %}