mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
- [x] Data model - [x] CRUD - [x] Editor - [x] Migration from old settings - [x] Clone files when copying events - [x] badges? - [x] Actual ticket output - [x] Default layout on event creation - [x] Link well from ticketing settings - [x] Tests - [x] Shipping plugin - [x] Migration - [x] Settings - [x] Create default - [x] API
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.13 on 2018-06-05 13:21
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
import pretix.base.models.base
|
||||
import pretix.plugins.ticketoutputpdf.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('pretixbase', '0095_auto_20180604_1129'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='TicketLayout',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('default', models.BooleanField(default=False, verbose_name='Default')),
|
||||
('name', models.CharField(max_length=190, verbose_name='Name')),
|
||||
('layout', models.TextField(
|
||||
default='[{"italic": false, "bottom": "274.60", "align": "left", "fontfamily": "Open Sans", '
|
||||
'"width": "175.00", "left": "17.50", "text": "Sample event name", "content": '
|
||||
'"event_name", "fontsize": "16.0", "bold": false, "color": [0, 0, 0, 1], '
|
||||
'"type": "textarea"}, {"italic": false, "bottom": "262.90", "align": "left", '
|
||||
'"fontfamily": "Open Sans", "width": "110.00", "left": "17.50", "text": "Sample product '
|
||||
'\\u2013 sample variation", "content": "itemvar", "fontsize": "13.0", "bold": false, '
|
||||
'"color": [0, 0, 0, 1], "type": "textarea"}, {"italic": false, "bottom": "252.50", '
|
||||
'"align": "left", "fontfamily": "Open Sans", "width": "110.00", "left": "17.50", '
|
||||
'"text": "John Doe", "content": "attendee_name", "fontsize": "13.0", "bold": false, '
|
||||
'"color": [0, 0, 0, 1], "type": "textarea"}, {"italic": false, "bottom": "242.10", '
|
||||
'"align": "left", "fontfamily": "Open Sans", "width": "110.00", "left": "17.50", '
|
||||
'"text": "May 31st, 2017", "content": "event_date_range", "fontsize": "13.0", '
|
||||
'"bold": false, "color": [0, 0, 0, 1], "type": "textarea"}, {"italic": false, '
|
||||
'"bottom": "204.80", "align": "left", "fontfamily": "Open Sans", "width": "110.00", '
|
||||
'"left": "17.50", "text": "Random City", "content": "event_location", "fontsize": "13.0", '
|
||||
'"bold": false, "color": [0, 0, 0, 1], "type": "textarea"}, {"italic": false, '
|
||||
'"bottom": "194.50", "align": "left", "fontfamily": "Open Sans", "width": "30.00", '
|
||||
'"left": "17.50", "text": "A1B2C", "content": "order", "fontsize": "13.0", "bold": false, '
|
||||
'"color": [0, 0, 0, 1], "type": "textarea"}, {"italic": false, "bottom": "194.50", '
|
||||
'"align": "right", "fontfamily": "Open Sans", "width": "45.00", "left": "52.50", '
|
||||
'"text": "123.45 EUR", "content": "price", "fontsize": "13.0", "bold": false, '
|
||||
'"color": [0, 0, 0, 1], "type": "textarea"}, {"italic": false, "bottom": "194.50", '
|
||||
'"align": "left", "fontfamily": "Open Sans", "width": "90.00", "left": "102.50", '
|
||||
'"text": "tdmruoekvkpbv1o2mv8xccvqcikvr58u", "content": "secret", "fontsize": "13.0", '
|
||||
'"bold": false, "color": [0, 0, 0, 1], "type": "textarea"}, {"left": "130.40", '
|
||||
'"bottom": "204.50", "type": "barcodearea", "size": "64.00"}]')),
|
||||
('background', models.FileField(blank=True, max_length=255, null=True,
|
||||
upload_to=pretix.plugins.ticketoutputpdf.models.bg_name)),
|
||||
('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='ticket_layouts',
|
||||
to='pretixbase.Event')),
|
||||
],
|
||||
options={
|
||||
'ordering': ('name',),
|
||||
},
|
||||
bases=(models.Model, pretix.base.models.base.LoggingMixin),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='TicketLayoutItem',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('item', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name='ticketlayout_assignment', to='pretixbase.Item')),
|
||||
('layout',
|
||||
models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='item_assignments',
|
||||
to='ticketoutputpdf.TicketLayout')),
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,55 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.13 on 2018-06-05 20:22
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
from django.utils.translation import gettext
|
||||
|
||||
from pretix.base.i18n import language
|
||||
|
||||
|
||||
def convert_old_settings(app, schema_editor):
|
||||
EventSettingsStore = app.get_model('pretixbase', 'Event_SettingsStore')
|
||||
for es in EventSettingsStore.objects.filter(key='ticketoutput_pdf_layout'):
|
||||
locale_es = EventSettingsStore.objects.filter(object=es.object, key='locale').first()
|
||||
if locale_es:
|
||||
locale = locale_es.value
|
||||
else:
|
||||
locale = 'en'
|
||||
|
||||
with language(locale):
|
||||
es.object.ticket_layouts.create(
|
||||
name=gettext('Default layout'),
|
||||
default=True,
|
||||
layout=es.value
|
||||
)
|
||||
|
||||
for es in EventSettingsStore.objects.filter(key='ticketoutput_pdf_background'):
|
||||
locale_es = EventSettingsStore.objects.filter(object=es.object, key='locale').first()
|
||||
if locale_es:
|
||||
locale = locale_es.value
|
||||
else:
|
||||
locale = 'en'
|
||||
|
||||
with language(locale):
|
||||
l = es.object.ticket_layouts.get_or_create(
|
||||
default=True,
|
||||
defaults={
|
||||
'name': gettext('Default layout'),
|
||||
}
|
||||
)[0]
|
||||
|
||||
l.background.name = es.value[7:]
|
||||
setattr(l, 'background', l.background.name)
|
||||
l.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('ticketoutputpdf', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(convert_old_settings, migrations.RunPython.noop)
|
||||
]
|
||||
Reference in New Issue
Block a user