diff --git a/src/pretix/control/forms/filter.py b/src/pretix/control/forms/filter.py index de76777f4e..7bb0d54c48 100644 --- a/src/pretix/control/forms/filter.py +++ b/src/pretix/control/forms/filter.py @@ -10,6 +10,8 @@ from pretix.control.utils.i18n import i18ncomp class FilterForm(forms.Form): + orders = {} + def filter_qs(self, qs): return qs @@ -17,6 +19,13 @@ class FilterForm(forms.Form): def filtered(self): return self.is_valid() and any(self.cleaned_data.values()) + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.fields['ordering'] = forms.ChoiceField( + choices=sum([[(a, b), ('-' + a, '-' + b)] for a, b in self.orders.items()], []), + required=False + ) + class OrderFilterForm(FilterForm): query = forms.CharField( @@ -176,6 +185,10 @@ class OrderSearchFilterForm(OrderFilterForm): class SubEventFilterForm(FilterForm): + orders = { + 'date_from': 'date_from', + 'active': 'active' + } status = forms.ChoiceField( label=_('Status'), choices=( @@ -223,10 +236,20 @@ class SubEventFilterForm(FilterForm): Q(name__icontains=i18ncomp(query)) | Q(location__icontains=query) ) + if fdata.get('ordering'): + qs = qs.order_by(dict(self.fields['ordering'].choices)[fdata.get('ordering')]) + return qs class EventFilterForm(FilterForm): + orders = { + 'slug': 'slug', + 'organizer': 'organizer__name', + 'date_from': 'date_from', + 'date_to': 'date_to', + 'live': 'live' + } status = forms.ChoiceField( label=_('Status'), choices=( @@ -293,4 +316,7 @@ class EventFilterForm(FilterForm): Q(name__icontains=i18ncomp(query)) | Q(slug__icontains=query) ) + if fdata.get('ordering'): + qs = qs.order_by(dict(self.fields['ordering'].choices)[fdata.get('ordering')]) + return qs diff --git a/src/pretix/control/templates/pretixcontrol/events/index.html b/src/pretix/control/templates/pretixcontrol/events/index.html index 3d7abc6422..4f47801cbe 100644 --- a/src/pretix/control/templates/pretixcontrol/events/index.html +++ b/src/pretix/control/templates/pretixcontrol/events/index.html @@ -1,5 +1,6 @@ {% extends "pretixcontrol/base.html" %} {% load i18n %} +{% load urlreplace %} {% load bootstrap3 %} {% block title %}{% trans "Events" %}{% endblock %} {% block content %} @@ -47,12 +48,36 @@ - - - - - - + + + {% if not hide_orga %} + + {% endif %} + + + @@ -62,7 +87,7 @@ {{ e.name }} - + {% if not hide_orga %}{% endif %}
{% trans "Event name" %}{% trans "Short form" %}{% trans "Organizer" %}{% trans "Start date" %}{% trans "End date" %}{% trans "Status" %} + {% trans "Event name" %} + + {% trans "Short form" %} + + + + {% trans "Organizer" %} + + + + {% trans "Start date" %} + + + + {% trans "End date" %} + + + + {% trans "Status" %} + + +
{{ e.slug }}{{ e.organizer }}{{ e.organizer }}{{ e.get_date_from_display }} {{ e.get_date_to_display }} diff --git a/src/pretix/control/templates/pretixcontrol/subevents/index.html b/src/pretix/control/templates/pretixcontrol/subevents/index.html index 9533ac7dc3..a7f8f4e825 100644 --- a/src/pretix/control/templates/pretixcontrol/subevents/index.html +++ b/src/pretix/control/templates/pretixcontrol/subevents/index.html @@ -1,6 +1,7 @@ {% extends "pretixcontrol/event/base.html" %} {% load i18n %} {% load bootstrap3 %} +{% load urlreplace %} {% block title %}{% trans "Dates" context "subevent" %}{% endblock %} {% block content %}

{% trans "Dates" context "subevent" %}

@@ -42,9 +43,19 @@ - - - + + + diff --git a/src/pretix/control/views/main.py b/src/pretix/control/views/main.py index 47db205ddf..963b8522d2 100644 --- a/src/pretix/control/views/main.py +++ b/src/pretix/control/views/main.py @@ -12,7 +12,7 @@ from django.views.generic import ListView from formtools.wizard.views import SessionWizardView from i18nfield.strings import LazyI18nString -from pretix.base.models import Event, Team +from pretix.base.models import Event, Organizer, Team from pretix.control.forms.event import ( EventWizardBasicsForm, EventWizardCopyForm, EventWizardFoundationForm, ) @@ -37,6 +37,10 @@ class EventList(ListView): def get_context_data(self, **kwargs): ctx = super().get_context_data(**kwargs) ctx['filter_form'] = self.filter_form + orga_c = Organizer.objects.filter( + pk__in=self.request.user.teams.values_list('organizer', flat=True) + ).count() + ctx['hide_orga'] = orga_c <= 1 return ctx @cached_property
{% trans "Name" %}{% trans "Begin" %}{% trans "Status" %} + {% trans "Name" %} + + {% trans "Begin" %} + + + + {% trans "Status" %} + + +