Mark order as closed when marking as paid. Add button to mark as paid.
This commit is contained in:
parent
746da234db
commit
e4585c8f7e
|
@ -122,9 +122,9 @@ class Order(CreatedUpdatedModel):
|
||||||
|
|
||||||
def mark_as_paid(self):
|
def mark_as_paid(self):
|
||||||
self.paid = True
|
self.paid = True
|
||||||
|
self.open = None
|
||||||
for order_product in self.orderproductrelation_set.all():
|
for order_product in self.orderproductrelation_set.all():
|
||||||
category_pk = str(order_product.product.category.pk)
|
category_pk = str(order_product.product.category.pk)
|
||||||
print(order_product, category_pk, settings.TICKET_CATEGORY_ID)
|
|
||||||
if category_pk == settings.TICKET_CATEGORY_ID:
|
if category_pk == settings.TICKET_CATEGORY_ID:
|
||||||
for _ in range(0, order_product.quantity):
|
for _ in range(0, order_product.quantity):
|
||||||
ticket = Ticket(
|
ticket = Ticket(
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
{% url opts|admin_urlname:'history' original.pk|admin_urlquote as history_url %}
|
{% url opts|admin_urlname:'history' original.pk|admin_urlquote as history_url %}
|
||||||
<a href="{% add_preserved_filters history_url %}" class="historylink">{% trans "History" %}</a>
|
<a href="{% add_preserved_filters history_url %}" class="historylink">{% trans "History" %}</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% if not original.paid and original.open != None %}
|
||||||
|
<li>
|
||||||
|
<a href="{% url 'shop:mark_order_as_paid' original.pk|admin_urlquote %}">Mark as paid</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
{% if original.paid and original.invoice %}
|
{% if original.paid and original.invoice %}
|
||||||
<li>
|
<li>
|
||||||
{% url 'shop:download_invoice' original.pk|admin_urlquote as invoice_url %}
|
{% url 'shop:download_invoice' original.pk|admin_urlquote as invoice_url %}
|
||||||
|
|
|
@ -9,6 +9,7 @@ urlpatterns = [
|
||||||
url(r'orders/$', OrderListView.as_view(), name='order_list'),
|
url(r'orders/$', OrderListView.as_view(), name='order_list'),
|
||||||
url(r'orders/(?P<pk>[0-9]+)/$', OrderDetailView.as_view(), name='order_detail'),
|
url(r'orders/(?P<pk>[0-9]+)/$', OrderDetailView.as_view(), name='order_detail'),
|
||||||
url(r'orders/(?P<pk>[0-9]+)/invoice/$', DownloadInvoiceView.as_view(), name='download_invoice'),
|
url(r'orders/(?P<pk>[0-9]+)/invoice/$', DownloadInvoiceView.as_view(), name='download_invoice'),
|
||||||
|
url(r'orders/(?P<pk>[0-9]+)/mark_as_paid/$', OrderMarkAsPaidView.as_view(), name='mark_order_as_paid'),
|
||||||
|
|
||||||
#url(r'orders/(?P<pk>[0-9]+)/pay/creditcard/$', EpayFormView.as_view(), name='epay_form'),
|
#url(r'orders/(?P<pk>[0-9]+)/pay/creditcard/$', EpayFormView.as_view(), name='epay_form'),
|
||||||
#url(r'orders/(?P<pk>[0-9]+)/pay/creditcard/callback/$',EpayCallbackView.as_view(), name='epay_callback'),
|
#url(r'orders/(?P<pk>[0-9]+)/pay/creditcard/callback/$',EpayCallbackView.as_view(), name='epay_callback'),
|
||||||
|
|
|
@ -566,3 +566,20 @@ class TicketDetailView(LoginRequiredMixin, UpdateView, DetailView):
|
||||||
if ticket.order.user != request.user:
|
if ticket.order.user != request.user:
|
||||||
return Http404
|
return Http404
|
||||||
return super(TicketDetailView, self).dispatch(request, *args, **kwargs)
|
return super(TicketDetailView, self).dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class OrderMarkAsPaidView(LoginRequiredMixin, SingleObjectMixin, View):
|
||||||
|
|
||||||
|
model = Order
|
||||||
|
|
||||||
|
def get(self, request, *args, **kwargs):
|
||||||
|
if not request.user.is_staff:
|
||||||
|
messages.error(request, 'You do not have permissions to do that.')
|
||||||
|
return HttpResponseRedirect(reverse_lazy('shop:index'))
|
||||||
|
else:
|
||||||
|
messages.success(request, 'The order has been marked as paid.')
|
||||||
|
order = self.get_object()
|
||||||
|
order.mark_as_paid()
|
||||||
|
return HttpResponseRedirect(request.META.get('HTTP_REFERER'))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue