Add quick 'n dirty manage screen. Fix pricing

This commit is contained in:
mcbloch 2021-05-20 16:46:35 +02:00
parent a67ad1da9e
commit c3fb866c73
6 changed files with 50 additions and 3 deletions

View file

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

View file

@ -0,0 +1,28 @@
{% extends "base.html" %}
{% block title %}Manage{% endblock %}
{% block content %}
<p>Aangezien we al geruime tijd klant zijn genieten we van horecaprijzen, dit bij aankoop vanaf € 200.
Bestellingen lager dan € 200 gebeuren via de webshop.</p>
<p>Bestellingen kunnen doorgegeven worden door te mailen naar <a href="mailto:order@drinks52.com">order@drinks52.com</a></p>
<ul>
<li>33CL: Kostprijs per bak: €23.32 + €4.50 (leeggoed) = €28; Flesjes met kroonkurk.</li>
<li>50CL: Kostprijs per bak: €25.44 + €4.50 (leeggoed) = €30; Flesjes met schroefdop.</li>
</ul>
<h2>Genoeg open orders om een bestelling te kunnen plaatsen?</h2>
{% if sum > 200 %}
Ja
{% else %}
Nee
{% endif %}
{% if sum > 0 %}
<p>Er staan orders open met een totale waarde van €{{ sum }}.</p>
{% else %}
<p>Er staan geen orders open.</p>
{% endif %}
{% endblock %}

View file

@ -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()">
</span>
<span>x</span>
<span class="unit_price">€25</span>
<span class="unit_price">€28</span>
</div>
<div class="rightcell price">
<span class="bold equals">=</span>

View file

@ -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/<int:order_id>", views.remove_order, name="remove_order"),
path("admin/", admin.site.urls),
path("login/zeus/", include("oauth.urls")),

View file

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

View file

@ -33,6 +33,11 @@
</span>
</li>
{% if user.is_staff or user.is_superuser %}
<li>
<a href="{% url 'manage' %}">
Manage
</a>
</li>
<li>
<a href="{% url 'admin:index' %}">
Admininterface