From 95e04b3741b6fca840eaad4a1f4b4b7368282b5a Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 8 Aug 2019 21:05:55 +0200 Subject: [PATCH 1/2] ShopTicket: use @property instead of get_orp() method This looks much more natural when being used from inside templates. --- src/profiles/templates/tickets/ticket_list.html | 2 +- src/tickets/models.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/profiles/templates/tickets/ticket_list.html b/src/profiles/templates/tickets/ticket_list.html index 2dc6d6b4..807be910 100644 --- a/src/profiles/templates/tickets/ticket_list.html +++ b/src/profiles/templates/tickets/ticket_list.html @@ -40,7 +40,7 @@ {{ ticket.product.name }} - {% if ticket.ticket_type.single_ticket_per_product %}{{ ticket.get_orp.quantity }} × {% endif %} + {% if ticket.ticket_type.single_ticket_per_product %}{{ ticket.orp.quantity }} × {% endif %} {{ ticket.product.price|currency }} {% if ticket.used %} diff --git a/src/tickets/models.py b/src/tickets/models.py index d72d5662..5580cda3 100644 --- a/src/tickets/models.py +++ b/src/tickets/models.py @@ -93,8 +93,7 @@ class BaseTicket(CampRelatedModel, UUIDModel): formatdict = {"ticket": self} if self.ticket_type.single_ticket_per_product and self.shortname == "shop": - orp = self.get_orp() - formatdict["quantity"] = orp.quantity + formatdict["quantity"] = self.orp.quantity return generate_pdf_letter( filename="{}_ticket_{}.pdf".format(self.shortname, self.pk), @@ -165,5 +164,6 @@ class ShopTicket(BaseTicket): def shortname(self): return "shop" - def get_orp(self): + @property + def orp(self): return OrderProductRelation.objects.get(product=self.product, order=self.order) From aa252c3d1149826528a4297c4695ec8e8ecf43cc Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 8 Aug 2019 21:07:03 +0200 Subject: [PATCH 2/2] info_desk/scan.html: show quantity if it's a ShopTicket and single_ticket_per_product is set fixes #377. --- src/backoffice/templates/info_desk/scan.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/backoffice/templates/info_desk/scan.html b/src/backoffice/templates/info_desk/scan.html index 351a8ee2..7a15b2dc 100644 --- a/src/backoffice/templates/info_desk/scan.html +++ b/src/backoffice/templates/info_desk/scan.html @@ -56,6 +56,13 @@ Product: {{ ticket.product }} + {% if ticket.ticket_type.single_ticket_per_product and ticket.shortname == "shop" %} + + + Quantity: + + {{ ticket.orp.quantity }} + {% endif %} Order: