NDOJ/judge/admin/volunteer.py

35 lines
986 B
Python
Raw Normal View History

2022-05-03 02:44:14 +00:00
from django.contrib import admin
from django.utils.html import format_html
from django.urls import reverse
from django.utils.translation import gettext, gettext_lazy as _, ungettext
from judge.models import VolunteerProblemVote
2022-05-14 17:57:27 +00:00
2022-05-03 02:44:14 +00:00
class VolunteerProblemVoteAdmin(admin.ModelAdmin):
2022-05-14 17:57:27 +00:00
fields = (
"voter",
"problem",
"time",
"thinking_points",
"knowledge_points",
"feedback",
)
readonly_fields = ("time", "problem", "voter")
list_display = (
"voter",
"problem_link",
"time",
"thinking_points",
"knowledge_points",
"feedback",
)
date_hierarchy = "time"
2022-05-03 02:44:14 +00:00
def problem_link(self, obj):
2022-05-14 17:57:27 +00:00
url = reverse("admin:judge_problem_change", args=(obj.problem.id,))
2022-05-03 02:44:14 +00:00
return format_html(f"<a href='{url}'>{obj.problem.code}</a>")
2022-05-14 17:57:27 +00:00
problem_link.short_description = _("Problem")
problem_link.admin_order_field = "problem__code"