Added ordering in admin interface order list

This commit is contained in:
Daniel Rosenblüh
2016-10-20 20:01:40 +02:00
committed by Raphael Michel
parent 39e940da5e
commit ad2a712934
2 changed files with 17 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
{% extends "pretixcontrol/event/base.html" %}
{% load i18n %}
{% load eventurl %}
{% load urlreplace %}
{% block title %}{% trans "Orders" %}{% endblock %}
{% block content %}
<h1>{% trans "Orders" %}</h1>
@@ -72,11 +73,16 @@
<table class="table table-condensed table-hover">
<thead>
<tr>
<th>{% trans "Order code" %}</th>
<th>{% trans "User" %}</th>
<th>{% trans "Order total" %}</th>
<th>{% trans "Order date" %}</th>
<th>{% trans "Status" %}</th>
<th>{% trans "Order code" %} <a href="?{% url_replace request 'ordering' '-code'%}"><i class="fa fa-caret-down"></i></a>
<a href="?{% url_replace request 'ordering' 'code'%}"><i class="fa fa-caret-up"></i></a></th>
<th>{% trans "User" %} <a href="?{% url_replace request 'ordering' '-email'%}"><i class="fa fa-caret-down"></i></a>
<a href="?{% url_replace request 'ordering' 'email'%}"><i class="fa fa-caret-up"></i></a></th>
<th>{% trans "Order total" %} <a href="?{% url_replace request 'ordering' '-total'%}"><i class="fa fa-caret-down"></i></a>
<a href="?{% url_replace request 'ordering' 'total'%}"><i class="fa fa-caret-up"></i></a></th>
<th>{% trans "Order date" %} <a href="?{% url_replace request 'ordering' '-datetime'%}"><i class="fa fa-caret-down"></i></a>
<a href="?{% url_replace request 'ordering' 'datetime'%}"><i class="fa fa-caret-up"></i></a></th>
<th>{% trans "Status" %} <a href="?{% url_replace request 'ordering' '-status'%}"><i class="fa fa-caret-down"></i></a>
<a href="?{% url_replace request 'ordering' 'status'%}"><i class="fa fa-caret-up"></i></a></th>
</tr>
</thead>
<tbody>

View File

@@ -69,6 +69,12 @@ class OrderList(EventPermissionRequiredMixin, ListView):
if self.request.GET.get("provider", "") != "":
p = self.request.GET.get("provider", "")
qs = qs.filter(payment_provider=p)
if self.request.GET.get("ordering", "") != "":
p = self.request.GET.get("ordering", "")
p_admissable = ('-code', 'code', '-email', 'email', '-total', 'total', '-datetime', 'datetime', '-status', 'status')
if p in p_admissable:
qs = qs.order_by(p)
return qs.distinct()
def get_payment_providers(self):