Skip to content

Commit

Permalink
SIO-2331 Improve all submissions view
Browse files Browse the repository at this point in the history
Change-Id: If17643597ff5251497309714589729b172fc1398
  • Loading branch information
niewysoki committed Mar 23, 2020
1 parent a1438ce commit 39882f2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
33 changes: 33 additions & 0 deletions oioioi/base/static/js/admin-filter-collapse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
(function($) {
'use strict';
class FilterCollapse {
constructor(filterElement) {
this.init(filterElement);
this.bindHover();
this.bindToggle();
}

init(filterElement) {
this.$filterElement = $(filterElement);
this.$filterList = this.$filterElement.next('ul').hide();
}

bindToggle() {
let that = this;
this.$filterElement.click(function(){
that.$filterList.slideToggle();
});
}

bindHover() {
this.$filterElement.css('cursor', 'pointer');
}
}

$(document).ready(function() {
$('#changelist-filter').children('h3').each(function() {
// Initialization binds on click function to elements
new FilterCollapse(this);
});
});
})(django.jQuery);
11 changes: 9 additions & 2 deletions oioioi/contests/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ def lookups(self, request, model_admin):
.filter(contest=request.contest)
.values_list('problem__name', flat=True)))

return [(x, x) for x in p_names]
return sorted([(x, x) for x in p_names], key=lambda (s, _): s.lower())

def queryset(self, request, queryset):
if self.value():
Expand Down Expand Up @@ -502,7 +502,14 @@ def queryset(self, request, queryset):
class SubmissionAdmin(admin.ModelAdmin):
date_hierarchy = 'date'
actions = ['rejudge_action']
search_fields = ['user__username', 'user__last_name']
search_fields = ['user__username', 'user__last_name',
'problem_instance__problem__name', 'problem_instance__short_name']

class Media:
js = (
'admin/js/jquery.init.js',
'js/admin-filter-collapse.js'
)

# We're using functions instead of lists because we want to
# have different columns and filters depending on whether
Expand Down

0 comments on commit 39882f2

Please sign in to comment.