Skip to content

Commit 8f49548

Browse files
committed
removed sortorder field; multiple fields can be sorted together now
1 parent 910d9d0 commit 8f49548

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

media/commitfest/js/commitfest.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -257,17 +257,13 @@ function flagCommitted(committer) {
257257
}
258258

259259
function sortpatches(sortby) {
260-
if ($('#id_sortkey').val() == sortby) {
261-
if($('#id_sortorder').val() == 1){
262-
$('#id_sortkey').val(0);
263-
$('#id_sortorder').val(0); // reset order
264-
}else if($('#id_sortorder').val() == -1){
265-
$('#id_sortkey').val(sortby);
266-
$('#id_sortorder').val(1); // ascending order -> oldest first
267-
}
260+
let sortkey = $('#id_sortkey').val()
261+
if (sortkey == sortby) {
262+
$('#id_sortkey').val(-sortby)
263+
} else if(-sortkey == sortby){
264+
$('#id_sortkey').val(0)
268265
} else {
269266
$('#id_sortkey').val(sortby);
270-
$('#id_sortorder').val(-1); // descending order -> latest first
271267
}
272268
$('#filterform').submit();
273269

pgcommitfest/commitfest/forms.py

-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ class CommitFestFilterForm(forms.Form):
1717
author = forms.ChoiceField(required=False)
1818
reviewer = forms.ChoiceField(required=False)
1919
sortkey = forms.IntegerField(required=False)
20-
sortorder = forms.IntegerField(required=False) # 0 -> no order, 1 -> asc, -1 -> desc
2120

2221
def __init__(self, cf, *args, **kwargs):
2322
super(CommitFestFilterForm, self).__init__(*args, **kwargs)
2423

2524
self.fields["sortkey"].widget = forms.HiddenInput()
26-
self.fields["sortorder"].widget = forms.HiddenInput()
2725

2826
c = [(-1, "* All")] + list(PatchOnCommitFest._STATUS_CHOICES)
2927
self.fields["status"] = forms.ChoiceField(choices=c, required=False)

pgcommitfest/commitfest/views.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -242,30 +242,39 @@ def commitfest(request, cfid):
242242

243243
if sortkey == 1:
244244
orderby_str = "modified, created"
245+
elif sortkey == -1:
246+
orderby_str = "modified DESC, created DESC"
245247
elif sortkey == 2:
246248
orderby_str = "lastmail, created"
249+
elif sortkey == -2:
250+
orderby_str = "lastmail DESC, created DESC"
247251
elif sortkey == 3:
248252
orderby_str = "num_cfs DESC, modified, created"
253+
elif sortkey == -3:
254+
orderby_str = "num_cfs ASC, modified DESC, created DESC"
249255
elif sortkey == 4:
250256
orderby_str = "p.id"
257+
elif sortkey == -4:
258+
orderby_str = "p.id DESC"
251259
elif sortkey == 5:
252260
orderby_str = "p.name, created"
261+
elif sortkey == -5:
262+
orderby_str = "p.name DESC, created DESC"
253263
elif sortkey == 6:
254264
orderby_str = (
255265
"branch.all_additions + branch.all_deletions NULLS LAST, created"
256266
)
267+
elif sortkey == -6:
268+
orderby_str = (
269+
"branch.all_additions + branch.all_deletions DESC NULLS LAST, created"
270+
)
257271
else:
258272
orderby_str = "p.id"
259273
sortkey = 0
260274
else:
261275
orderby_str = "topic, created"
262276
sortkey = 0
263277

264-
sortorder = int(request.GET.get("sortorder", "0"))
265-
if sortorder == 1:
266-
orderby_str += " ASC"
267-
elif sortorder == -1:
268-
orderby_str += " DESC"
269278

270279
if not has_filter and sortkey == 0 and request.GET:
271280
# Redirect to get rid of the ugly url
@@ -353,7 +362,6 @@ def commitfest(request, cfid):
353362
"title": cf.title,
354363
"grouping": sortkey == 0,
355364
"sortkey": sortkey,
356-
"sortorder": sortorder,
357365
"openpatchids": [p["id"] for p in patches if p["is_open"]],
358366
"header_activity": "Activity log",
359367
"header_activity_link": "activity/",

0 commit comments

Comments
 (0)