forked from CGM_Public/pretix_original
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):
|
class FilterForm(forms.Form):
|
||||||
|
orders = {}
|
||||||
|
|
||||||
def filter_qs(self, qs):
|
def filter_qs(self, qs):
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
@@ -17,6 +19,13 @@ class FilterForm(forms.Form):
|
|||||||
def filtered(self):
|
def filtered(self):
|
||||||
return self.is_valid() and any(self.cleaned_data.values())
|
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):
|
class OrderFilterForm(FilterForm):
|
||||||
query = forms.CharField(
|
query = forms.CharField(
|
||||||
@@ -176,6 +185,10 @@ class OrderSearchFilterForm(OrderFilterForm):
|
|||||||
|
|
||||||
|
|
||||||
class SubEventFilterForm(FilterForm):
|
class SubEventFilterForm(FilterForm):
|
||||||
|
orders = {
|
||||||
|
'date_from': 'date_from',
|
||||||
|
'active': 'active'
|
||||||
|
}
|
||||||
status = forms.ChoiceField(
|
status = forms.ChoiceField(
|
||||||
label=_('Status'),
|
label=_('Status'),
|
||||||
choices=(
|
choices=(
|
||||||
@@ -223,10 +236,20 @@ class SubEventFilterForm(FilterForm):
|
|||||||
Q(name__icontains=i18ncomp(query)) | Q(location__icontains=query)
|
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
|
return qs
|
||||||
|
|
||||||
|
|
||||||
class EventFilterForm(FilterForm):
|
class EventFilterForm(FilterForm):
|
||||||
|
orders = {
|
||||||
|
'slug': 'slug',
|
||||||
|
'organizer': 'organizer__name',
|
||||||
|
'date_from': 'date_from',
|
||||||
|
'date_to': 'date_to',
|
||||||
|
'live': 'live'
|
||||||
|
}
|
||||||
status = forms.ChoiceField(
|
status = forms.ChoiceField(
|
||||||
label=_('Status'),
|
label=_('Status'),
|
||||||
choices=(
|
choices=(
|
||||||
@@ -293,4 +316,7 @@ class EventFilterForm(FilterForm):
|
|||||||
Q(name__icontains=i18ncomp(query)) | Q(slug__icontains=query)
|
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
|
return qs
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{% extends "pretixcontrol/base.html" %}
|
{% extends "pretixcontrol/base.html" %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
{% load urlreplace %}
|
||||||
{% load bootstrap3 %}
|
{% load bootstrap3 %}
|
||||||
{% block title %}{% trans "Events" %}{% endblock %}
|
{% block title %}{% trans "Events" %}{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
@@ -47,12 +48,36 @@
|
|||||||
<table class="table table-condensed table-hover">
|
<table class="table table-condensed table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{% trans "Event name" %}</th>
|
<th>
|
||||||
<th>{% trans "Short form" %}</th>
|
{% trans "Event name" %}
|
||||||
<th>{% trans "Organizer" %}</th>
|
</th>
|
||||||
<th>{% trans "Start date" %}</th>
|
<th>
|
||||||
<th>{% trans "End date" %}</th>
|
{% trans "Short form" %}
|
||||||
<th class="text-right">{% trans "Status" %}</th>
|
<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>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -62,7 +87,7 @@
|
|||||||
<strong><a href="{% url "control:event.index" organizer=e.organizer.slug event=e.slug %}">{{ e.name }}</a></strong>
|
<strong><a href="{% url "control:event.index" organizer=e.organizer.slug event=e.slug %}">{{ e.name }}</a></strong>
|
||||||
</td>
|
</td>
|
||||||
<td>{{ e.slug }}</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_from_display }}</td>
|
||||||
<td>{{ e.get_date_to_display }}</td>
|
<td>{{ e.get_date_to_display }}</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{% extends "pretixcontrol/event/base.html" %}
|
{% extends "pretixcontrol/event/base.html" %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load bootstrap3 %}
|
{% load bootstrap3 %}
|
||||||
|
{% load urlreplace %}
|
||||||
{% block title %}{% trans "Dates" context "subevent" %}{% endblock %}
|
{% block title %}{% trans "Dates" context "subevent" %}{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>{% trans "Dates" context "subevent" %}</h1>
|
<h1>{% trans "Dates" context "subevent" %}</h1>
|
||||||
@@ -42,9 +43,19 @@
|
|||||||
<table class="table table-hover table-quotas">
|
<table class="table table-hover table-quotas">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{% trans "Name" %}</th>
|
<th>
|
||||||
<th>{% trans "Begin" %}</th>
|
{% trans "Name" %}
|
||||||
<th>{% trans "Status" %}</th>
|
</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>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from django.views.generic import ListView
|
|||||||
from formtools.wizard.views import SessionWizardView
|
from formtools.wizard.views import SessionWizardView
|
||||||
from i18nfield.strings import LazyI18nString
|
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 (
|
from pretix.control.forms.event import (
|
||||||
EventWizardBasicsForm, EventWizardCopyForm, EventWizardFoundationForm,
|
EventWizardBasicsForm, EventWizardCopyForm, EventWizardFoundationForm,
|
||||||
)
|
)
|
||||||
@@ -37,6 +37,10 @@ class EventList(ListView):
|
|||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
ctx = super().get_context_data(**kwargs)
|
ctx = super().get_context_data(**kwargs)
|
||||||
ctx['filter_form'] = self.filter_form
|
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
|
return ctx
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
|
|||||||
Reference in New Issue
Block a user