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
This commit is contained in:
Bill Fenner 2007-06-21 19:07:40 +00:00
parent 772a2242ad
commit c6493ad8ab
4 changed files with 32 additions and 7 deletions

View file

@ -16,8 +16,8 @@ class MyIfChangedNode(Node):
self._varlist = varlist
def render(self, context):
if context.has_key('forloop') and context['forloop']['first']:
self._last_seen = None
#if context.has_key('forloop') and context['forloop']['first']:
# self._last_seen = None
try:
if self._varlist:
# Consider multiple parameters.
@ -81,3 +81,24 @@ def myifchanged(parser, token):
nodelist_false = NodeList()
return MyIfChangedNode(nodelist_true, nodelist_false, *bits[1:])
myifchanged = register.tag(myifchanged)
class CycleValueNode(Node):
def __init__(self, cyclenode):
self.cyclenode = cyclenode
def render(self, context):
return self.cyclenode.cyclevars[self.cyclenode.counter % self.cyclenode.cyclevars_len]
def cyclevalue(parser, token):
args = token.contents.split()
if len(args) == 2:
name = args[1]
if not hasattr(parser, '_namedCycleNodes'):
raise TemplateSyntaxError("No named cycles in template: '%s' is not defined" % name)
if name not in parser._namedCycleNodes:
raise TemplateSyntaxError("Named cycle '%s' does not exist" % name)
return CycleValueNode(parser._namedCycleNodes[name])
else:
raise TemplateSyntaxError("Usage: cyclevalue cyclename")
cyclevalue = register.tag(cyclevalue)

View file

@ -65,7 +65,7 @@ def search(request):
if status != '':
q_objs.append(Q(draft__status=status,rfc_flag=0))
matches = IDInternal.objects.all().filter(*q_objs)
matches = matches.order_by('cur_state', 'cur_sub_state', 'ballot', '-primary_flag')
matches = matches.order_by('cur_state', 'cur_sub_state', '-primary_flag')
#
# Now search by I-D exists, if there could be any results.
# If searching by job owner, current state or substate, there
@ -80,7 +80,7 @@ def search(request):
#'search_status_id': 'status',
}
q_objs = [Q(**{qdict[k]: args[k]}) for k in qdict.keys() if args.get(k, '') != '']
idmatches = InternetDraft.objects.filter(*q_objs).exclude(id_document_tag__in=in_tracker).filter(status__status='Active')
idmatches = InternetDraft.objects.filter(*q_objs).exclude(id_document_tag__in=in_tracker).filter(status__status='Active').order_by('filename')
# resolve the queryset, append wrapper objects.
matches = list(matches) + [DocumentWrapper(id) for id in idmatches]
if not(args.get('search_filename', '') or args.get('search_status_id', 0)) and args.get('search_rfcnumber', 0):

View file

@ -1,5 +1,5 @@
{% load myifchanged %}
<tr bgcolor="#{% myifchanged match.ballot_id %}{% cycle F8D6F8,E2AFE2 as ballotcolor %}{% else %}{% if match.synthetic %}{% cycle ballotcolor %}{% else %}{{ ballotcolor }}{% endif %}{% endmyifchanged %}">
<tr bgcolor="#{% myifchanged match.ballot_id %}{% cycle F8D6F8,E2AFE2 as ballotcolor %}{% else %}{% if match.synthetic %}{% cycle ballotcolor %}{% else %}{% cyclevalue ballotcolor %}{% endif %}{% endmyifchanged %}">
{% if match.synthetic %}
<td>&nbsp;</td>
{% else %}

View file

@ -2,8 +2,12 @@
<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>
<table bgcolor="#DFDFDF" cellspacing="0" cellpadding="0" border="0" width="800">
<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>
{% for match in group.list %}
{% include "idtracker/search_result_row.html" %}
{# Same sort algorithm as I-D tracker #}
{% regroup group.list by primary_flag as primaries %}
{% for pgroup in primaries %}
{% for match in pgroup.list|dictsort:"document.filename" %}
{% include "idtracker/search_result_row.html" %}
{% endfor %}
{% endfor %}
</table>
{% endfor %}