status = forms.ChoiceField(required=False)
author = forms.ChoiceField(required=False)
reviewer = forms.ChoiceField(required=False)
+ sortkey = forms.IntegerField(required=False)
def __init__(self, cf, *args, **kwargs):
super(CommitFestFilterForm, self).__init__(*args, **kwargs)
+ self.fields['sortkey'].widget = forms.HiddenInput()
+
c = [(-1, '* All')] + list(PatchOnCommitFest._STATUS_CHOICES)
self.fields['status'] = forms.ChoiceField(choices=c, required=False)
<table class="table table-condensed">
<thead>
<tr>
-{%for f in form%}
+{%for f in form%}{%if not f.is_hidden%}
<td>{{f.label}}</td>
-{%endfor%}
+{%endif%}{%endfor%}
<td></td>
</tr>
</thead>
<table class="table table-striped table-bordered table-hover table-condensed">
<thead>
<tr>
- <th>Patch</th>
+ <th>{%if p.is_open%}<a href="#" style="color:#333333;" onclick="return sortpatches(0);">Patch</a>{%if sortkey = 0%}<div style="float:right;"><i class="icon-arrow-down"></i></div>{%endif%}{%endif%}</th>
<th>Status</th>
<th>Author</th>
<th>Reviewers</th>
- <th>Latest activity</th>
- <th>Latest mail</th>
+ <th>{%if p.is_open%}<a href="#" style="color:#333333;" onclick="return sortpatches(1);">Latest activity</a>{%if sortkey = 1%}<div style="float:right;"><i class="icon-arrow-down"></i></div>{%endif%}{%else%}Latest activity{%endif%}</th>
+ <th>{%if p.is_open%}<a href="#" style="color:#333333;" onclick="return sortpatches(2);">Latest mail</a>{%if sortkey = 2%}<div style="float:right;"><i class="icon-arrow-down"></i></div>{%endif%}{%else%}Latest mail{%endif%}</th>
</tr>
</thead>
<tbody>
{%endifchanged%}
+{%if grouping%}
{%ifchanged p.topic%}
<tr><th colspan="6">{{p.topic}}</th></tr>
{%endifchanged%}
+{%endif%}
<tr>
<td><a href="{{p.id}}/">{{p}}</a></td>
<td><span class="label">{{p.status|patchstatusstring}}</span></td>
if request.GET.has_key('text') and request.GET['text'] != '':
q = q & Q(name__icontains=request.GET['text'])
- # Not sure if this is correct?
has_filter = len(q.children) > 0
- if not has_filter and request.GET:
+
+ # Figure out custom ordering
+ ordering = ['-is_open', 'topic__topic', 'created',]
+ if request.GET.has_key('sortkey'):
+ sortkey=int(request.GET['sortkey'])
+ if sortkey==1:
+ ordering = ['-is_open', 'modified', 'created',]
+ elif sortkey==2:
+ ordering = ['-is_open', 'lastmail', 'created',]
+ else:
+ sortkey=0
+ else:
+ sortkey = 0
+
+ if not has_filter and sortkey==0 and request.GET:
# Redirect to get rid of the ugly url
return HttpResponseRedirect('/%s/' % cf.id)
'author_names':"SELECT string_agg(first_name || ' ' || last_name || ' (' || username || ')', ', ') FROM auth_user INNER JOIN commitfest_patch_authors cpa ON cpa.user_id=auth_user.id WHERE cpa.patch_id=commitfest_patch.id",
'reviewer_names':"SELECT string_agg(first_name || ' ' || last_name || ' (' || username || ')', ', ') FROM auth_user INNER JOIN commitfest_patch_reviewers cpr ON cpr.user_id=auth_user.id WHERE cpr.patch_id=commitfest_patch.id",
'is_open':'commitfest_patchoncommitfest.status IN (%s)' % ','.join([str(x) for x in PatchOnCommitFest.OPEN_STATUSES]),
- }).order_by('-is_open', 'topic__topic', 'created')
+ }).order_by(*ordering)
# Generates a fairly expensive query, which we shouldn't do unless
# the user is logged in. XXX: Figure out how to avoid doing that..
'patches': patches,
'has_filter': has_filter,
'title': 'Commitfest %s' % cf.name,
+ 'grouping': sortkey==0,
+ 'sortkey': sortkey,
}, context_instance=RequestContext(request))
def patch(request, cfid, patchid):