redo migrations for Tickets app again, fix BaseTicket to be abstract

This commit is contained in:
Thomas Steen Rasmussen 2017-08-19 22:22:54 +02:00
parent 410905f3ce
commit a07e74180e
4 changed files with 89 additions and 44 deletions

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-08-19 19:32
# Generated by Django 1.10.5 on 2017-08-19 20:21
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-08-19 19:32
# Generated by Django 1.10.5 on 2017-08-19 20:21
from __future__ import unicode_literals
from django.db import migrations, models
@ -12,20 +12,52 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
('shop', '0047_auto_20170522_1942'),
('sponsors', '0006_auto_20170715_1110'),
('camps', '0022_camp_colour'),
('sponsors', '0006_auto_20170715_1110'),
('shop', '0047_auto_20170522_1942'),
]
operations = [
migrations.CreateModel(
name='BaseTicket',
name='DiscountTicket',
fields=[
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('created', models.DateTimeField(auto_now_add=True)),
('updated', models.DateTimeField(auto_now=True)),
('qrcode_base64', models.TextField(blank=True, null=True)),
('checked_in', models.BooleanField(default=False)),
('price', models.IntegerField(help_text='Price of the discounted ticket (in DKK, including VAT).')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='ShopTicket',
fields=[
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('created', models.DateTimeField(auto_now_add=True)),
('updated', models.DateTimeField(auto_now=True)),
('qrcode_base64', models.TextField(blank=True, null=True)),
('checked_in', models.BooleanField(default=False)),
('name', models.CharField(blank=True, help_text='Name of the person this ticket belongs to. This can be different from the buying user.', max_length=100, null=True)),
('email', models.EmailField(blank=True, max_length=254, null=True)),
('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='shoptickets', to='shop.Order')),
('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='shop.Product')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='SponsorTicket',
fields=[
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('created', models.DateTimeField(auto_now_add=True)),
('updated', models.DateTimeField(auto_now=True)),
('qrcode_base64', models.TextField(blank=True, null=True)),
('checked_in', models.BooleanField(default=False)),
('sponsor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='sponsors.Sponsor')),
],
options={
'abstract': False,
@ -38,51 +70,25 @@ class Migration(migrations.Migration):
('created', models.DateTimeField(auto_now_add=True)),
('updated', models.DateTimeField(auto_now=True)),
('name', models.TextField()),
('camp', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='camps.Camp')),
('camp', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='camps.Camp')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='DiscountTicket',
fields=[
('baseticket_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='tickets.BaseTicket')),
('price', models.IntegerField(help_text='Price of the discounted ticket (in DKK, including VAT).')),
],
options={
'abstract': False,
},
bases=('tickets.baseticket',),
),
migrations.CreateModel(
name='ShopTicket',
fields=[
('baseticket_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='tickets.BaseTicket')),
('name', models.CharField(blank=True, help_text='Name of the person this ticket belongs to. This can be different from the buying user.', max_length=100, null=True)),
('email', models.EmailField(blank=True, max_length=254, null=True)),
('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='shoptickets', to='shop.Order')),
('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='shop.Product')),
],
options={
'abstract': False,
},
bases=('tickets.baseticket',),
),
migrations.CreateModel(
name='SponsorTicket',
fields=[
('baseticket_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='tickets.BaseTicket')),
('sponsor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='sponsors.Sponsor')),
],
options={
'abstract': False,
},
bases=('tickets.baseticket',),
),
migrations.AddField(
model_name='baseticket',
model_name='sponsorticket',
name='ticket_type',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tickets.TicketType'),
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='tickets.TicketType'),
),
migrations.AddField(
model_name='shopticket',
name='ticket_type',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='tickets.TicketType'),
),
migrations.AddField(
model_name='discountticket',
name='ticket_type',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='tickets.TicketType'),
),
]

View file

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-08-19 20:22
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('tickets', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='discountticket',
name='ticket_type',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tickets.TicketType'),
),
migrations.AlterField(
model_name='shopticket',
name='ticket_type',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tickets.TicketType'),
),
migrations.AlterField(
model_name='sponsorticket',
name='ticket_type',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tickets.TicketType'),
),
migrations.AlterField(
model_name='tickettype',
name='camp',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='camps.Camp'),
),
]

View file

@ -32,6 +32,9 @@ class BaseTicket(CreatedUpdatedModel, UUIDModel):
ticket_type = models.ForeignKey('TicketType')
checked_in = models.BooleanField(default=False)
class Meta:
abstract = True
def save(self, **kwargs):
super(BaseTicket, self).save(**kwargs)
self.qrcode_base64 = self.get_qr_code()