Add state to order, more info in overview
This commit is contained in:
parent
fbe577ddda
commit
654ff5814f
6 changed files with 47 additions and 5 deletions
12
mordor/admin.py
Normal file
12
mordor/admin.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
|
||||||
|
from django.contrib import admin
|
||||||
|
from mordor.models import Order
|
||||||
|
|
||||||
|
|
||||||
|
class OrderAdmin(admin.ModelAdmin):
|
||||||
|
model = Order
|
||||||
|
|
||||||
|
|
||||||
|
admin.site.register(Order, OrderAdmin)
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 3.2 on 2021-05-17 18:41
|
# Generated by Django 3.2 on 2021-05-17 19:31
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
@ -22,6 +22,8 @@ class Migration(migrations.Migration):
|
||||||
('updated_at', models.DateTimeField(auto_now=True)),
|
('updated_at', models.DateTimeField(auto_now=True)),
|
||||||
('amount_33', models.IntegerField(blank=True, default=0)),
|
('amount_33', models.IntegerField(blank=True, default=0)),
|
||||||
('amount_50', models.IntegerField(blank=True, default=0)),
|
('amount_50', models.IntegerField(blank=True, default=0)),
|
||||||
|
('state', models.IntegerField(choices=[(0, 'open'), (1, 'besteld'), (2, 'geleverd')], default=0)),
|
||||||
|
('paid', models.BooleanField(default=False)),
|
||||||
('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
|
('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
|
|
|
@ -11,9 +11,17 @@ class TimeStampMixin(models.Model):
|
||||||
|
|
||||||
|
|
||||||
class Order(TimeStampMixin):
|
class Order(TimeStampMixin):
|
||||||
|
OPEN, ORDERED, DELIVERED = range(3)
|
||||||
|
ORDER_STATES = {OPEN: "open", ORDERED: "besteld", DELIVERED: "geleverd"}
|
||||||
|
|
||||||
amount_33 = models.IntegerField(default=0, blank=True)
|
amount_33 = models.IntegerField(default=0, blank=True)
|
||||||
amount_50 = models.IntegerField(default=0, blank=True)
|
amount_50 = models.IntegerField(default=0, blank=True)
|
||||||
user = models.ForeignKey(CustomUser, null=True, on_delete=models.SET_NULL)
|
user = models.ForeignKey(CustomUser, null=True, on_delete=models.SET_NULL)
|
||||||
|
state = models.IntegerField(choices=ORDER_STATES.items(), default=OPEN)
|
||||||
|
paid = models.BooleanField(default=False)
|
||||||
|
|
||||||
|
def state_str(self):
|
||||||
|
return self.ORDER_STATES[self.state]
|
||||||
|
|
||||||
def price_33(self):
|
def price_33(self):
|
||||||
return self.amount_33 * 25
|
return self.amount_33 * 25
|
||||||
|
@ -31,4 +39,4 @@ class Order(TimeStampMixin):
|
||||||
self.amount_50 = 0
|
self.amount_50 = 0
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"Order {self.amount_33}x33cl, {self.amount_50}x50cl"
|
return f"Order {self.amount_33}x33cl, {self.amount_50}x50cl for {self.user.username} [{self.state_str()}]"
|
||||||
|
|
|
@ -5,6 +5,12 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<main class="shop">
|
<main class="shop">
|
||||||
{% if orders %}
|
{% if orders %}
|
||||||
|
<b>Bestel datum</b>
|
||||||
|
<b>Aantal</b>
|
||||||
|
<b>Bedrag</b>
|
||||||
|
<b>Status</b>
|
||||||
|
<b>Betaald</b>
|
||||||
|
<span></span>
|
||||||
{% for order in orders %}
|
{% for order in orders %}
|
||||||
<div class="leftcell">
|
<div class="leftcell">
|
||||||
{{ order.created_at.date }}
|
{{ order.created_at.date }}
|
||||||
|
@ -14,7 +20,18 @@
|
||||||
<div>{{ order.amount_50 }}x 50cl = €{{ order.price_50 }}</div>
|
<div>{{ order.amount_50 }}x 50cl = €{{ order.price_50 }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="midcell">
|
<div class="midcell">
|
||||||
€ {{ order.total_price }}</span></div>
|
€ {{ order.total_price }}</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{{ order.state_str }}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{% if order.paid %}
|
||||||
|
✓
|
||||||
|
{% else %}
|
||||||
|
✗
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
<div class="rightcell">
|
<div class="rightcell">
|
||||||
<form action="{% url 'remove_order' order.id %}" method="post">
|
<form action="{% url 'remove_order' order.id %}" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
|
@ -67,4 +67,7 @@
|
||||||
<span id="sum_50">0</span>
|
<span id="sum_50">0</span>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<div>
|
||||||
|
<p>Bakken met telkens 20 flesjes</p>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -91,8 +91,8 @@ button {
|
||||||
margin: 3em auto 0;
|
margin: 3em auto 0;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
display: grid;
|
display: grid;
|
||||||
max-width: 30em;
|
max-width: 40em;
|
||||||
grid-template-columns: auto 30% 20% auto;
|
grid-template-columns: auto 30% 20% 20% 10% auto;
|
||||||
row-gap: 2em;
|
row-gap: 2em;
|
||||||
font-size: 125%;
|
font-size: 125%;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue