PDF Layout: Make pretix logo a layout element, not a background element

This commit is contained in:
Raphael Michel
2018-07-10 13:24:27 +02:00
parent dc12b9a197
commit 6b9c3ad4e7
14 changed files with 343 additions and 35 deletions

View File

@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import json
from django.db import migrations
from django.db.models import Q
def add_pretix_logo(app, schema_editor):
TicketLayout = app.get_model('ticketoutputpdf', 'TicketLayout')
for tl in TicketLayout.objects.filter(Q(background__isnull=True) | Q(background="")):
l = json.loads(tl.layout)
l.append({"type": "poweredby", "left": "88.72", "bottom": "10.00", "size": "20.00", "content": "dark"})
tl.layout = json.dumps(l)
tl.save(update_fields=['layout'])
class Migration(migrations.Migration):
dependencies = [
('ticketoutputpdf', '0002_auto_20180605_2022'),
]
operations = [
migrations.RunPython(add_pretix_logo, migrations.RunPython.noop)
]

View File

@@ -53,7 +53,8 @@ class TicketLayout(LoggedModel):
'"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"}]'
'{"left": "130.40", "bottom": "204.50", "type": "barcodearea", "size": "64.00"},{"type":"poweredby",'
'"left":"88.72","bottom":"10.00","size":"20.00","content":"dark"}]'
)
background = models.FileField(null=True, blank=True, upload_to=bg_name, max_length=255)

View File

@@ -157,7 +157,8 @@ class PdfTicketOutput(BaseTicketOutput):
{"type": "textarea", "left": "102.50", "bottom": "194.50", "fontsize": "13.0", "color": [0, 0, 0, 1],
"fontfamily": "Open Sans", "bold": False, "italic": False, "width": "90.00", "content": "secret",
"text": "tdmruoekvkpbv1o2mv8xccvqcikvr58u", "align": "left"},
{"type": "barcodearea", "left": "130.40", "bottom": "204.50", "size": "64.00"}
{"type": "barcodearea", "left": "130.40", "bottom": "204.50", "size": "64.00"},
{"type": "poweredby", "left": "88.72", "bottom": "10.00", "size": "20.00"},
]
def _migrate_from_old_settings(self):