update tickettype with camp, remove camp from baseticket

minor updates to template and str method of TicketType
This commit is contained in:
Stephan Telling 2017-08-17 21:17:36 +02:00
parent 85a1db6704
commit fc87a13c05
No known key found for this signature in database
GPG key ID: D4892289F36ADA9B
4 changed files with 51 additions and 4 deletions

View file

@ -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'),
),
]

View file

@ -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'),
),
]

View file

@ -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)

View file

@ -12,8 +12,8 @@
</tr>
</table>
<br>
<h2>{{ ticket.camp.title }} Ticket</h2>
<h3>Type: {{ ticket.ticket_type }}</h3>
<h2>{{ ticket.ticket_type.camp.title }} Ticket</h2>
<h3>Type: {{ ticket.ticket_type.name }}</h3>
{% if ticket.name %}
<h3>Participant: {{ ticket.name }}</h3>