Add cancel and proforma buttons to review and pay template.
This commit is contained in:
parent
3ba33649cb
commit
fa855fb69e
|
@ -78,6 +78,19 @@
|
||||||
<div class="alert alert-info">{{ order.invoice_address|linebreaks }}</div>
|
<div class="alert alert-info">{{ order.invoice_address|linebreaks }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if not order.paid and order.open is None %}
|
||||||
|
<form action="{% url "shop:order_detail" pk=order.pk %}" method="POST">
|
||||||
|
{% csrf_token %}
|
||||||
|
{% bootstrap_button "Cancel order" button_type="submit" button_class="btn-danger btn-lg" name="cancel_order" icon="remove" %}
|
||||||
|
|
||||||
|
{% if order.pdf %}
|
||||||
|
{% url 'shop:download_invoice' pk=order.pk as invoice_download_url %}
|
||||||
|
{% bootstrap_button "Proforma Invoice PDF" icon="save-file" href=invoice_download_url button_class="btn-primary btn-lg pull-right" %}
|
||||||
|
{% endif %}
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -275,14 +275,6 @@ class OrderDetailView(
|
||||||
template_name = "order_detail.html"
|
template_name = "order_detail.html"
|
||||||
context_object_name = "order"
|
context_object_name = "order"
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
|
||||||
order = self.get_object()
|
|
||||||
if order.open is None and not order.paid:
|
|
||||||
return HttpResponseRedirect(
|
|
||||||
reverse("shop:order_review_and_pay", kwargs={"pk": order.pk})
|
|
||||||
)
|
|
||||||
return super().dispatch(request, *args, **kwargs)
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
if "order_product_formset" not in kwargs:
|
if "order_product_formset" not in kwargs:
|
||||||
kwargs["order_product_formset"] = OrderProductRelationFormSet(
|
kwargs["order_product_formset"] = OrderProductRelationFormSet(
|
||||||
|
@ -291,6 +283,14 @@ class OrderDetailView(
|
||||||
|
|
||||||
return super().get_context_data(**kwargs)
|
return super().get_context_data(**kwargs)
|
||||||
|
|
||||||
|
def get(self, request, *args, **kwargs):
|
||||||
|
order = self.get_object()
|
||||||
|
if order.open is None and not order.paid:
|
||||||
|
return HttpResponseRedirect(
|
||||||
|
reverse("shop:order_review_and_pay", kwargs={"pk": order.pk})
|
||||||
|
)
|
||||||
|
return super().get(request, *args, **kwargs)
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
self.object = self.get_object()
|
self.object = self.get_object()
|
||||||
order = self.object
|
order = self.object
|
||||||
|
@ -393,10 +393,7 @@ class OrderReviewAndPayView(
|
||||||
|
|
||||||
|
|
||||||
class DownloadInvoiceView(
|
class DownloadInvoiceView(
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin, EnsureUserOwnsOrderMixin, SingleObjectMixin, View
|
||||||
EnsureUserOwnsOrderMixin,
|
|
||||||
SingleObjectMixin,
|
|
||||||
View,
|
|
||||||
):
|
):
|
||||||
model = Order
|
model = Order
|
||||||
|
|
||||||
|
@ -417,9 +414,7 @@ class DownloadInvoiceView(
|
||||||
reverse_lazy("shop:order_detail", kwargs={"pk": self.get_object().pk})
|
reverse_lazy("shop:order_detail", kwargs={"pk": self.get_object().pk})
|
||||||
)
|
)
|
||||||
response = HttpResponse(content_type="application/pdf")
|
response = HttpResponse(content_type="application/pdf")
|
||||||
response["Content-Disposition"] = (
|
response["Content-Disposition"] = 'attachment; filename="%s"' % pdfobj.filename
|
||||||
'attachment; filename="%s"' % pdfobj.filename
|
|
||||||
)
|
|
||||||
response.write(pdfobj.pdf.read())
|
response.write(pdfobj.pdf.read())
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue