Backoffice first steps + add 403.html (#173)
* start working on backoffice * add 403.html
This commit is contained in:
parent
a4930af92a
commit
803c8c7ff3
0
src/backoffice/__init__.py
Normal file
0
src/backoffice/__init__.py
Normal file
5
src/backoffice/apps.py
Normal file
5
src/backoffice/apps.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class BackofficeConfig(AppConfig):
|
||||
name = 'backoffice'
|
0
src/backoffice/migrations/__init__.py
Normal file
0
src/backoffice/migrations/__init__.py
Normal file
20
src/backoffice/templates/backoffice_index.html
Normal file
20
src/backoffice/templates/backoffice_index.html
Normal 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 %}
|
||||
|
||||
|
38
src/backoffice/templates/infodesk.html
Normal file
38
src/backoffice/templates/infodesk.html
Normal 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
8
src/backoffice/urls.py
Normal 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
26
src/backoffice/views.py
Normal 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()
|
||||
|
|
@ -44,6 +44,7 @@ INSTALLED_APPS = [
|
|||
'people',
|
||||
'tickets',
|
||||
'bar',
|
||||
'backoffice',
|
||||
|
||||
'allauth',
|
||||
'allauth.account',
|
||||
|
|
|
@ -114,6 +114,11 @@ urlpatterns = [
|
|||
name='people',
|
||||
),
|
||||
|
||||
url(
|
||||
r'^backoffice/',
|
||||
include('backoffice.urls', namespace='backoffice')
|
||||
),
|
||||
|
||||
# camp specific urls below here
|
||||
|
||||
url(
|
||||
|
|
9
src/templates/403.html
Normal file
9
src/templates/403.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<p class="lead">
|
||||
403 The forbidden fruit.
|
||||
</p>
|
||||
|
||||
{% endblock %}
|
Loading…
Reference in a new issue