Fix send solution error

This commit is contained in:
Yohann D'ANELLO 2020-05-05 22:29:10 +02:00
parent 4ce767d451
commit 75d8ec2265
2 changed files with 15 additions and 7 deletions

View File

@ -224,6 +224,10 @@ class SolutionsView(TeamMixin, BaseFormView, SingleTableView):
return super().post(request, *args, **kwargs)
def get_context_data(self, **kwargs):
self.object_list = self.get_queryset()
return super().get_context_data(**kwargs)
def get_queryset(self):
qs = super().get_queryset()
if not self.request.user.admin:
@ -236,7 +240,7 @@ class SolutionsView(TeamMixin, BaseFormView, SingleTableView):
solution.final = solution.team.selected_for_final
if timezone.now() > solution.tournament.date_solutions:
form.add_error('file', _("You can't publish your solution anymore. Deadline: {date:%m-%d-%Y %h:%M}.")
form.add_error('file', _("You can't publish your solution anymore. Deadline: {date:%m-%d-%Y %H:%M}.")
.format(date=solution.tournament.date_solutions))
return super().form_invalid(form)
@ -334,6 +338,10 @@ class SynthesesView(TeamMixin, BaseFormView, SingleTableView):
return qs.order_by('team__tournament__date_start', 'team__tournament__name', 'team__trigram', 'round',
'source',)
def get_context_data(self, **kwargs):
self.object_list = self.get_queryset()
return super().get_context_data(**kwargs)
def form_valid(self, form):
synthesis = form.instance
synthesis.team = self.request.user.team
@ -341,13 +349,13 @@ class SynthesesView(TeamMixin, BaseFormView, SingleTableView):
if synthesis.round == '1' and timezone.now() > synthesis.tournament.date_syntheses:
form.add_error('file', _("You can't publish your synthesis anymore for the first round."
" Deadline: {date:%m-%d-%Y %h:%M}.")
" Deadline: {date:%m-%d-%Y %H:%M}.")
.format(date=synthesis.tournament.date_syntheses))
return super().form_invalid(form)
if synthesis.round == '2' and timezone.now() > synthesis.tournament.date_syntheses_2:
form.add_error('file', _("You can't publish your synthesis anymore for the second round."
" Deadline: {date:%m-%d-%Y %h:%M}.")
" Deadline: {date:%m-%d-%Y %H:%M}.")
.format(date=synthesis.tournament.date_syntheses_2))
return super().form_invalid(form)

View File

@ -610,9 +610,9 @@ msgstr "Solutions"
#: apps/tournament/views.py:239
msgid ""
"You can't publish your solution anymore. Deadline: {date:%m-%d-%Y %h:%M}."
"You can't publish your solution anymore. Deadline: {date:%m-%d-%Y %H:%M}."
msgstr ""
"Vous ne pouvez plus publier vos solutions. Deadline : {date:%d/%m/%Y %h:%M}."
"Vous ne pouvez plus publier vos solutions. Deadline : {date:%d/%m/%Y %H:%M}."
#: apps/tournament/views.py:263
msgid "All solutions"
@ -636,7 +636,7 @@ msgstr "Notes de synthèse de l'équipe {team}.zip"
#: apps/tournament/views.py:343
msgid ""
"You can't publish your synthesis anymore for the first round. Deadline: "
"{date:%m-%d-%Y %h:%M}."
"{date:%m-%d-%Y %H:%M}."
msgstr ""
"Vous ne pouvez plus envoyer vos notes de synthèse pour le premier tour. "
"Deadline : {date:%d/%m/%Y %h:%M}."
@ -644,7 +644,7 @@ msgstr ""
#: apps/tournament/views.py:349
msgid ""
"You can't publish your synthesis anymore for the second round. Deadline: "
"{date:%m-%d-%Y %h:%M}."
"{date:%m-%d-%Y %H:%M}."
msgstr ""
"Vous ne pouvez plus envoyer vos notes de synthèse pour le second tour. "
"Deadline : {date:%d/%m/%Y %h:%M}."