Backoffice first steps + add 403.html (#173)

* start working on backoffice

* add 403.html
This commit is contained in:
Thomas Steen Rasmussen 2017-10-03 21:14:07 +02:00 committed by GitHub
parent a4930af92a
commit 803c8c7ff3
10 changed files with 112 additions and 0 deletions

View file

5
src/backoffice/apps.py Normal file
View file

@ -0,0 +1,5 @@
from django.apps import AppConfig
class BackofficeConfig(AppConfig):
name = 'backoffice'

View file

View file

@ -0,0 +1,20 @@
{% extends 'base.html' %}
{% load commonmark %}
{% load static from staticfiles %}
{% load imageutils %}
{% block content %}
<div class="row">
<div class="lead">
Please select your desired action below.
</div>
</div>
<div class="row">
<p>
<ul>
<li><a href="{% url 'backoffice:infodesk_index' %}">Infodesk</a></li>
</ul>
</p>
</div>
{% endblock content %}

View file

@ -0,0 +1,38 @@
{% extends 'base.html' %}
{% load commonmark %}
{% load static from staticfiles %}
{% load imageutils %}
{% block content %}
<div class="row">
<h2>Infodesk Backoffice</h2>
<div class="lead">
Orders with one or more Products that are not handed out
</div>
</div>
<div class="row">
<table class="table table-hover">
<tr>
<th>Order</th>
<th>User</th>
<th>OPR Id</th>
<th>Product</th>
<th>Quantity</th>
<th>Handed Out?</th>
</tr>
{% for order in order_list %}
{% for productrel in order.orderproductrelation_set.all %}
<tr>
<td><a href="/admin/shop/order/{{ order.id }}/change/">Order #{{ order.id }}</a></td>
<td>{{ order.user }}</td>
<td>{{ productrel.id }}</td>
<td>{{ productrel.product.name }}</td>
<td>{{ productrel.quantity }}</td>
<td>{{ productrel.handed_out }}</td>
</tr>
{% endfor %}
{% endfor %}
</table>
</div>
{% endblock content %}

8
src/backoffice/urls.py Normal file
View file

@ -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'),
]

26
src/backoffice/views.py Normal file
View file

@ -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()

View file

@ -44,6 +44,7 @@ INSTALLED_APPS = [
'people', 'people',
'tickets', 'tickets',
'bar', 'bar',
'backoffice',
'allauth', 'allauth',
'allauth.account', 'allauth.account',

View file

@ -114,6 +114,11 @@ urlpatterns = [
name='people', name='people',
), ),
url(
r'^backoffice/',
include('backoffice.urls', namespace='backoffice')
),
# camp specific urls below here # camp specific urls below here
url( url(

9
src/templates/403.html Normal file
View file

@ -0,0 +1,9 @@
{% extends 'base.html' %}
{% block content %}
<p class="lead">
403 The forbidden fruit.
</p>
{% endblock %}