mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Add column ordering to more lists
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 @@
|
||||
<table class="table table-condensed table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Event name" %}</th>
|
||||
<th>{% trans "Short form" %}</th>
|
||||
<th>{% trans "Organizer" %}</th>
|
||||
<th>{% trans "Start date" %}</th>
|
||||
<th>{% trans "End date" %}</th>
|
||||
<th class="text-right">{% trans "Status" %}</th>
|
||||
<th>
|
||||
{% trans "Event name" %}
|
||||
</th>
|
||||
<th>
|
||||
{% trans "Short form" %}
|
||||
<a href="?{% url_replace request 'ordering' '-slug' %}"><i class="fa fa-caret-down"></i></a>
|
||||
<a href="?{% url_replace request 'ordering' 'slug' %}"><i class="fa fa-caret-up"></i></a>
|
||||
</th>
|
||||
{% if not hide_orga %}
|
||||
<th>
|
||||
{% trans "Organizer" %}
|
||||
<a href="?{% url_replace request 'ordering' '-organizer' %}"><i class="fa fa-caret-down"></i></a>
|
||||
<a href="?{% url_replace request 'ordering' 'organizer' %}"><i class="fa fa-caret-up"></i></a>
|
||||
</th>
|
||||
{% endif %}
|
||||
<th>
|
||||
{% trans "Start date" %}
|
||||
<a href="?{% url_replace request 'ordering' '-date_from' %}"><i class="fa fa-caret-down"></i></a>
|
||||
<a href="?{% url_replace request 'ordering' 'date_from' %}"><i class="fa fa-caret-up"></i></a>
|
||||
</th>
|
||||
<th>
|
||||
{% trans "End date" %}
|
||||
<a href="?{% url_replace request 'ordering' '-date_to' %}"><i class="fa fa-caret-down"></i></a>
|
||||
<a href="?{% url_replace request 'ordering' 'date_to' %}"><i class="fa fa-caret-up"></i></a>
|
||||
</th>
|
||||
<th class="text-right">
|
||||
{% trans "Status" %}
|
||||
<a href="?{% url_replace request 'ordering' '-live' %}"><i class="fa fa-caret-down"></i></a>
|
||||
<a href="?{% url_replace request 'ordering' 'live' %}"><i class="fa fa-caret-up"></i></a>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -62,7 +87,7 @@
|
||||
<strong><a href="{% url "control:event.index" organizer=e.organizer.slug event=e.slug %}">{{ e.name }}</a></strong>
|
||||
</td>
|
||||
<td>{{ e.slug }}</td>
|
||||
<td>{{ e.organizer }}</td>
|
||||
{% if not hide_orga %}<td>{{ e.organizer }}</td>{% endif %}
|
||||
<td>{{ e.get_date_from_display }}</td>
|
||||
<td>{{ e.get_date_to_display }}</td>
|
||||
<td class="text-right">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{% extends "pretixcontrol/event/base.html" %}
|
||||
{% load i18n %}
|
||||
{% load bootstrap3 %}
|
||||
{% load urlreplace %}
|
||||
{% block title %}{% trans "Dates" context "subevent" %}{% endblock %}
|
||||
{% block content %}
|
||||
<h1>{% trans "Dates" context "subevent" %}</h1>
|
||||
@@ -42,9 +43,19 @@
|
||||
<table class="table table-hover table-quotas">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Name" %}</th>
|
||||
<th>{% trans "Begin" %}</th>
|
||||
<th>{% trans "Status" %}</th>
|
||||
<th>
|
||||
{% trans "Name" %}
|
||||
</th>
|
||||
<th>
|
||||
{% trans "Begin" %}
|
||||
<a href="?{% url_replace request 'ordering' '-date_from' %}"><i class="fa fa-caret-down"></i></a>
|
||||
<a href="?{% url_replace request 'ordering' 'date_from' %}"><i class="fa fa-caret-up"></i></a>
|
||||
</th>
|
||||
<th>
|
||||
{% trans "Status" %}
|
||||
<a href="?{% url_replace request 'ordering' '-active' %}"><i class="fa fa-caret-down"></i></a>
|
||||
<a href="?{% url_replace request 'ordering' 'active' %}"><i class="fa fa-caret-up"></i></a>
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user