From 49750440463dfe28ee9dacbaa727244ceaa00fa9 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 24 Sep 2020 11:15:54 +0200 Subject: [PATCH] Update a team in a popup <3 --- apps/participation/forms.py | 8 +- apps/participation/models.py | 4 +- .../templates/participation/create_team.html | 2 +- .../participation/create_team_modal.html | 2 +- .../participation/join_team_modal.html | 2 +- .../templates/participation/team_detail.html | 19 +++- .../templates/participation/update_team.html | 15 +++ .../participation/update_team_modal.html | 21 +++++ apps/participation/urls.py | 3 +- apps/participation/views.py | 28 +++++- locale/fr/LC_MESSAGES/django.po | 92 ++++++++++--------- 11 files changed, 146 insertions(+), 50 deletions(-) create mode 100644 apps/participation/templates/participation/update_team.html create mode 100644 apps/participation/templates/participation/update_team_modal.html diff --git a/apps/participation/forms.py b/apps/participation/forms.py index 7217f7c..f49856c 100644 --- a/apps/participation/forms.py +++ b/apps/participation/forms.py @@ -4,7 +4,7 @@ from django import forms from django.core.exceptions import ValidationError from django.utils.translation import gettext_lazy as _ -from .models import Team +from .models import Team, Participation class TeamForm(forms.ModelForm): @@ -36,3 +36,9 @@ class JoinTeamForm(forms.ModelForm): class Meta: model = Team fields = ('access_code',) + + +class ParticipationForm(forms.ModelForm): + class Meta: + model = Participation + fields = ('problem',) diff --git a/apps/participation/models.py b/apps/participation/models.py index 70c07f6..8f3ac3b 100644 --- a/apps/participation/models.py +++ b/apps/participation/models.py @@ -2,6 +2,8 @@ from django.core.validators import RegexValidator from django.db import models from django.db.models import Index from django.utils.crypto import get_random_string +from django.utils.functional import lazy +from django.utils.text import format_lazy from django.utils.translation import gettext_lazy as _ @@ -56,7 +58,7 @@ class Participation(models.Model): ) problem = models.IntegerField( - choices=[(i, _("Problem #{problem:d}").format(problem=i)) for i in range(1, 5)], + choices=[(i, format_lazy(_("Problem #{problem:d}"), problem=i)) for i in range(1, 5)], null=True, default=None, verbose_name=_("problem number"), diff --git a/apps/participation/templates/participation/create_team.html b/apps/participation/templates/participation/create_team.html index 1be29f5..1c93537 100644 --- a/apps/participation/templates/participation/create_team.html +++ b/apps/participation/templates/participation/create_team.html @@ -10,4 +10,4 @@ -{% endblock content %} \ No newline at end of file +{% endblock content %} diff --git a/apps/participation/templates/participation/create_team_modal.html b/apps/participation/templates/participation/create_team_modal.html index 242c645..6163660 100644 --- a/apps/participation/templates/participation/create_team_modal.html +++ b/apps/participation/templates/participation/create_team_modal.html @@ -1,4 +1,4 @@ -{% load crispy_forms_filters i18n %} +{% load i18n %}