NDOJ/judge/models/volunteer.py

40 lines
1.4 KiB
Python
Raw Permalink Normal View History

2022-05-03 02:44:14 +00:00
from django.db import models
from django.db.models import CASCADE
from django.utils.translation import gettext_lazy as _
from judge.models import Profile, Problem, ProblemType
2022-05-14 17:57:27 +00:00
__all__ = ["VolunteerProblemVote"]
2022-05-03 02:44:14 +00:00
class VolunteerProblemVote(models.Model):
2022-05-14 17:57:27 +00:00
voter = models.ForeignKey(
Profile, related_name="volunteer_problem_votes", on_delete=CASCADE
)
problem = models.ForeignKey(
Problem, related_name="volunteer_user_votes", on_delete=CASCADE
)
2022-05-03 02:44:14 +00:00
time = models.DateTimeField(auto_now_add=True)
2022-05-14 17:57:27 +00:00
knowledge_points = models.PositiveIntegerField(
verbose_name=_("knowledge points"),
help_text=_("Points awarded by knowledge difficulty"),
)
thinking_points = models.PositiveIntegerField(
verbose_name=_("thinking points"),
help_text=_("Points awarded by thinking difficulty"),
)
types = models.ManyToManyField(
ProblemType,
verbose_name=_("problem types"),
help_text=_("The type of problem, " "as shown on the problem's page."),
)
feedback = models.TextField(verbose_name=_("feedback"), blank=True)
2022-05-03 02:44:14 +00:00
class Meta:
2022-05-14 17:57:27 +00:00
verbose_name = _("volunteer vote")
verbose_name_plural = _("volunteer votes")
unique_together = ["voter", "problem"]
2022-05-03 02:44:14 +00:00
def __str__(self):
2022-05-14 17:57:27 +00:00
return f"{self.voter} for {self.problem.code}"