diff --git a/src/backoffice/templates/index.html b/src/backoffice/templates/index.html index c121fe43..c8b94755 100644 --- a/src/backoffice/templates/index.html +++ b/src/backoffice/templates/index.html @@ -42,6 +42,14 @@

Merchandise To Order

Use this view to generate a list of merchandise that needs to be ordered

+ +

Village Orders

+

Use this view to look at Village category OrderProductRelations

+
+ +

Village Gear To Order

+

Use this view to generate a list of village gear that needs to be ordered

+
diff --git a/src/backoffice/templates/orders_village.html b/src/backoffice/templates/orders_village.html new file mode 100644 index 00000000..93ccbd3c --- /dev/null +++ b/src/backoffice/templates/orders_village.html @@ -0,0 +1,51 @@ +{% extends 'base.html' %} +{% load commonmark %} +{% load static from staticfiles %} +{% load imageutils %} +{% block extra_head %} + + +{% endblock extra_head %} +{% block content %} +
+

Village Orders

+
+ Use this view to look at village orders.
+
+ This table shows all OrderProductRelations which are in the Village category (not including handed out, unpaid, cancelled and refunded orders). The table is initally sorted by order ID but the sorting can be changed by clicking the column headlines (if javascript is enabled). +
+
+
+
+ + + + + + + + + + + + + {% for productrel in orderproductrelation_list %} + + + + + + + + + {% endfor %} + +
OrderUserEmailOPR IdProductQuantity
Order #{{ productrel.order.id }}{{ productrel.order.user }}{{ productrel.order.user.email }}{{ productrel.id }}{{ productrel.product.name }}{{ productrel.quantity }}
+
+ + +{% endblock content %} diff --git a/src/backoffice/templates/village_to_order.html b/src/backoffice/templates/village_to_order.html new file mode 100644 index 00000000..ae3501c0 --- /dev/null +++ b/src/backoffice/templates/village_to_order.html @@ -0,0 +1,44 @@ +{% extends 'base.html' %} +{% load commonmark %} +{% load static from staticfiles %} +{% load imageutils %} +{% block extra_head %} + + +{% endblock extra_head %} +{% block content %} +
+

Village Gear To Order

+
+ This is a list of village gear to order from our supplier +
+
+ This table shows all different village stuff that needs to be ordered +
+
+
+
+ + + + + + + + + {% for key, val in village.items %} + + + + + {% endfor %} + +
TypeQuantity
{{ key }}{{ val }}
+
+ + +{% endblock content %} diff --git a/src/backoffice/urls.py b/src/backoffice/urls.py index f48cced5..df740b38 100644 --- a/src/backoffice/urls.py +++ b/src/backoffice/urls.py @@ -17,5 +17,7 @@ urlpatterns = [ path('speakers//', SpeakerProposalManageView.as_view(), name='speakerproposal_manage'), path('events//', EventProposalManageView.as_view(), name='eventproposal_manage'), ])), + path('village_orders/', VillageOrdersView.as_view(), name='village_orders'), + path('village_to_order/', VillageToOrderView.as_view(), name='village_to_order'), ] diff --git a/src/backoffice/views.py b/src/backoffice/views.py index 06af7073..d75868f7 100644 --- a/src/backoffice/views.py +++ b/src/backoffice/views.py @@ -168,3 +168,50 @@ class MerchandiseToOrderView(BackofficeViewMixin, TemplateView): context = super().get_context_data(**kwargs) context['merchandise'] = merchandise_orders return context + + +class VillageOrdersView(BackofficeViewMixin, ListView): + template_name = "orders_village.html" + + def get_queryset(self, **kwargs): + camp_prefix = 'BornHack {}'.format(timezone.now().year) + + return OrderProductRelation.objects.filter( + handed_out=False, + order__paid=True, + order__refunded=False, + order__cancelled=False, + product__category__name='Villages', + ).filter( + product__name__startswith=camp_prefix + ).order_by('order') + + +class VillageToOrderView(BackofficeViewMixin, TemplateView): + template_name = "village_to_order.html" + + def get_context_data(self, **kwargs): + camp_prefix = 'BornHack {}'.format(timezone.now().year) + + order_relations = OrderProductRelation.objects.filter( + handed_out=False, + order__paid=True, + order__refunded=False, + order__cancelled=False, + product__category__name='Villages', + ).filter( + product__name__startswith=camp_prefix + ) + + village_orders = {} + for relation in order_relations: + try: + quantity = village_orders[relation.product.name] + relation.quantity + village_orders[relation.product.name] = quantity + except KeyError: + village_orders[relation.product.name] = relation.quantity + + context = super().get_context_data(**kwargs) + context['village'] = village_orders + return context +