diff --git a/participation/forms.py b/participation/forms.py index 48ed414..caec0c2 100644 --- a/participation/forms.py +++ b/participation/forms.py @@ -128,10 +128,12 @@ class ValidateParticipationForm(forms.Form): class TournamentForm(forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - if settings.TFJM_APP != "ETEAM": + if settings.NB_ROUNDS < 3: del self.fields['date_third_phase'] del self.fields['solutions_available_third_phase'] del self.fields['syntheses_third_phase_limit'] + if not settings.PAYMENT_MANAGEMENT: + del self.fields['price'] class Meta: model = Tournament diff --git a/participation/management/commands/fix_sympa_lists.py b/participation/management/commands/fix_sympa_lists.py index afa8649..8dd4681 100644 --- a/participation/management/commands/fix_sympa_lists.py +++ b/participation/management/commands/fix_sympa_lists.py @@ -1,6 +1,6 @@ # Copyright (C) 2020 by Animath # SPDX-License-Identifier: GPL-3.0-or-later - +from django.conf import settings from django.core.management import BaseCommand from django.db.models import Q from participation.models import Team, Tournament @@ -13,6 +13,9 @@ class Command(BaseCommand): """ Create Sympa mailing lists and register teams. """ + if not settings.ML_MANAGEMENT: + return + sympa = get_sympa_client() sympa.create_list("equipes", "Equipes du TFJM2", "hotline", diff --git a/participation/models.py b/participation/models.py index b3538f8..88860c1 100644 --- a/participation/models.py +++ b/participation/models.py @@ -239,7 +239,8 @@ class Team(models.Model): if not self.access_code: # if the team got created, generate the access code, create the contact mailing list self.access_code = get_random_string(6) - self.create_mailing_list() + if settings.ML_MANAGEMENT: + self.create_mailing_list() return super().save(*args, **kwargs) diff --git a/participation/signals.py b/participation/signals.py index e7c041f..db5ebec 100644 --- a/participation/signals.py +++ b/participation/signals.py @@ -1,7 +1,9 @@ # Copyright (C) 2020 by Animath # SPDX-License-Identifier: GPL-3.0-or-later + from typing import Union +from django.conf import settings from participation.models import Note, Participation, Passage, Pool, Team, Tournament from registration.models import Payment from tfjm.lists import get_sympa_client @@ -22,7 +24,7 @@ def update_mailing_list(instance: Team, raw, **_): """ When a team name or trigram got updated, update mailing lists """ - if instance.pk and not raw: + if instance.pk and not raw and settings.ML_MANAGEMENT: old_team = Team.objects.get(pk=instance.pk) if old_team.trigram != instance.trigram: # Delete old mailing list, create a new one @@ -41,7 +43,7 @@ def create_payments(instance: Participation, created, raw, **_): """ When a participation got created, create an associated payment. """ - if instance.valid and not raw: + if instance.valid and not raw and settings.PAYMENT_MANAGEMENT: for student in instance.team.students.all(): payment_qs = Payment.objects.filter(registrations=student, final=False) if payment_qs.exists(): diff --git a/participation/templates/participation/tournament_detail.html b/participation/templates/participation/tournament_detail.html index caa65e7..cf6e695 100644 --- a/participation/templates/participation/tournament_detail.html +++ b/participation/templates/participation/tournament_detail.html @@ -18,8 +18,10 @@
{% trans 'place'|capfirst %}
{{ tournament.place }}
-
{% trans 'price'|capfirst %}
-
{% if tournament.price %}{{ tournament.price }} €{% else %}{% trans "Free" %}{% endif %}
+ {% if TFJM.PAYMENT_MANAGEMENT %} +
{% trans 'price'|capfirst %}
+
{% if tournament.price %}{{ tournament.price }} €{% else %}{% trans "Free" %}{% endif %}
+ {% endif %}
{% trans 'remote'|capfirst %}
{{ tournament.remote|yesno }}
@@ -42,7 +44,7 @@
{% trans 'date of maximal syntheses submission for the second round'|capfirst %}
{{ tournament.syntheses_second_phase_limit }}
- {% if TFJM_APP == "ETEAM" %} + {% if TFJM.APP == "ETEAM" %}
{% trans 'date of maximal syntheses submission for the third round'|capfirst %}
{{ tournament.syntheses_third_phase_limit }}
{% endif %} @@ -50,14 +52,16 @@
{% trans 'description'|capfirst %}
{{ tournament.description }}
-
{% trans 'To contact organizers' %}
-
{{ tournament.organizers_email }}
+ {% if TFJM.ML_MANAGEMENT %} +
{% trans 'To contact organizers' %}
+
{{ tournament.organizers_email }}
-
{% trans 'To contact juries' %}
-
{{ tournament.jurys_email }}
+
{% trans 'To contact juries' %}
+
{{ tournament.jurys_email }}
-
{% trans 'To contact valid teams' %}
-
{{ tournament.teams_email }}
+
{% trans 'To contact valid teams' %}
+
{{ tournament.teams_email }}
+ {% endif %} @@ -77,13 +81,15 @@
{% render_table teams %}
- - {% if user.registration.is_admin or user.registration in tournament.organizers.all %} -
- - {% trans "Access to payments list" %} - -
+ + {% if TFJM.PAYMENT_MANAGEMENT %} + {% if user.registration.is_admin or user.registration in tournament.organizers.all %} +
+ + {% trans "Access to payments list" %} + +
+ {% endif %} {% endif %} {% if pools.data %} diff --git a/registration/management/commands/check_hello_asso.py b/registration/management/commands/check_hello_asso.py index 10fa767..90825f3 100644 --- a/registration/management/commands/check_hello_asso.py +++ b/registration/management/commands/check_hello_asso.py @@ -3,6 +3,7 @@ import json +from django.conf import settings from django.core.management import BaseCommand from ...models import Payment @@ -15,6 +16,9 @@ class Command(BaseCommand): help = "Vérifie si les paiements Hello Asso initiés sont validés ou non. Si oui, valide les inscriptions." def handle(self, *args, **options): + if not settings.PAYMENT_MANAGEMENT: + return + for payment in Payment.objects.exclude(valid=True).filter(checkout_intent_id__isnull=False).all(): checkout_intent = payment.get_checkout_intent() if checkout_intent is not None and 'order' in checkout_intent: diff --git a/registration/management/commands/remind_payments.py b/registration/management/commands/remind_payments.py index a1ded6f..09fd2cb 100644 --- a/registration/management/commands/remind_payments.py +++ b/registration/management/commands/remind_payments.py @@ -1,6 +1,7 @@ # Copyright (C) 2024 by Animath # SPDX-License-Identifier: GPL-3.0-or-later +from django.conf import settings from django.core.management import BaseCommand from ...models import Payment @@ -13,5 +14,8 @@ class Command(BaseCommand): help = "Envoie un mail de rappel à toustes les participant⋅es qui n'ont pas encore payé ou déclaré de paiement." def handle(self, *args, **options): + if not settings.PAYMENT_MANAGEMENT: + return + for payment in Payment.objects.filter(valid=False).filter(registrations__team__participation__valid=True).all(): payment.send_remind_mail() diff --git a/tfjm/context_processors.py b/tfjm/context_processors.py index 7a979e9..1c31248 100644 --- a/tfjm/context_processors.py +++ b/tfjm/context_processors.py @@ -5,6 +5,11 @@ from participation.models import Tournament def tfjm_context(request): return { - 'TFJM_APP': settings.TFJM_APP, - 'SINGLE_TOURNAMENT': Tournament.objects.first() if Tournament.objects.exists() and settings.TFJM_APP else None, + 'TFJM': { + 'APP': settings.TFJM_APP, + 'ML_MANAGEMENT': settings.ML_MANAGEMENT, + 'PAYMENT_MANAGEMENT': settings.PAYMENT_MANAGEMENT, + 'SINGLE_TOURNAMENT': + Tournament.objects.first() if Tournament.objects.exists() and settings.TFJM_APP else None, + } } diff --git a/tfjm/settings.py b/tfjm/settings.py index ec01e98..9adf27d 100644 --- a/tfjm/settings.py +++ b/tfjm/settings.py @@ -349,6 +349,8 @@ if TFJM_APP == "TFJM": TEAM_CODE_LENGTH = 3 RECOMMENDED_SOLUTIONS_COUNT = 5 NB_ROUNDS = 2 + ML_MANAGEMENT = True + PAYMENT_MANAGEMENT = True PROBLEMS = [ "Triominos", @@ -364,6 +366,8 @@ elif TFJM_APP == "ETEAM": TEAM_CODE_LENGTH = 4 RECOMMENDED_SOLUTIONS_COUNT = 6 NB_ROUNDS = 3 + ML_MANAGEMENT = False + PAYMENT_MANAGEMENT = False PROBLEMS = [ "Exploring Flatland", diff --git a/tfjm/templates/navbar.html b/tfjm/templates/navbar.html index 4add947..da09f85 100644 --- a/tfjm/templates/navbar.html +++ b/tfjm/templates/navbar.html @@ -19,8 +19,8 @@ {% trans "Home" %}