Skip to content

Commit c6493ad

Browse files
committed
Match I-D tracker search results better:
* Don't sort by ballot ID. * dictsort by filename within 'primary_flag' sets inside the template. * Change myifchanged to not reset on the first cycle of a for loop. * Introduce cyclevalue tag, to get the current cycle color from the cycle node itself instead of the context, since the context gets reset between for loops. - Legacy-Id: 596
1 parent 772a224 commit c6493ad

4 files changed

Lines changed: 32 additions & 7 deletions

File tree

ietf/idtracker/templatetags/myifchanged.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ def __init__(self, nodelist_true, nodelist_false, *varlist):
1616
self._varlist = varlist
1717

1818
def render(self, context):
19-
if context.has_key('forloop') and context['forloop']['first']:
20-
self._last_seen = None
19+
#if context.has_key('forloop') and context['forloop']['first']:
20+
# self._last_seen = None
2121
try:
2222
if self._varlist:
2323
# Consider multiple parameters.
@@ -81,3 +81,24 @@ def myifchanged(parser, token):
8181
nodelist_false = NodeList()
8282
return MyIfChangedNode(nodelist_true, nodelist_false, *bits[1:])
8383
myifchanged = register.tag(myifchanged)
84+
85+
86+
class CycleValueNode(Node):
87+
def __init__(self, cyclenode):
88+
self.cyclenode = cyclenode
89+
90+
def render(self, context):
91+
return self.cyclenode.cyclevars[self.cyclenode.counter % self.cyclenode.cyclevars_len]
92+
93+
def cyclevalue(parser, token):
94+
args = token.contents.split()
95+
if len(args) == 2:
96+
name = args[1]
97+
if not hasattr(parser, '_namedCycleNodes'):
98+
raise TemplateSyntaxError("No named cycles in template: '%s' is not defined" % name)
99+
if name not in parser._namedCycleNodes:
100+
raise TemplateSyntaxError("Named cycle '%s' does not exist" % name)
101+
return CycleValueNode(parser._namedCycleNodes[name])
102+
else:
103+
raise TemplateSyntaxError("Usage: cyclevalue cyclename")
104+
cyclevalue = register.tag(cyclevalue)

ietf/idtracker/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def search(request):
6565
if status != '':
6666
q_objs.append(Q(draft__status=status,rfc_flag=0))
6767
matches = IDInternal.objects.all().filter(*q_objs)
68-
matches = matches.order_by('cur_state', 'cur_sub_state', 'ballot', '-primary_flag')
68+
matches = matches.order_by('cur_state', 'cur_sub_state', '-primary_flag')
6969
#
7070
# Now search by I-D exists, if there could be any results.
7171
# If searching by job owner, current state or substate, there
@@ -80,7 +80,7 @@ def search(request):
8080
#'search_status_id': 'status',
8181
}
8282
q_objs = [Q(**{qdict[k]: args[k]}) for k in qdict.keys() if args.get(k, '') != '']
83-
idmatches = InternetDraft.objects.filter(*q_objs).exclude(id_document_tag__in=in_tracker).filter(status__status='Active')
83+
idmatches = InternetDraft.objects.filter(*q_objs).exclude(id_document_tag__in=in_tracker).filter(status__status='Active').order_by('filename')
8484
# resolve the queryset, append wrapper objects.
8585
matches = list(matches) + [DocumentWrapper(id) for id in idmatches]
8686
if not(args.get('search_filename', '') or args.get('search_status_id', 0)) and args.get('search_rfcnumber', 0):

ietf/templates/idtracker/search_result_row.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% load myifchanged %}
2-
<tr bgcolor="#{% myifchanged match.ballot_id %}{% cycle F8D6F8,E2AFE2 as ballotcolor %}{% else %}{% if match.synthetic %}{% cycle ballotcolor %}{% else %}{{ ballotcolor }}{% endif %}{% endmyifchanged %}">
2+
<tr bgcolor="#{% myifchanged match.ballot_id %}{% cycle F8D6F8,E2AFE2 as ballotcolor %}{% else %}{% if match.synthetic %}{% cycle ballotcolor %}{% else %}{% cyclevalue ballotcolor %}{% endif %}{% endmyifchanged %}">
33
{% if match.synthetic %}
44
<td>&nbsp;</td>
55
{% else %}

ietf/templates/idtracker/search_result_table.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
<h3>In State: <a href="/idtracker/states/{{ group.list.0.cur_state_id }}/">{{ group.list.0.cur_state }}</a>{% if group.list.0.cur_sub_state %} :: <a href="/idtracker/states/substate/{{ group.list.0.cur_sub_state_id }}/">{{ group.list.0.cur_sub_state }}</a>{% endif %}</h3>
33
<table bgcolor="#DFDFDF" cellspacing="0" cellpadding="0" border="0" width="800">
44
<tr bgcolor="#A3A3A3"><th>&nbsp;</th><th width="250">Name (Intended Status)</th><th>Ver</th><th>Responsible AD</th><th>Status Date</th><th>Modified (EST)</th></tr>
5-
{% for match in group.list %}
6-
{% include "idtracker/search_result_row.html" %}
5+
{# Same sort algorithm as I-D tracker #}
6+
{% regroup group.list by primary_flag as primaries %}
7+
{% for pgroup in primaries %}
8+
{% for match in pgroup.list|dictsort:"document.filename" %}
9+
{% include "idtracker/search_result_row.html" %}
10+
{% endfor %}
711
{% endfor %}
812
</table>
913
{% endfor %}

0 commit comments

Comments
 (0)