mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +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:
41
src/pretix/plugins/ticketoutputpdf/forms.py
Normal file
41
src/pretix/plugins/ticketoutputpdf/forms.py
Normal file
@@ -0,0 +1,41 @@
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from pretix.base.models import CachedCombinedTicket, CachedTicket
|
||||
|
||||
from .models import TicketLayout, TicketLayoutItem
|
||||
|
||||
|
||||
class TicketLayoutForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = TicketLayout
|
||||
fields = ('name',)
|
||||
|
||||
|
||||
class TicketLayoutItemForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = TicketLayoutItem
|
||||
fields = ('layout',)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
event = kwargs.pop('event')
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields['layout'].label = _('PDF ticket layout')
|
||||
self.fields['layout'].empty_label = _('(Event default)')
|
||||
self.fields['layout'].queryset = event.ticket_layouts.all()
|
||||
self.fields['layout'].required = False
|
||||
|
||||
def save(self, commit=True):
|
||||
if self.cleaned_data['layout'] is None:
|
||||
if self.instance.pk:
|
||||
self.instance.delete()
|
||||
else:
|
||||
return
|
||||
else:
|
||||
return super().save(commit=commit)
|
||||
CachedTicket.objects.filter(
|
||||
order_position__item_id=self.instance.item, provider='pdf'
|
||||
).delete()
|
||||
CachedCombinedTicket.objects.filter(
|
||||
order__positions__item=self.instance.item
|
||||
).delete()
|
||||
Reference in New Issue
Block a user