forked from CGM_Public/pretix_original
* Upgrade Django to 3.0 and other dependencies to recent versions * Fix otp version contsraint * Remove six dependency * Resolve some warnings * Fix failing tests * Update django-countries * Resolve all RemovedInDjango31Warnings in test suite * Run isort * Fix import * Update PostgreSQL version on travis
44 lines
1.6 KiB
Python
44 lines
1.6 KiB
Python
from django import forms
|
|
from django.urls import reverse
|
|
from django.utils.translation import gettext_lazy as _
|
|
from django_scopes.forms import (
|
|
SafeModelChoiceField, SafeModelMultipleChoiceField,
|
|
)
|
|
|
|
from pretix.control.forms.widgets import Select2
|
|
from pretix.plugins.pretixdroid.models import AppConfiguration
|
|
|
|
|
|
class AppConfigurationForm(forms.ModelForm):
|
|
class Meta:
|
|
model = AppConfiguration
|
|
fields = ('all_items', 'items', 'list', 'show_info', 'allow_search', 'app')
|
|
widgets = {
|
|
'items': forms.CheckboxSelectMultiple(attrs={
|
|
'data-inverse-dependency': '#id_all_items'
|
|
}),
|
|
'app': forms.RadioSelect
|
|
}
|
|
field_classes = {
|
|
'items': SafeModelMultipleChoiceField,
|
|
'list': SafeModelChoiceField,
|
|
}
|
|
|
|
def __init__(self, **kwargs):
|
|
self.event = kwargs.pop('event')
|
|
super().__init__(**kwargs)
|
|
self.fields['items'].queryset = self.event.items.all()
|
|
self.fields['list'].queryset = self.event.checkin_lists.all()
|
|
self.fields['list'].widget = Select2(
|
|
attrs={
|
|
'data-model-select2': 'generic',
|
|
'data-select2-url': reverse('control:event.orders.checkinlists.select2', kwargs={
|
|
'event': self.event.slug,
|
|
'organizer': self.event.organizer.slug,
|
|
}),
|
|
'data-placeholder': _('Check-in list')
|
|
}
|
|
)
|
|
self.fields['list'].widget.choices = self.fields['list'].choices
|
|
self.fields['list'].required = True
|