mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-07-03 18:02:50 +02:00
Add tweaks to update notes
This commit is contained in:
@ -380,7 +380,8 @@ class Pool(models.Model):
|
||||
return Solution.objects.filter(participation__in=self.participations, final_solution=self.tournament.final)
|
||||
|
||||
def average(self, participation):
|
||||
return sum(passage.average(participation) for passage in self.passages.all())
|
||||
return sum(passage.average(participation) for passage in self.passages.all()) \
|
||||
+ sum(tweak.diff for tweak in participation.tweaks.filter(pool=self).all())
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse_lazy("participation:pool_detail", args=(self.pk,))
|
||||
@ -514,6 +515,30 @@ class Passage(models.Model):
|
||||
verbose_name_plural = _("passages")
|
||||
|
||||
|
||||
class Tweak(models.Model):
|
||||
pool = models.ForeignKey(
|
||||
Pool,
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name=_("passage"),
|
||||
)
|
||||
|
||||
participation = models.ForeignKey(
|
||||
Participation,
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name=_("participation"),
|
||||
related_name='tweaks',
|
||||
)
|
||||
|
||||
diff = models.IntegerField(
|
||||
verbose_name=_("difference"),
|
||||
help_text=_("Score to add/remove on the final score"),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("tweak")
|
||||
verbose_name_plural = _("tweaks")
|
||||
|
||||
|
||||
def get_solution_filename(instance, filename):
|
||||
return f"solutions/{instance.participation.team.trigram}_{instance.problem}" \
|
||||
+ ("final" if instance.final_solution else "")
|
||||
|
Reference in New Issue
Block a user