From fc87a13c058c1fb0ef26dd6e8bc62c6732df3e65 Mon Sep 17 00:00:00 2001 From: Stephan Telling Date: Thu, 17 Aug 2017 21:17:36 +0200 Subject: [PATCH] update tickettype with camp, remove camp from baseticket minor updates to template and str method of TicketType --- .../migrations/0002_auto_20170817_1937.py | 26 +++++++++++++++++++ .../migrations/0003_auto_20170817_1938.py | 21 +++++++++++++++ src/tickets/models.py | 4 +-- src/tickets/templates/pdf/ticket.html | 4 +-- 4 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 src/tickets/migrations/0002_auto_20170817_1937.py create mode 100644 src/tickets/migrations/0003_auto_20170817_1938.py diff --git a/src/tickets/migrations/0002_auto_20170817_1937.py b/src/tickets/migrations/0002_auto_20170817_1937.py new file mode 100644 index 00000000..4432e465 --- /dev/null +++ b/src/tickets/migrations/0002_auto_20170817_1937.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-08-17 17:37 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('camps', '0022_camp_colour'), + ('tickets', '0001_initial'), + ] + + operations = [ + migrations.RemoveField( + model_name='baseticket', + name='camp', + ), + migrations.AddField( + model_name='tickettype', + name='camp', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='camps.Camp'), + ), + ] diff --git a/src/tickets/migrations/0003_auto_20170817_1938.py b/src/tickets/migrations/0003_auto_20170817_1938.py new file mode 100644 index 00000000..0156481e --- /dev/null +++ b/src/tickets/migrations/0003_auto_20170817_1938.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-08-17 17:38 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('tickets', '0002_auto_20170817_1937'), + ] + + operations = [ + migrations.AlterField( + model_name='tickettype', + name='camp', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='camps.Camp'), + ), + ] diff --git a/src/tickets/models.py b/src/tickets/models.py index 1f59a4cb..63206888 100644 --- a/src/tickets/models.py +++ b/src/tickets/models.py @@ -21,15 +21,15 @@ logger = logging.getLogger("bornhack.%s" % __name__) # TicketType can be full week, one day. etc. class TicketType(CreatedUpdatedModel, UUIDModel): name = models.TextField() + camp = models.ForeignKey('camps.Camp') def __str__(self): - return '{}'.format(self.name) + return '{} ({})'.format(self.name, self.camp.title) class BaseTicket(models.Model): qrcode_base64 = models.TextField(null=True, blank=True) ticket_type = models.ForeignKey('TicketType') - camp = models.ForeignKey('camps.Camp') def save(self, **kwargs): super(BaseTicket, self).save(**kwargs) diff --git a/src/tickets/templates/pdf/ticket.html b/src/tickets/templates/pdf/ticket.html index 556c7d4a..dc9f10e7 100644 --- a/src/tickets/templates/pdf/ticket.html +++ b/src/tickets/templates/pdf/ticket.html @@ -12,8 +12,8 @@
-

{{ ticket.camp.title }} Ticket

-

Type: {{ ticket.ticket_type }}

+

{{ ticket.ticket_type.camp.title }} Ticket

+

Type: {{ ticket.ticket_type.name }}

{% if ticket.name %}

Participant: {{ ticket.name }}