Update problem vote

This commit is contained in:
cuom1999 2022-03-10 11:27:52 -06:00
parent 2e3a45168e
commit 573fb7a954
2 changed files with 19 additions and 7 deletions

View file

@ -239,14 +239,26 @@ class ProblemAdmin(VersionAdmin):
class ProblemPointsVoteAdmin(admin.ModelAdmin):
list_display = ('points', 'voter', 'problem', 'vote_time')
search_fields = ('voter', 'problem')
readonly_fields = ('voter', 'problem', 'vote_time')
list_display = ('points', 'voter', 'problem', 'problem_code', 'problem_points', 'vote_time')
search_fields = ('voter__user__username', 'problem__code',)
readonly_fields = ('voter', 'problem', 'problem_code', 'problem_points', 'vote_time')
def has_change_permission(self, request, obj=None):
if obj is None:
return request.user.has_perm('judge.edit_own_problem')
return obj.problem.is_editable_by(request.user)
def lookup_allowed(self, key, value):
return super().lookup_allowed(key, value) or key in ('problem__code',)
# def lookup_allowed(self, key, value):
# return key in ('problem')
def problem_code(self, obj):
return obj.problem.code
problem_code.short_description = 'Problem Code'
problem_code.admin_order_field = 'problem__code'
def problem_points(self, obj):
return obj.problem.points
problem_points.short_description = 'Problem Points'
problem_points.admin_order_field = 'problem__points'

View file

@ -35,8 +35,8 @@
<span>{{_('This helps us improve the site')}}</span>
</td>
<td>
<span style="padding-left: 0.2em"><b>{{_('Easy')}}</b></span>
<span style="float: right; padding-right: 0.2em"><b>{{_('Hard')}}</b></span>
<span style="padding-left: 0.2em"><b>{{min_possible_vote}}</b></span>
<span style="float: right; padding-right: 0.2em"><b>{{max_possible_vote}}</b></span>
</td>
</tr>
</tbody>