mirror of
https://github.com/pretix/pretix.git
synced 2026-05-11 16:13:59 +00:00
Device and team creation: List events ordered and with date
This commit is contained in:
@@ -177,7 +177,7 @@ class EventWizardBasicsForm(I18nModelForm):
|
|||||||
return slug
|
return slug
|
||||||
|
|
||||||
|
|
||||||
class EventChoiceField(forms.ModelChoiceField):
|
class EventChoiceMixin:
|
||||||
def label_from_instance(self, obj):
|
def label_from_instance(self, obj):
|
||||||
return mark_safe('{}<br /><span class="text-muted">{} · {}</span>'.format(
|
return mark_safe('{}<br /><span class="text-muted">{} · {}</span>'.format(
|
||||||
escape(str(obj)),
|
escape(str(obj)),
|
||||||
@@ -186,6 +186,16 @@ class EventChoiceField(forms.ModelChoiceField):
|
|||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
|
class EventChoiceField(forms.ModelChoiceField):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SafeEventMultipleChoiceField(EventChoiceMixin, forms.ModelMultipleChoiceField):
|
||||||
|
def __init__(self, queryset, *args, **kwargs):
|
||||||
|
queryset = queryset.model.objects.none()
|
||||||
|
super().__init__(queryset, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class EventWizardCopyForm(forms.Form):
|
class EventWizardCopyForm(forms.Form):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ from pretix.base.models import Device, Organizer, Team
|
|||||||
from pretix.control.forms import (
|
from pretix.control.forms import (
|
||||||
ExtFileField, FontSelect, MultipleLanguagesWidget,
|
ExtFileField, FontSelect, MultipleLanguagesWidget,
|
||||||
)
|
)
|
||||||
|
from pretix.control.forms.event import SafeEventMultipleChoiceField
|
||||||
from pretix.multidomain.models import KnownDomain
|
from pretix.multidomain.models import KnownDomain
|
||||||
from pretix.presale.style import get_fonts
|
from pretix.presale.style import get_fonts
|
||||||
|
|
||||||
@@ -136,7 +137,9 @@ class TeamForm(forms.ModelForm):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
organizer = kwargs.pop('organizer')
|
organizer = kwargs.pop('organizer')
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields['limit_events'].queryset = organizer.events.all()
|
self.fields['limit_events'].queryset = organizer.events.all().order_by(
|
||||||
|
'-has_subevents', '-date_from'
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Team
|
model = Team
|
||||||
@@ -147,11 +150,12 @@ class TeamForm(forms.ModelForm):
|
|||||||
'can_view_vouchers', 'can_change_vouchers']
|
'can_view_vouchers', 'can_change_vouchers']
|
||||||
widgets = {
|
widgets = {
|
||||||
'limit_events': forms.CheckboxSelectMultiple(attrs={
|
'limit_events': forms.CheckboxSelectMultiple(attrs={
|
||||||
'data-inverse-dependency': '#id_all_events'
|
'data-inverse-dependency': '#id_all_events',
|
||||||
|
'class': 'scrolling-multiple-choice scrolling-multiple-choice-large',
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
field_classes = {
|
field_classes = {
|
||||||
'limit_events': SafeModelMultipleChoiceField
|
'limit_events': SafeEventMultipleChoiceField
|
||||||
}
|
}
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
@@ -171,7 +175,9 @@ class DeviceForm(forms.ModelForm):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
organizer = kwargs.pop('organizer')
|
organizer = kwargs.pop('organizer')
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields['limit_events'].queryset = organizer.events.all()
|
self.fields['limit_events'].queryset = organizer.events.all().order_by(
|
||||||
|
'-has_subevents', '-date_from'
|
||||||
|
)
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
d = super().clean()
|
d = super().clean()
|
||||||
@@ -185,11 +191,12 @@ class DeviceForm(forms.ModelForm):
|
|||||||
fields = ['name', 'all_events', 'limit_events']
|
fields = ['name', 'all_events', 'limit_events']
|
||||||
widgets = {
|
widgets = {
|
||||||
'limit_events': forms.CheckboxSelectMultiple(attrs={
|
'limit_events': forms.CheckboxSelectMultiple(attrs={
|
||||||
'data-inverse-dependency': '#id_all_events'
|
'data-inverse-dependency': '#id_all_events',
|
||||||
|
'class': 'scrolling-multiple-choice scrolling-multiple-choice-large',
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
field_classes = {
|
field_classes = {
|
||||||
'limit_events': SafeModelMultipleChoiceField
|
'limit_events': SafeEventMultipleChoiceField
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -314,6 +314,9 @@ div.scrolling-multiple-choice, div.scrolling-choice {
|
|||||||
.radio:first-of-type, .checkbox:first-of-type {
|
.radio:first-of-type, .checkbox:first-of-type {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
&.scrolling-multiple-choice-large {
|
||||||
|
height: 350px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
table td > .checkbox {
|
table td > .checkbox {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user