working on shop
This commit is contained in:
parent
57e120c45f
commit
b3f6131be4
shop
|
@ -8,12 +8,7 @@ from django.utils import timezone
|
|||
from django.core.urlresolvers import reverse_lazy
|
||||
from bornhack.utils import CreatedUpdatedModel, UUIDModel
|
||||
from .managers import ProductQuerySet
|
||||
|
||||
import hashlib
|
||||
import io
|
||||
import base64
|
||||
|
||||
import qrcode
|
||||
import hashlib, io, base64, qrcode
|
||||
|
||||
|
||||
class Order(CreatedUpdatedModel):
|
||||
|
@ -109,7 +104,7 @@ class Order(CreatedUpdatedModel):
|
|||
|
||||
@property
|
||||
def description(self):
|
||||
return "BornHack 2016 order #%s" % self.pk
|
||||
return "BornHack %s order #%s" % (self.camp.start.year, self.pk)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return str(reverse_lazy('shop:order_detail', kwargs={'pk': self.pk}))
|
||||
|
@ -128,6 +123,36 @@ class Order(CreatedUpdatedModel):
|
|||
ticket.save()
|
||||
self.save()
|
||||
|
||||
def is_not_handed_out(self):
|
||||
if self.orderproductrelation_set.filter(handed_out=True).count() == 0:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def is_partially_handed_out(self):
|
||||
if self.orderproductrelation_set.filter(handed_out=True).count() != 0 and self.orderproductrelation_set.filter(handed_out=False).count() != 0:
|
||||
# some products are handed out, others are not
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def is_fully_handed_out(self):
|
||||
if self.orderproductrelation_set.filter(handed_out=False).count() == 0:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
@property
|
||||
def handed_out_status(self):
|
||||
if self.is_not_handed_out():
|
||||
return "no"
|
||||
elif self.is_partially_handed_out():
|
||||
return "partially"
|
||||
elif self.is_fully_handed_out():
|
||||
return "fully"
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
class ProductCategory(CreatedUpdatedModel, UUIDModel):
|
||||
class Meta:
|
||||
|
|
|
@ -15,16 +15,16 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
{% for order in orders %}
|
||||
<tr {% if order.finalized and order.paid %}style="color: lightgreen"{% endif %}>
|
||||
<tr {% if not order.open and order.paid %}style="color: lightgrey"{% endif %}>
|
||||
<td>{{ order.id }}</td>
|
||||
<td>{{ order.finalized }}</td>
|
||||
<td>{{ order.open }}</td>
|
||||
<td>{{ order.paid }}</td>
|
||||
<td>?</td>
|
||||
<td>{{ order.handed_out_status }}</td>
|
||||
<td>
|
||||
{% if order.finalized and not order.paid %}
|
||||
{% if not order.open and not order.paid %}
|
||||
{% url 'shop:order_detail' pk=order.pk as order_detail_url %}
|
||||
{% url 'shop:order_cancel' pk=order.pk as order_cancel_url %}
|
||||
{% bootstrap_button "Pay order" href=order_detail_url button_class="btn-primary" %}
|
||||
{% bootstrap_button "Order details" href=order_detail_url button_class="btn-primary" %}
|
||||
{% bootstrap_button "Cancel order" href=order_cancel_url button_class="btn-primary" %}
|
||||
{% endif %}
|
||||
</td>
|
||||
|
|
Loading…
Reference in a new issue