forked from CGM_Public/pretix_original
Allow to sort list of quotas
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
{% extends "pretixcontrol/items/base.html" %}
|
{% extends "pretixcontrol/items/base.html" %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
{% load urlreplace %}
|
||||||
{% block title %}{% trans "Quotas" %}{% endblock %}
|
{% block title %}{% trans "Quotas" %}{% endblock %}
|
||||||
{% block inside %}
|
{% block inside %}
|
||||||
<h1>{% trans "Quotas" %}</h1>
|
<h1>{% trans "Quotas" %}</h1>
|
||||||
@@ -41,12 +42,21 @@
|
|||||||
<table class="table table-hover table-quotas">
|
<table class="table table-hover table-quotas">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{% trans "Quota name" %}</th>
|
<th>{% trans "Quota name" %}
|
||||||
|
<a href="?{% url_replace request 'ordering' '-name' %}"><i class="fa fa-caret-down"></i></a>
|
||||||
|
<a href="?{% url_replace request 'ordering' 'name' %}"><i class="fa fa-caret-up"></i></a></th>
|
||||||
|
</th>
|
||||||
<th>{% trans "Products" %}</th>
|
<th>{% trans "Products" %}</th>
|
||||||
{% if request.event.has_subevents %}
|
{% if request.event.has_subevents %}
|
||||||
<th>{% trans "Date" context "subevent" %}</th>
|
<th>{% trans "Date" context "subevent" %}
|
||||||
|
<a href="?{% url_replace request 'ordering' '-date' %}"><i class="fa fa-caret-down"></i></a>
|
||||||
|
<a href="?{% url_replace request 'ordering' 'date' %}"><i class="fa fa-caret-up"></i></a></th>
|
||||||
|
</th>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<th>{% trans "Total capacity" %}</th>
|
<th>{% trans "Total capacity" %}
|
||||||
|
<a href="?{% url_replace request 'ordering' '-size' %}"><i class="fa fa-caret-down"></i></a>
|
||||||
|
<a href="?{% url_replace request 'ordering' 'size' %}"><i class="fa fa-caret-up"></i></a></th>
|
||||||
|
</th>
|
||||||
<th>{% trans "Capacity left" %}</th>
|
<th>{% trans "Capacity left" %}</th>
|
||||||
<th class="action-col-2"></th>
|
<th class="action-col-2"></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -698,6 +698,19 @@ class QuotaList(PaginationMixin, ListView):
|
|||||||
if self.request.GET.get("subevent", "") != "":
|
if self.request.GET.get("subevent", "") != "":
|
||||||
s = self.request.GET.get("subevent", "")
|
s = self.request.GET.get("subevent", "")
|
||||||
qs = qs.filter(subevent_id=s)
|
qs = qs.filter(subevent_id=s)
|
||||||
|
|
||||||
|
valid_orders = {
|
||||||
|
'-date': ('-subevent__date_from', 'name'),
|
||||||
|
'date': ('subevent__date_from', '-name'),
|
||||||
|
'size': ('size', 'name'),
|
||||||
|
'-size': ('-size', '-name'),
|
||||||
|
'name': ('name',),
|
||||||
|
'-name': ('-name',),
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.request.GET.get("ordering", "-date") in valid_orders:
|
||||||
|
qs = qs.order_by(*valid_orders[self.request.GET.get("ordering", "-date")])
|
||||||
|
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
|
|||||||
Reference in New Issue
Block a user