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:
@ -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="",
|
||||
|
Reference in New Issue
Block a user