From 0b6031eef7629b1b179d07174fa42cad065116cc Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Sun, 12 Jun 2022 13:52:02 +0700 Subject: [PATCH] Update admin page --- judge/admin/problem.py | 29 ----------------------------- judge/models/__init__.py | 1 + 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/judge/admin/problem.py b/judge/admin/problem.py index c687655..88d260b 100644 --- a/judge/admin/problem.py +++ b/judge/admin/problem.py @@ -1,5 +1,4 @@ from operator import attrgetter -import statistics from django import forms from django.contrib import admin @@ -197,10 +196,6 @@ class ProblemAdmin(CompareVersionAdmin): "name", "show_authors", "points", - "vote_cnt", - "vote_mean", - "vote_median", - "vote_std", "is_public", "show_public", ] @@ -295,11 +290,6 @@ class ProblemAdmin(CompareVersionAdmin): def get_queryset(self, request): queryset = Problem.objects.prefetch_related("authors__user") - queryset = queryset.annotate( - _vote_mean=Avg("problem_points_votes__points"), - _vote_std=StdDev("problem_points_votes__points"), - _vote_cnt=Count("problem_points_votes__points"), - ) if request.user.has_perm("judge.edit_all_problem"): return queryset @@ -347,25 +337,6 @@ class ProblemAdmin(CompareVersionAdmin): request, form, *args, **kwargs ) - def vote_mean(self, obj): - return round(obj._vote_mean, 1) if obj._vote_mean is not None else None - - vote_mean.admin_order_field = "_vote_mean" - - def vote_std(self, obj): - return round(obj._vote_std, 1) if obj._vote_std is not None else None - - vote_std.admin_order_field = "_vote_std" - - def vote_cnt(self, obj): - return obj._vote_cnt - - vote_cnt.admin_order_field = "_vote_cnt" - - def vote_median(self, obj): - votes = obj.problem_points_votes.values_list("points", flat=True) - return statistics.median(votes) if votes else None - class ProblemPointsVoteAdmin(admin.ModelAdmin): list_display = ( diff --git a/judge/models/__init__.py b/judge/models/__init__.py index 8eaf102..a8232da 100644 --- a/judge/models/__init__.py +++ b/judge/models/__init__.py @@ -69,4 +69,5 @@ revisions.register(ProblemData) revisions.register(ProblemTestCase) revisions.register(ContestParticipation) revisions.register(Rating) +revisions.register(VolunteerProblemVote) del revisions