From c3fb866c73d81bce3c75110849ccc2a6ac8eee39 Mon Sep 17 00:00:00 2001 From: mcbloch Date: Thu, 20 May 2021 16:46:35 +0200 Subject: [PATCH] Add quick 'n dirty manage screen. Fix pricing --- mordor/models.py | 2 +- mordor/templates/mordor/manage.html | 28 ++++++++++++++++++++++++++++ mordor/templates/mordor/winkel.html | 4 ++-- mordor/urls.py | 1 + mordor/views.py | 13 +++++++++++++ templates/base.html | 5 +++++ 6 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 mordor/templates/mordor/manage.html diff --git a/mordor/models.py b/mordor/models.py index e3f6cee..6075820 100644 --- a/mordor/models.py +++ b/mordor/models.py @@ -24,7 +24,7 @@ class Order(TimeStampMixin): return self.ORDER_STATES[self.state] def price_33(self): - return self.amount_33 * 25 + return self.amount_33 * 28 def price_50(self): return self.amount_50 * 30 diff --git a/mordor/templates/mordor/manage.html b/mordor/templates/mordor/manage.html new file mode 100644 index 0000000..a251261 --- /dev/null +++ b/mordor/templates/mordor/manage.html @@ -0,0 +1,28 @@ +{% extends "base.html" %} + +{% block title %}Manage{% endblock %} + +{% block content %} + +

Aangezien we al geruime tijd klant zijn genieten we van horecaprijzen, dit bij aankoop vanaf € 200. +Bestellingen lager dan € 200 gebeuren via de webshop.

+

Bestellingen kunnen doorgegeven worden door te mailen naar order@drinks52.com

+ + +

Genoeg open orders om een bestelling te kunnen plaatsen?

+ {% if sum > 200 %} + Ja + {% else %} + Nee + {% endif %} + {% if sum > 0 %} +

Er staan orders open met een totale waarde van €{{ sum }}.

+ {% else %} +

Er staan geen orders open.

+ {% endif %} + + +{% endblock %} diff --git a/mordor/templates/mordor/winkel.html b/mordor/templates/mordor/winkel.html index a6ae33a..43419b5 100644 --- a/mordor/templates/mordor/winkel.html +++ b/mordor/templates/mordor/winkel.html @@ -11,7 +11,7 @@ let total_sum = 0 function input_changed() { - sum_33 = Number(document.getElementById(`amount_33`).value) * 25; + sum_33 = Number(document.getElementById(`amount_33`).value) * 28; sum_50 = Number(document.getElementById(`amount_50`).value) * 30; let total_field_33 = document.getElementById(`sum_33`); @@ -45,7 +45,7 @@ onblur="this.placeholder='0'" oninput="input_changed()"> x - €25 + €28
=€ diff --git a/mordor/urls.py b/mordor/urls.py index 12962cc..a21a1ae 100644 --- a/mordor/urls.py +++ b/mordor/urls.py @@ -23,6 +23,7 @@ urlpatterns = [ path("", views.index, name="index"), path("winkel", views.winkel, name="winkel"), path("orders", views.orders, name="orders"), + path("manage", views.manage, name="manage"), path("remove_order/", views.remove_order, name="remove_order"), path("admin/", admin.site.urls), path("login/zeus/", include("oauth.urls")), diff --git a/mordor/views.py b/mordor/views.py index 2f6f067..323df84 100644 --- a/mordor/views.py +++ b/mordor/views.py @@ -44,3 +44,16 @@ def orders(req): user_orders = Order.objects.filter(user=req.user) return render(req, "mordor/orders.html", {"orders": user_orders}) + + +def manage(req): + if req.user.is_staff or req.user.is_superuser: + open_orders = Order.objects.filter(state=Order.OPEN) + sum_open_orders = sum([o.total_price() for o in open_orders]) + return render( + req, + "mordor/manage.html", + {"open_orders": open_orders, "sum": sum_open_orders}, + ) + else: + return HttpResponseRedirect(reverse("index")) diff --git a/templates/base.html b/templates/base.html index 74ac56d..def10ab 100644 --- a/templates/base.html +++ b/templates/base.html @@ -33,6 +33,11 @@ {% if user.is_staff or user.is_superuser %} +
  • + + Manage + +
  • Admininterface