Add sorting to liaison list view. Fixes

- Legacy-Id: 2543
This commit is contained in:
Emilio A. Sánchez López 2010-10-07 11:31:55 +00:00
parent a9cab1ea36
commit 895b8950eb
5 changed files with 55 additions and 3 deletions

View file

@ -96,7 +96,22 @@ def liaison_list(request):
approval_codes = IETFHM.get_all_can_approve_codes(person)
can_approve = LiaisonDetail.objects.filter(approval__isnull=False, approval__approved=False, from_raw_code__in=approval_codes).count()
public_liaisons = LiaisonDetail.objects.filter(Q(approval__isnull=True)|Q(approval__approved=True)).order_by("-submitted_date")
order = request.GET.get('order_by', 'submitted_date')
plain_order = order
reverse_order = order.startswith('-')
if reverse_order:
plain_order = order[1:]
if plain_order not in ('submitted_date', 'deadline_date', 'title', 'to_body', 'from_raw_body'):
order = 'submitted_date'
reverse_order = True
plain_order = 'submitted_date'
elif plain_order in ('submitted_date', 'deadline_date'):
# Reverse order for date fields, humans find it more natural
if reverse_order:
order = plain_order
else:
order = '-%s' % plain_order
public_liaisons = LiaisonDetail.objects.filter(Q(approval__isnull=True)|Q(approval__approved=True)).order_by(order)
return object_list(request, public_liaisons,
allow_empty=True,
@ -105,7 +120,8 @@ def liaison_list(request):
'can_approve': can_approve,
'can_edit': can_edit,
'can_send_incoming': can_send_incoming,
'can_send_outgoing': can_send_outgoing},
'can_send_outgoing': can_send_outgoing,
plain_order: not reverse_order and '-' or None},
)

View file

@ -3,6 +3,7 @@
{% block title %}Liaison Statements{% endblock %}
{% block pagehead %}
<link rel="stylesheet" type="text/css" href="/css/liaisons.css"></link>
<link rel="alternate" type="application/atom+xml" href="/feed/liaison/recent/" />
{% endblock %}
@ -23,7 +24,23 @@
{% endblock %}
<table class="ietf-table" width="100%">
<tr><th width="9%">Date</th><th width="20%">From</th><th width="20%">To</th><th width="50%">Title</th></tr>
<tr>
<th width="9%" class="orderField orderField{{ submitted_date|yesno:"Active,Inactive,Reversed" }}">
<a href="?order_by={{ submitted_date|default_if_none:"" }}submitted_date">Date</a>
</th>
<th width="15%" class="orderField orderField{{ from_raw_body|yesno:"Active,Inactive,Reversed" }}">
<a href="?order_by={{ from_raw_body|default_if_none:"" }}from_raw_body">From</a>
</th>
<th width="15%" class="orderField orderField{{ to_body|yesno:"Active,Inactive,Reversed" }}">
<a href="?order_by={{ to_body|default_if_none:"" }}to_body">To</a>
</th>
<th width="9%" class="orderField orderField{{ deadline_date|yesno:"Active,Inactive,Reversed" }}">
<a href="?order_by={{ deadline_date|default_if_none:"" }}deadline_date">Deadline</a>
</th>
<th width="50%" class="orderField orderField{{ title|yesno:"Active,Inactive,Reversed" }}">
<a href="?order_by={{ title|default_if_none:"" }}title">Title</a>
</th>
</tr>
{% for liaison in object_list %}
<tr class="{% cycle oddrow,evenrow %}">
@ -40,6 +57,9 @@
{{ liaison.to_body|escape }}
{% endif %}
</td>
<td>
{{ liaison.deadline_date|default:"--" }}
</td>
<td>
{% if liaison.by_secretariat %}
{% for file in liaison.uploads_set.all %}

View file

@ -93,3 +93,19 @@ span.fieldRequired {
font-size: 1.2em;
background-color: #ffdd88;
}
th.orderField a {
text-decoration: none;
color: white;
display: block;
}
th.orderFieldReversed a {
background: #2647A0 url(/images/arrow-down.gif) no-repeat left center;
padding-left: 20px;
}
th.orderFieldActive a {
background: #2647A0 url(/images/arrow-up.gif) no-repeat left center;
padding-left: 20px;
}

Binary file not shown.

After

(image error) Size: 80 B

BIN
static/images/arrow-up.gif Normal file

Binary file not shown.

After

(image error) Size: 79 B