Search for orders and mark them as paid.
This commit is contained in:
parent
59dec88c04
commit
470115a0d9
|
@ -27,7 +27,6 @@
|
|||
|
||||
{% if ticket %}
|
||||
|
||||
|
||||
<br />
|
||||
|
||||
<table class="table">
|
||||
|
@ -110,7 +109,61 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
<hr />
|
||||
|
||||
<form method="POST"
|
||||
class="form-inline">
|
||||
{% csrf_token %}
|
||||
|
||||
<input type="text" class="form-control input-lg" name="find_order_id" />
|
||||
|
||||
<button type="submit" class="btn btn-lg btn-primary">
|
||||
Find an order
|
||||
</button>
|
||||
</form>
|
||||
|
||||
{% if view.order_search %}
|
||||
|
||||
{% if order %}
|
||||
|
||||
<h3>Order #{{ order.id }}</h3>
|
||||
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td>
|
||||
<strong>Total</strong>
|
||||
<td>
|
||||
{{ order.total }} DKK
|
||||
<tr>
|
||||
<td>
|
||||
<strong>Paid?</strong>
|
||||
<td>
|
||||
{{ order.paid }}
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<strong>Payment type</strong>
|
||||
<td>
|
||||
{{ order.get_payment_method_display }}
|
||||
|
||||
</table>
|
||||
|
||||
{% if not order.paid and order.payment_method == order.CASH %}
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
<button type="submit" name="mark_as_paid" value="{{ order.id }}" class="btn btn-primary">Mark as paid!</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
|
||||
Order not found...
|
||||
|
||||
{% endif %}
|
||||
|
||||
<a href="" class="btn btn-primary">Clear</a>
|
||||
|
||||
{% endif %}
|
||||
|
||||
<script src="{% static 'js/ticket_scan.js' %}"></script>
|
||||
|
|
@ -7,9 +7,11 @@ app_name = "backoffice"
|
|||
urlpatterns = [
|
||||
path("", BackofficeIndexView.as_view(), name="index"),
|
||||
# infodesk
|
||||
path(
|
||||
"tickets/", include([path("", ScanTicketsView.as_view(), name="scan_tickets")])
|
||||
),
|
||||
path("infodesk/", include(
|
||||
[
|
||||
path("", ScanTicketsView.as_view(), name="scan_tickets"),
|
||||
]
|
||||
)),
|
||||
path("product_handout/", ProductHandoutView.as_view(), name="product_handout"),
|
||||
path("badge_handout/", BadgeHandoutView.as_view(), name="badge_handout"),
|
||||
path("ticket_checkin/", TicketCheckinView.as_view(), name="ticket_checkin"),
|
||||
|
|
|
@ -2,7 +2,7 @@ import logging, os
|
|||
from itertools import chain
|
||||
|
||||
import qrcode
|
||||
from django.contrib.auth.mixins import PermissionRequiredMixin, UserPassesTestMixin
|
||||
from django.contrib.auth.mixins import PermissionRequiredMixin, UserPassesTestMixin, LoginRequiredMixin
|
||||
from django.contrib.auth.models import User
|
||||
from django.views.generic import TemplateView, ListView, DetailView
|
||||
from django.views.generic.edit import CreateView, UpdateView, DeleteView
|
||||
|
@ -565,10 +565,12 @@ def _ticket_getter_by_pk(pk):
|
|||
pass
|
||||
|
||||
|
||||
class ScanTicketsView(TemplateView):
|
||||
template_name = "tickets/scan.html"
|
||||
class ScanTicketsView(LoginRequiredMixin, InfoTeamPermissionMixin, CampViewMixin,TemplateView):
|
||||
template_name = "info_desk/scan.html"
|
||||
|
||||
ticket = None
|
||||
order = None
|
||||
order_search = False
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
@ -589,6 +591,9 @@ class ScanTicketsView(TemplateView):
|
|||
else:
|
||||
messages.warning(self.request, "Ticket not found!")
|
||||
|
||||
elif self.order_search:
|
||||
context['order'] = self.order
|
||||
|
||||
return context
|
||||
|
||||
def post(self, request, **kwargs):
|
||||
|
@ -596,6 +601,15 @@ class ScanTicketsView(TemplateView):
|
|||
self.ticket = self.check_in_ticket(request)
|
||||
elif 'badge_ticket_id' in request.POST:
|
||||
self.ticket = self.hand_out_badge(request)
|
||||
elif 'find_order_id' in request.POST:
|
||||
self.order_search = True
|
||||
try:
|
||||
order_id = self.request.POST.get('find_order_id')
|
||||
self.order = Order.objects.get(id=order_id)
|
||||
except Order.DoesNotExist:
|
||||
pass
|
||||
elif 'mark_as_paid' in request.POST:
|
||||
self.mark_order_as_paid(request)
|
||||
|
||||
return super().get(request, **kwargs)
|
||||
|
||||
|
@ -614,3 +628,8 @@ class ScanTicketsView(TemplateView):
|
|||
ticket_to_handout_badge_for.save()
|
||||
messages.info(request, "Badge marked as handed out!")
|
||||
return ticket_to_handout_badge_for
|
||||
|
||||
def mark_order_as_paid(self, request):
|
||||
order = Order.objects.get(id=request.POST.get('mark_as_paid'))
|
||||
order.mark_as_paid()
|
||||
messages.success(request, "Order #{} has been marked as paid!".format(order.id))
|
||||
|
|
Loading…
Reference in a new issue