Add quick 'n dirty manage screen. Fix pricing
This commit is contained in:
parent
a67ad1da9e
commit
c3fb866c73
6 changed files with 50 additions and 3 deletions
|
@ -24,7 +24,7 @@ class Order(TimeStampMixin):
|
||||||
return self.ORDER_STATES[self.state]
|
return self.ORDER_STATES[self.state]
|
||||||
|
|
||||||
def price_33(self):
|
def price_33(self):
|
||||||
return self.amount_33 * 25
|
return self.amount_33 * 28
|
||||||
|
|
||||||
def price_50(self):
|
def price_50(self):
|
||||||
return self.amount_50 * 30
|
return self.amount_50 * 30
|
||||||
|
|
28
mordor/templates/mordor/manage.html
Normal file
28
mordor/templates/mordor/manage.html
Normal 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 %}
|
|
@ -11,7 +11,7 @@
|
||||||
let total_sum = 0
|
let total_sum = 0
|
||||||
|
|
||||||
function input_changed() {
|
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;
|
sum_50 = Number(document.getElementById(`amount_50`).value) * 30;
|
||||||
|
|
||||||
let total_field_33 = document.getElementById(`sum_33`);
|
let total_field_33 = document.getElementById(`sum_33`);
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
onblur="this.placeholder='0'" oninput="input_changed()">
|
onblur="this.placeholder='0'" oninput="input_changed()">
|
||||||
</span>
|
</span>
|
||||||
<span>x</span>
|
<span>x</span>
|
||||||
<span class="unit_price">€25</span>
|
<span class="unit_price">€28</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="rightcell price">
|
<div class="rightcell price">
|
||||||
<span class="bold equals">=</span>€
|
<span class="bold equals">=</span>€
|
||||||
|
|
|
@ -23,6 +23,7 @@ urlpatterns = [
|
||||||
path("", views.index, name="index"),
|
path("", views.index, name="index"),
|
||||||
path("winkel", views.winkel, name="winkel"),
|
path("winkel", views.winkel, name="winkel"),
|
||||||
path("orders", views.orders, name="orders"),
|
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("remove_order/<int:order_id>", views.remove_order, name="remove_order"),
|
||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
path("login/zeus/", include("oauth.urls")),
|
path("login/zeus/", include("oauth.urls")),
|
||||||
|
|
|
@ -44,3 +44,16 @@ def orders(req):
|
||||||
user_orders = Order.objects.filter(user=req.user)
|
user_orders = Order.objects.filter(user=req.user)
|
||||||
|
|
||||||
return render(req, "mordor/orders.html", {"orders": user_orders})
|
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"))
|
||||||
|
|
|
@ -33,6 +33,11 @@
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
{% if user.is_staff or user.is_superuser %}
|
{% if user.is_staff or user.is_superuser %}
|
||||||
|
<li>
|
||||||
|
<a href="{% url 'manage' %}">
|
||||||
|
Manage
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{% url 'admin:index' %}">
|
<a href="{% url 'admin:index' %}">
|
||||||
Admininterface
|
Admininterface
|
||||||
|
|
Loading…
Reference in a new issue