add village gear sections to backoffice
This commit is contained in:
parent
763f38f70a
commit
458ce45198
|
@ -42,6 +42,14 @@
|
|||
<h4 class="list-group-item-heading">Merchandise To Order</h4>
|
||||
<p class="list-group-item-text">Use this view to generate a list of merchandise that needs to be ordered</p>
|
||||
</a>
|
||||
<a href="{% url 'backoffice:village_orders' camp_slug=camp.slug %}" class="list-group-item">
|
||||
<h4 class="list-group-item-heading">Village Orders</h4>
|
||||
<p class="list-group-item-text">Use this view to look at Village category OrderProductRelations</p>
|
||||
</a>
|
||||
<a href="{% url 'backoffice:village_to_order' camp_slug=camp.slug %}" class="list-group-item">
|
||||
<h4 class="list-group-item-heading">Village Gear To Order</h4>
|
||||
<p class="list-group-item-text">Use this view to generate a list of village gear that needs to be ordered</p>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
51
src/backoffice/templates/orders_village.html
Normal file
51
src/backoffice/templates/orders_village.html
Normal file
|
@ -0,0 +1,51 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load commonmark %}
|
||||
{% load static from staticfiles %}
|
||||
{% load imageutils %}
|
||||
{% block extra_head %}
|
||||
<script src="{% static "js/jquery.dataTables.min.js" %}"></script>
|
||||
<link rel="stylesheet" href="{% static 'css/jquery.dataTables.min.css' %}">
|
||||
{% endblock extra_head %}
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<h2>Village Orders</h2>
|
||||
<div class="lead">
|
||||
Use this view to look at village orders.</div>
|
||||
<div>
|
||||
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).
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Order</th>
|
||||
<th>User</th>
|
||||
<th>Email</th>
|
||||
<th>OPR Id</th>
|
||||
<th>Product</th>
|
||||
<th>Quantity</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for productrel in orderproductrelation_list %}
|
||||
<tr>
|
||||
<td><a href="/admin/shop/order/{{ productrel.order.id }}/change/">Order #{{ productrel.order.id }}</a></td>
|
||||
<td>{{ productrel.order.user }}</td>
|
||||
<td>{{ productrel.order.user.email }}</td>
|
||||
<td>{{ productrel.id }}</td>
|
||||
<td>{{ productrel.product.name }}</td>
|
||||
<td>{{ productrel.quantity }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$('.table').DataTable();
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock content %}
|
44
src/backoffice/templates/village_to_order.html
Normal file
44
src/backoffice/templates/village_to_order.html
Normal file
|
@ -0,0 +1,44 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load commonmark %}
|
||||
{% load static from staticfiles %}
|
||||
{% load imageutils %}
|
||||
{% block extra_head %}
|
||||
<script src="{% static "js/jquery.dataTables.min.js" %}"></script>
|
||||
<link rel="stylesheet" href="{% static 'css/jquery.dataTables.min.css' %}">
|
||||
{% endblock extra_head %}
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<h2>Village Gear To Order</h2>
|
||||
<div class="lead">
|
||||
This is a list of village gear to order from our supplier
|
||||
</div>
|
||||
<div>
|
||||
This table shows all different village stuff that needs to be ordered
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<th>Quantity</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for key, val in village.items %}
|
||||
<tr>
|
||||
<td>{{ key }}</td>
|
||||
<td>{{ val }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$('.table').DataTable();
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock content %}
|
|
@ -17,5 +17,7 @@ urlpatterns = [
|
|||
path('speakers/<uuid:pk>/', SpeakerProposalManageView.as_view(), name='speakerproposal_manage'),
|
||||
path('events/<uuid:pk>/', 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'),
|
||||
]
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue