forked from CGM_Public/pretix_original
Allow to sort the list of vouchers
This commit is contained in:
@@ -851,6 +851,32 @@ class UserFilterForm(FilterForm):
|
|||||||
|
|
||||||
class VoucherFilterForm(FilterForm):
|
class VoucherFilterForm(FilterForm):
|
||||||
orders = {
|
orders = {
|
||||||
|
'code': 'code',
|
||||||
|
'-code': '-code',
|
||||||
|
'redeemed': 'redeemed',
|
||||||
|
'-redeemed': '-redeemed',
|
||||||
|
'valid_until': 'valid_until',
|
||||||
|
'-valid_until': '-valid_until',
|
||||||
|
'tag': 'tag',
|
||||||
|
'-tag': '-tag',
|
||||||
|
'item': (
|
||||||
|
'seat__sorting_rank',
|
||||||
|
'item__category__position',
|
||||||
|
'item__category',
|
||||||
|
'item__position',
|
||||||
|
'item__variation__position',
|
||||||
|
'quota__name',
|
||||||
|
),
|
||||||
|
'subevent': 'subevent__date_from',
|
||||||
|
'-subevent': '-subevent__date_from',
|
||||||
|
'-item': (
|
||||||
|
'-seat__sorting_rank',
|
||||||
|
'-item__category__position',
|
||||||
|
'-item__category',
|
||||||
|
'-item__position',
|
||||||
|
'-item__variation__position',
|
||||||
|
'-quota__name',
|
||||||
|
)
|
||||||
}
|
}
|
||||||
status = forms.ChoiceField(
|
status = forms.ChoiceField(
|
||||||
label=_('Status'),
|
label=_('Status'),
|
||||||
@@ -987,7 +1013,15 @@ class VoucherFilterForm(FilterForm):
|
|||||||
qs = qs.filter(subevent_id=fdata.get('subevent').pk)
|
qs = qs.filter(subevent_id=fdata.get('subevent').pk)
|
||||||
|
|
||||||
if fdata.get('ordering'):
|
if fdata.get('ordering'):
|
||||||
qs = qs.order_by(self.get_order_by())
|
ob = self.orders[fdata.get('ordering')]
|
||||||
|
if isinstance(ob, dict):
|
||||||
|
ob = dict(ob)
|
||||||
|
o = ob.pop('_order')
|
||||||
|
qs = qs.annotate(**ob).order_by(o)
|
||||||
|
elif isinstance(ob, (list, tuple)):
|
||||||
|
qs = qs.order_by(*ob)
|
||||||
|
else:
|
||||||
|
qs = qs.order_by(ob)
|
||||||
|
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
|
|||||||
@@ -95,13 +95,37 @@
|
|||||||
<input type="checkbox" data-toggle-table />
|
<input type="checkbox" data-toggle-table />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</th>
|
</th>
|
||||||
<th>{% trans "Voucher code" %}</th>
|
<th>
|
||||||
<th>{% trans "Redemptions" %}</th>
|
{% trans "Voucher code" %}
|
||||||
<th>{% trans "Expiry" %}</th>
|
<a href="?{% url_replace request 'ordering' '-code' %}"><i class="fa fa-caret-down"></i></a>
|
||||||
<th>{% trans "Tag" %}</th>
|
<a href="?{% url_replace request 'ordering' 'code' %}"><i class="fa fa-caret-up"></i></a>
|
||||||
<th>{% trans "Product" %}</th>
|
</th>
|
||||||
|
<th>
|
||||||
|
{% trans "Redemptions" %}
|
||||||
|
<a href="?{% url_replace request 'ordering' '-redeemed' %}"><i class="fa fa-caret-down"></i></a>
|
||||||
|
<a href="?{% url_replace request 'ordering' 'redeemed' %}"><i class="fa fa-caret-up"></i></a>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
{% trans "Expiry" %}
|
||||||
|
<a href="?{% url_replace request 'ordering' '-valid_until' %}"><i class="fa fa-caret-down"></i></a>
|
||||||
|
<a href="?{% url_replace request 'ordering' 'valid_until' %}"><i class="fa fa-caret-up"></i></a>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
{% trans "Tag" %}
|
||||||
|
<a href="?{% url_replace request 'ordering' '-tag' %}"><i class="fa fa-caret-down"></i></a>
|
||||||
|
<a href="?{% url_replace request 'ordering' 'tag' %}"><i class="fa fa-caret-up"></i></a>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
{% trans "Product" %}
|
||||||
|
<a href="?{% url_replace request 'ordering' '-item' %}"><i class="fa fa-caret-down"></i></a>
|
||||||
|
<a href="?{% url_replace request 'ordering' 'item' %}"><i class="fa fa-caret-up"></i></a>
|
||||||
|
</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' '-subevent' %}"><i class="fa fa-caret-down"></i></a>
|
||||||
|
<a href="?{% url_replace request 'ordering' 'subevent' %}"><i class="fa fa-caret-up"></i></a>
|
||||||
|
</th>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user