From 01a6e28623a473ee24bdadc618677dbf5bc37545 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sat, 23 Jan 2021 13:41:43 +0100 Subject: [PATCH 1/5] Fix matrix avatar --- .../participation/management/commands/fix_matrix_channels.py | 5 ++++- tfjm/matrix.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/participation/management/commands/fix_matrix_channels.py b/apps/participation/management/commands/fix_matrix_channels.py index 4be6bb6..9213e9f 100644 --- a/apps/participation/management/commands/fix_matrix_channels.py +++ b/apps/participation/management/commands/fix_matrix_channels.py @@ -23,7 +23,10 @@ class Command(BaseCommand): else: # pragma: no cover if not os.path.isfile(".matrix_avatar"): avatar_uri = Matrix.get_avatar() - if not isinstance(avatar_uri, str): + if isinstance(avatar_uri, str): + with open(".matrix_avatar", "w") as f: + f.write(avatar_uri) + else: stat_file = os.stat("tfjm/static/logo.png") with open("tfjm/static/logo.png", "rb") as f: resp = Matrix.upload(f, filename="logo.png", content_type="image/png", diff --git a/tfjm/matrix.py b/tfjm/matrix.py index 20732d6..3d7e48d 100644 --- a/tfjm/matrix.py +++ b/tfjm/matrix.py @@ -76,7 +76,7 @@ class Matrix: """ client = await cls._get_client() resp = await client.get_avatar() - return resp.avatar_url if resp.status_code == 200 else resp + return resp.avatar_url if hasattr(resp, "avatar_url") else resp @classmethod @async_to_sync From d9a2b3160672948a65c2ff723b00f3b46069ef07 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sat, 23 Jan 2021 13:43:31 +0100 Subject: [PATCH 2/5] Django filters was missing --- tfjm/settings.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tfjm/settings.py b/tfjm/settings.py index 76f5f9b..0b13ce4 100644 --- a/tfjm/settings.py +++ b/tfjm/settings.py @@ -56,6 +56,7 @@ INSTALLED_APPS = [ 'address', 'bootstrap_datepicker_plus', 'crispy_forms', + 'django_filters', 'django_tables2', 'haystack', 'logs', From b5136ffa915f94d18408ac0adf90872c1b9b6a1c Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sat, 23 Jan 2021 14:26:15 +0100 Subject: [PATCH 3/5] A motivation letter must be a PDF/JPEG/PNG file (it didn't work) --- apps/participation/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/participation/forms.py b/apps/participation/forms.py index f80fefe..de77aba 100644 --- a/apps/participation/forms.py +++ b/apps/participation/forms.py @@ -61,7 +61,7 @@ class ParticipationForm(forms.ModelForm): class MotivationLetterForm(forms.ModelForm): def clean_file(self): - if "file" in self.files: + if "motivation_letter" in self.files: file = self.files["motivation_letter"] if file.size > 2e6: raise ValidationError(_("The uploaded file size must be under 2 Mo.")) From a0266c691b7ea6a12974611d8fe8986a50dd33f5 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sat, 23 Jan 2021 14:27:21 +0100 Subject: [PATCH 4/5] Coaches have no health sheet --- apps/participation/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/participation/views.py b/apps/participation/views.py index afafbc7..235441f 100644 --- a/apps/participation/views.py +++ b/apps/participation/views.py @@ -391,7 +391,7 @@ class TeamAuthorizationsView(LoginRequiredMixin, DetailView): _("Parental authorization of {participant}.{ext}") .format(participant=str(participant), ext=ext)) - if participant.health_sheet: + if isinstance(participant, StudentRegistration) and participant.health_sheet: mime_type = magic.from_file("media/" + participant.health_sheet.name) ext = mime_type.split("/")[1].replace("jpeg", "jpg") zf.write("media/" + participant.health_sheet.name, From 4dd3c105fe1ba23f357cc87fbbba27c2db773d5a Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sat, 23 Jan 2021 14:30:00 +0100 Subject: [PATCH 5/5] Only consider a participant as a child if it is not 18 on the beginning of the tournament --- apps/registration/models.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/registration/models.py b/apps/registration/models.py index 3e12fce..3a603f8 100644 --- a/apps/registration/models.py +++ b/apps/registration/models.py @@ -159,7 +159,13 @@ class ParticipantRegistration(Registration): @property def under_18(self): - return (timezone.now().date() - self.birth_date).days < 18 * 365.24 + important_date = timezone.now().date() + if self.team and self.team.participation.tournament: + important_date = self.team.participation.tournament.date_start + if self.team.participation.final: + from participation.models import Tournament + important_date = Tournament.final_tournament().date_start + return (important_date - self.birth_date).days < 18 * 365.24 @property def type(self): # pragma: no cover