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 }}