1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-07-04 10:52:14 +02:00

Upload to the good place

This commit is contained in:
Yohann D'ANELLO
2021-01-12 17:51:55 +01:00
parent 2ca0444053
commit ead59e28b8
4 changed files with 20 additions and 13 deletions

View File

@ -312,6 +312,15 @@ class Pool(models.Model):
verbose_name_plural = _("pools")
def get_solution_filename(instance, filename):
return f"solutions/{instance.participation.team.trigram}_{instance.problem}" \
+ ("final" if instance.final_solution else "")
def get_random_synthesis_filename(instance, filename):
return "syntheses/" + get_random_string(64)
class Solution(models.Model):
participation = models.ForeignKey(
Participation,
@ -331,14 +340,15 @@ class Solution(models.Model):
file = models.FileField(
verbose_name=_("file"),
upload_to="solutions/",
upload_to=get_solution_filename,
unique=True,
blank=True,
default="",
)
def __str__(self):
return repr(self)
return _("Solution of team {team} for problem {problem}")\
.format(team=self.participation.team.name, problem=self.problem)
class Meta:
verbose_name = _("solution")
@ -369,7 +379,7 @@ class Synthesis(models.Model):
file = models.FileField(
verbose_name=_("file"),
upload_to="syntheses/",
upload_to=get_random_synthesis_filename,
unique=True,
blank=True,
default="",