Merge branch 'master' of github.com:bornhack/bornhack-website
This commit is contained in:
commit
13efe137b8
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- 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 __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- 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 __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
@ -12,20 +12,52 @@ class Migration(migrations.Migration):
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('shop', '0047_auto_20170522_1942'),
|
|
||||||
('sponsors', '0006_auto_20170715_1110'),
|
|
||||||
('camps', '0022_camp_colour'),
|
('camps', '0022_camp_colour'),
|
||||||
|
('sponsors', '0006_auto_20170715_1110'),
|
||||||
|
('shop', '0047_auto_20170522_1942'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='BaseTicket',
|
name='DiscountTicket',
|
||||||
fields=[
|
fields=[
|
||||||
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||||
('created', models.DateTimeField(auto_now_add=True)),
|
('created', models.DateTimeField(auto_now_add=True)),
|
||||||
('updated', models.DateTimeField(auto_now=True)),
|
('updated', models.DateTimeField(auto_now=True)),
|
||||||
('qrcode_base64', models.TextField(blank=True, null=True)),
|
('qrcode_base64', models.TextField(blank=True, null=True)),
|
||||||
('checked_in', models.BooleanField(default=False)),
|
('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={
|
options={
|
||||||
'abstract': False,
|
'abstract': False,
|
||||||
|
@ -38,51 +70,25 @@ class Migration(migrations.Migration):
|
||||||
('created', models.DateTimeField(auto_now_add=True)),
|
('created', models.DateTimeField(auto_now_add=True)),
|
||||||
('updated', models.DateTimeField(auto_now=True)),
|
('updated', models.DateTimeField(auto_now=True)),
|
||||||
('name', models.TextField()),
|
('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={
|
options={
|
||||||
'abstract': False,
|
'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(
|
migrations.AddField(
|
||||||
model_name='baseticket',
|
model_name='sponsorticket',
|
||||||
name='ticket_type',
|
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'),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
36
src/tickets/migrations/0002_auto_20170819_2222.py
Normal file
36
src/tickets/migrations/0002_auto_20170819_2222.py
Normal 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'),
|
||||||
|
),
|
||||||
|
]
|
27
src/tickets/migrations/0003_auto_20170819_2309.py
Normal file
27
src/tickets/migrations/0003_auto_20170819_2309.py
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.5 on 2017-08-19 21:09
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('tickets', '0002_auto_20170819_2222'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='discountticket',
|
||||||
|
name='qrcode_base64',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='shopticket',
|
||||||
|
name='qrcode_base64',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='sponsorticket',
|
||||||
|
name='qrcode_base64',
|
||||||
|
),
|
||||||
|
]
|
|
@ -27,14 +27,11 @@ class TicketType(CreatedUpdatedModel, UUIDModel):
|
||||||
|
|
||||||
|
|
||||||
class BaseTicket(CreatedUpdatedModel, UUIDModel):
|
class BaseTicket(CreatedUpdatedModel, UUIDModel):
|
||||||
qrcode_base64 = models.TextField(null=True, blank=True)
|
|
||||||
ticket_type = models.ForeignKey('TicketType')
|
ticket_type = models.ForeignKey('TicketType')
|
||||||
checked_in = models.BooleanField(default=False)
|
checked_in = models.BooleanField(default=False)
|
||||||
|
|
||||||
def save(self, **kwargs):
|
class Meta:
|
||||||
super(BaseTicket, self).save(**kwargs)
|
abstract = True
|
||||||
self.qrcode_base64 = self.get_qr_code()
|
|
||||||
super(BaseTicket, self).save(**kwargs)
|
|
||||||
|
|
||||||
def _get_token(self):
|
def _get_token(self):
|
||||||
return hashlib.sha256(
|
return hashlib.sha256(
|
||||||
|
@ -44,7 +41,7 @@ class BaseTicket(CreatedUpdatedModel, UUIDModel):
|
||||||
).encode('utf-8')
|
).encode('utf-8')
|
||||||
).hexdigest()
|
).hexdigest()
|
||||||
|
|
||||||
def get_qr_code(self):
|
def get_qr_code_base64(self):
|
||||||
qr = qrcode.make(
|
qr = qrcode.make(
|
||||||
self._get_token(),
|
self._get_token(),
|
||||||
version=1,
|
version=1,
|
||||||
|
@ -56,7 +53,7 @@ class BaseTicket(CreatedUpdatedModel, UUIDModel):
|
||||||
return qrcode_base64
|
return qrcode_base64
|
||||||
|
|
||||||
def get_qr_code_url(self):
|
def get_qr_code_url(self):
|
||||||
return 'data:image/png;base64,{}'.format(self.qrcode_base64)
|
return 'data:image/png;base64,{}'.format(self.get_qr_code_base64)
|
||||||
|
|
||||||
def generate_pdf(self):
|
def generate_pdf(self):
|
||||||
return generate_pdf_letter(
|
return generate_pdf_letter(
|
||||||
|
@ -117,11 +114,6 @@ class ShopTicket(BaseTicket):
|
||||||
product=self.product
|
product=self.product
|
||||||
)
|
)
|
||||||
|
|
||||||
def save(self, **kwargs):
|
|
||||||
super(ShopTicket, self).save(**kwargs)
|
|
||||||
self.qrcode_base64 = self.get_qr_code()
|
|
||||||
super(ShopTicket, self).save(**kwargs)
|
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return str(
|
return str(
|
||||||
reverse_lazy('tickets:shopticket_edit', kwargs={'pk': self.pk})
|
reverse_lazy('tickets:shopticket_edit', kwargs={'pk': self.pk})
|
||||||
|
|
Loading…
Reference in a new issue