mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Consistently set default background PDFs on server, not client (#2840)
Co-authored-by: Martin Gross <gross@rami.io>
This commit is contained in:
@@ -24,6 +24,7 @@ from rest_framework import viewsets
|
||||
from pretix.api.serializers.i18n import I18nAwareModelSerializer
|
||||
from pretix.api.serializers.order import CompatibleJSONField
|
||||
|
||||
from ...multidomain.utils import static_absolute
|
||||
from .models import BadgeItem, BadgeLayout
|
||||
|
||||
|
||||
@@ -47,6 +48,12 @@ class BadgeLayoutSerializer(I18nAwareModelSerializer):
|
||||
model = BadgeLayout
|
||||
fields = ('id', 'name', 'default', 'layout', 'background', 'item_assignments')
|
||||
|
||||
def to_representation(self, instance):
|
||||
d = super().to_representation(instance)
|
||||
if not d['background']:
|
||||
d['background'] = static_absolute(instance.event, "pretixplugins/badges/badge_default_a6l.pdf")
|
||||
return d
|
||||
|
||||
|
||||
class BadgeLayoutViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
serializer_class = BadgeLayoutSerializer
|
||||
|
||||
@@ -24,6 +24,7 @@ from rest_framework import viewsets
|
||||
from pretix.api.serializers.i18n import I18nAwareModelSerializer
|
||||
from pretix.api.serializers.order import CompatibleJSONField
|
||||
|
||||
from ...multidomain.utils import static_absolute
|
||||
from .models import TicketLayout, TicketLayoutItem
|
||||
|
||||
|
||||
@@ -49,6 +50,12 @@ class TicketLayoutSerializer(I18nAwareModelSerializer):
|
||||
model = TicketLayout
|
||||
fields = ('id', 'name', 'default', 'layout', 'background', 'item_assignments')
|
||||
|
||||
def to_representation(self, instance):
|
||||
d = super().to_representation(instance)
|
||||
if not d['background']:
|
||||
d['background'] = static_absolute(instance.event, "pretixpresale/pdf/ticket_default_a4.pdf")
|
||||
return d
|
||||
|
||||
|
||||
class TicketLayoutViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
serializer_class = TicketLayoutSerializer
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
from django.apps import AppConfig
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import gettext, gettext_lazy as _
|
||||
|
||||
from pretix import __version__ as version
|
||||
|
||||
@@ -63,3 +63,11 @@ class TicketOutputPdfApp(AppConfig):
|
||||
except ImportError:
|
||||
errs.append("Python package 'reportlab' is not installed.")
|
||||
return errs
|
||||
|
||||
def installed(self, event):
|
||||
event.ticket_layouts.get_or_create(
|
||||
default=True,
|
||||
defaults={
|
||||
'name': gettext('Default layout'),
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user