Fix some stuff for new tickets. Also fix bootstrap-dev script.

This commit is contained in:
Víðir Valberg Guðmundsson 2019-07-30 23:38:03 +02:00
parent 7dc82ee4ee
commit f1ce253d4a
4 changed files with 23 additions and 4 deletions

View file

@ -40,6 +40,7 @@
<td> <td>
{{ ticket.product.name }} {{ ticket.product.name }}
<td> <td>
{% if ticket.ticket_type.single_ticket_per_product %}{{ ticket.get_orp.quantity }} &times; {% endif %}
{{ ticket.product.price|currency }} {{ ticket.product.price|currency }}
<td> <td>
{% if ticket.used %} {% if ticket.used %}

View file

@ -5,6 +5,8 @@ import qrcode
from django.conf import settings from django.conf import settings
from django.urls import reverse_lazy from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from shop.models import OrderProductRelation
from utils.models import UUIDModel, CampRelatedModel from utils.models import UUIDModel, CampRelatedModel
from utils.pdf import generate_pdf_letter from utils.pdf import generate_pdf_letter
from django.db import models from django.db import models
@ -88,9 +90,15 @@ class BaseTicket(CampRelatedModel, UUIDModel):
) )
def generate_pdf(self): def generate_pdf(self):
formatdict = {"ticket": self}
if self.ticket_type.single_ticket_per_product and self.shortname == "shop":
orp = self.get_orp()
formatdict["quantity"] = orp.quantity
return generate_pdf_letter( return generate_pdf_letter(
filename="{}_ticket_{}.pdf".format(self.shortname, self.pk), filename="{}_ticket_{}.pdf".format(self.shortname, self.pk),
formatdict={"ticket": self}, formatdict=formatdict,
template="pdf/ticket.html", template="pdf/ticket.html",
) )
@ -156,3 +164,6 @@ class ShopTicket(BaseTicket):
@property @property
def shortname(self): def shortname(self):
return "shop" return "shop"
def get_orp(self):
return OrderProductRelation.objects.get(product=self.product, order=self.order)

View file

@ -13,6 +13,10 @@
<br> <br>
<h2>{{ ticket.ticket_type.camp.title }} Ticket</h2> <h2>{{ ticket.ticket_type.camp.title }} Ticket</h2>
<h3>Type: {{ ticket.ticket_type.name }}</h3> <h3>Type: {{ ticket.ticket_type.name }}</h3>
<h3>Product: {{ ticket.product.name }}</h3>
{% if quantity %}
<h3>Quantity: {{ quantity }}</h3>
{% endif %}
{% if ticket.name %} {% if ticket.name %}
<h3>Participant: {{ ticket.name }}</h3> <h3>Participant: {{ ticket.name }}</h3>

View file

@ -1399,7 +1399,8 @@ class Command(BaseCommand):
camp=camp, camp=camp,
user=users[1], user=users[1],
seats=2, seats=2,
location="From Copenhagen", from_location="Copenhagen",
to_location="BornHack",
when=timezone.datetime(year, 8, 27, 12, 0, tzinfo=timezone.utc), when=timezone.datetime(year, 8, 27, 12, 0, tzinfo=timezone.utc),
description="I have space for two people and a little bit of luggage", description="I have space for two people and a little bit of luggage",
) )
@ -1407,7 +1408,8 @@ class Command(BaseCommand):
camp=camp, camp=camp,
user=users[1], user=users[1],
seats=2, seats=2,
location="To Copenhagen", from_location="BornHack",
to_location="Copenhagen",
when=timezone.datetime(year, 9, 4, 12, 0, tzinfo=timezone.utc), when=timezone.datetime(year, 9, 4, 12, 0, tzinfo=timezone.utc),
description="I have space for two people and a little bit of luggage", description="I have space for two people and a little bit of luggage",
) )
@ -1415,7 +1417,8 @@ class Command(BaseCommand):
camp=camp, camp=camp,
user=users[4], user=users[4],
seats=1, seats=1,
location="From Aarhus", from_location="Aarhus",
to_location="BornHack",
when=timezone.datetime(year, 8, 27, 12, 0, tzinfo=timezone.utc), when=timezone.datetime(year, 8, 27, 12, 0, tzinfo=timezone.utc),
description="I need a ride and have a large backpack", description="I need a ride and have a large backpack",
) )