Files are required for solutions and syntheses

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
Yohann D'ANELLO 2022-04-29 18:53:34 +02:00
parent c686584e74
commit 5f2cd16071
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
3 changed files with 25 additions and 5 deletions

View File

@ -0,0 +1,24 @@
# Generated by Django 3.2.13 on 2022-04-29 16:53
from django.db import migrations, models
import participation.models
class Migration(migrations.Migration):
dependencies = [
('participation', '0007_remove_passage_place'),
]
operations = [
migrations.AlterField(
model_name='solution',
name='file',
field=models.FileField(unique=True, upload_to=participation.models.get_solution_filename, verbose_name='file'),
),
migrations.AlterField(
model_name='synthesis',
name='file',
field=models.FileField(unique=True, upload_to=participation.models.get_synthesis_filename, verbose_name='file'),
),
]

View File

@ -547,8 +547,6 @@ class Solution(models.Model):
verbose_name=_("file"), verbose_name=_("file"),
upload_to=get_solution_filename, upload_to=get_solution_filename,
unique=True, unique=True,
blank=True,
default="",
) )
def __str__(self): def __str__(self):
@ -588,8 +586,6 @@ class Synthesis(models.Model):
verbose_name=_("file"), verbose_name=_("file"),
upload_to=get_synthesis_filename, upload_to=get_synthesis_filename,
unique=True, unique=True,
blank=True,
default="",
) )
def __str__(self): def __str__(self):

View File

@ -751,7 +751,7 @@ class PassageDetailView(LoginRequiredMixin, DetailView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
if self.request.user.registration in self.object.pool.juries.all(): if self.request.user.registration in self.object.pool.juries.all():
context["my_note"] = Note.objects.get(passage=self.object, jury=self.request.user.registration) context["my_note"] = Note.objects.get_or_create(passage=self.object, jury=self.request.user.registration)[0]
context["notes"] = NoteTable([note for note in self.object.notes.all() if note]) context["notes"] = NoteTable([note for note in self.object.notes.all() if note])
elif self.request.user.registration.is_admin: elif self.request.user.registration.is_admin:
context["notes"] = NoteTable([note for note in self.object.notes.all() if note]) context["notes"] = NoteTable([note for note in self.object.notes.all() if note])