forked from CGM_Public/pretix_original
New pretixdroid configuration system
This commit is contained in:
23
src/pretix/plugins/pretixdroid/forms.py
Normal file
23
src/pretix/plugins/pretixdroid/forms.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from django import forms
|
||||
|
||||
from pretix.plugins.pretixdroid.models import AppConfiguration
|
||||
|
||||
|
||||
class AppConfigurationForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = AppConfiguration
|
||||
fields = ('all_items', 'items', 'subevent', 'show_info', 'allow_search')
|
||||
widgets = {
|
||||
'items': forms.CheckboxSelectMultiple(attrs={
|
||||
'data-inverse-dependency': '#id_all_items'
|
||||
}),
|
||||
}
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.event = kwargs.pop('event')
|
||||
super().__init__(**kwargs)
|
||||
self.fields['items'].queryset = self.event.items.all()
|
||||
if self.event.has_subevents:
|
||||
self.fields['subevent'].queryset = self.event.subevents.all()
|
||||
else:
|
||||
del self.fields['subevent']
|
||||
Reference in New Issue
Block a user