mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 11:52:20 +01:00 
			
		
		
		
	Add unified registration for Île-de-France
This commit is contained in:
		
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -5,7 +5,7 @@ from io import StringIO
 | 
			
		||||
import re
 | 
			
		||||
 | 
			
		||||
from crispy_forms.helper import FormHelper
 | 
			
		||||
from crispy_forms.layout import Div, Field, Submit
 | 
			
		||||
from crispy_forms.layout import Div, Field, HTML, Layout, Submit
 | 
			
		||||
from django import forms
 | 
			
		||||
from django.contrib.auth.models import User
 | 
			
		||||
from django.core.exceptions import ValidationError
 | 
			
		||||
@@ -77,9 +77,30 @@ class ParticipationForm(forms.ModelForm):
 | 
			
		||||
    """
 | 
			
		||||
    def __init__(self, *args, **kwargs):
 | 
			
		||||
        super().__init__(*args, **kwargs)
 | 
			
		||||
        if settings.TFJM_APP == "ETEAM":
 | 
			
		||||
            # One single tournament only
 | 
			
		||||
        if settings.SINGLE_TOURNAMENT:
 | 
			
		||||
            del self.fields['tournament']
 | 
			
		||||
        self.helper = FormHelper()
 | 
			
		||||
        idf_warning_banner = f"""
 | 
			
		||||
<div class=\"alert alert-warning\">
 | 
			
		||||
<h5 class=\"alert-heading\">{_("IMPORTANT")}</h4>
 | 
			
		||||
{_("""For the tournaments in the region "Île-de-France": registration is
 | 
			
		||||
unified for each tournament. By choosing a tournament "Île-de-France",
 | 
			
		||||
you're accepting that your team may be selected for one of these tournaments.
 | 
			
		||||
In case of date conflict, please write them in your motivation letter.""")}
 | 
			
		||||
</div>
 | 
			
		||||
"""
 | 
			
		||||
        unified_registration_tournament_ids = ",".join(str(tournament.id)
 | 
			
		||||
            for tournament in Tournament.objects.filter(
 | 
			
		||||
                unified_registration=True).all())
 | 
			
		||||
        self.helper.layout = Layout(
 | 
			
		||||
            'tournament',
 | 
			
		||||
            Div(
 | 
			
		||||
                HTML(idf_warning_banner),
 | 
			
		||||
                css_id="idf_warning_banner",
 | 
			
		||||
                data_tid_unified=unified_registration_tournament_ids,
 | 
			
		||||
            ),
 | 
			
		||||
            'final',
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = Participation
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,21 @@
 | 
			
		||||
# Generated by Django 5.1.5 on 2025-01-14 18:06
 | 
			
		||||
 | 
			
		||||
import django.core.validators
 | 
			
		||||
from django.db import migrations, models
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Migration(migrations.Migration):
 | 
			
		||||
 | 
			
		||||
    dependencies = [
 | 
			
		||||
        ("participation", "0022_alter_note_observer_oral"),
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    operations = [
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name="tournament",
 | 
			
		||||
            name="unified_registration",
 | 
			
		||||
            field=models.BooleanField(
 | 
			
		||||
                default=False, verbose_name="unified registration"
 | 
			
		||||
            ),
 | 
			
		||||
        ),
 | 
			
		||||
    ]
 | 
			
		||||
@@ -283,6 +283,11 @@ class Tournament(models.Model):
 | 
			
		||||
        default=date.today,
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    unified_registration = models.BooleanField(
 | 
			
		||||
        verbose_name=_("unified registration"),
 | 
			
		||||
        default=False,
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    place = models.CharField(
 | 
			
		||||
        max_length=255,
 | 
			
		||||
        verbose_name=_("place"),
 | 
			
		||||
 
 | 
			
		||||
@@ -1,15 +1,37 @@
 | 
			
		||||
{% extends request.content_only|yesno:"empty.html,base.html" %}
 | 
			
		||||
 | 
			
		||||
{% load crispy_forms_filters i18n %}
 | 
			
		||||
{% load crispy_forms_filters crispy_forms_tags i18n %}
 | 
			
		||||
 | 
			
		||||
{% block content %}
 | 
			
		||||
    <form method="post">
 | 
			
		||||
        <div id="form-content">
 | 
			
		||||
            {% csrf_token %}
 | 
			
		||||
            {{ form|crispy }}
 | 
			
		||||
            {{ participation_form|crispy }}
 | 
			
		||||
            {% crispy participation_form %}
 | 
			
		||||
        </div>
 | 
			
		||||
        <button class="btn btn-success" type="submit">{% trans "Update" %}</button>
 | 
			
		||||
    </form>
 | 
			
		||||
{% endblock content %}
 | 
			
		||||
 | 
			
		||||
{% block extrajavascript %}
 | 
			
		||||
    <script>
 | 
			
		||||
        const tournamentSelect = document.getElementById('id_tournament')
 | 
			
		||||
        const idfWarningBanner = document.getElementById('idf_warning_banner')
 | 
			
		||||
        const unifiedRegistrationTournamentIds = idfWarningBanner.getAttribute('data-tid-unified').split(',')
 | 
			
		||||
        if (idfWarningBanner.getAttribute('data-tid-unified') !== "") {
 | 
			
		||||
            function updateIDFWarningBannerVisibility() {
 | 
			
		||||
                const tid = tournamentSelect.value
 | 
			
		||||
                if (unifiedRegistrationTournamentIds.includes(tid))
 | 
			
		||||
                    idfWarningBanner.classList.remove('d-none')
 | 
			
		||||
                else
 | 
			
		||||
                    idfWarningBanner.classList.add('d-none')
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            tournamentSelect.addEventListener('change', updateIDFWarningBannerVisibility)
 | 
			
		||||
            updateIDFWarningBannerVisibility()
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            idfWarningBanner.classList.add('d-none')
 | 
			
		||||
        }
 | 
			
		||||
    </script>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 
 | 
			
		||||
@@ -30,6 +30,15 @@
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <div class="alert alert-warning">
 | 
			
		||||
        <h3 class="alert-heading"><i class="fas fa-warning"></i> {% trans "New in 2025" %}</h3>
 | 
			
		||||
        {% blocktrans trimmed %}
 | 
			
		||||
        Registration for Ile-de-France tournaments is now unified.
 | 
			
		||||
        If you live in or near the Ile-de-France region, your registration will be pooled with each of the region's tournaments,
 | 
			
		||||
        and the organizers will take care of team allocation. However, date constraints can be indicated in the motivation letter.
 | 
			
		||||
        {% endblocktrans %}
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <div class="jumbotron p-5 border rounded-5">
 | 
			
		||||
        <h5 class="display-4">{% trans "How does it work?" %}</h5>
 | 
			
		||||
        <p>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user