mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 05:42:12 +01:00 
			
		
		
		
	Birth date is only for participants
This commit is contained in:
		
							
								
								
									
										108
									
								
								apps/participation/migrations/0002_initial.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										108
									
								
								apps/participation/migrations/0002_initial.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,108 @@
 | 
			
		||||
# Generated by Django 3.2.13 on 2023-01-10 19:22
 | 
			
		||||
 | 
			
		||||
from django.db import migrations, models
 | 
			
		||||
import django.db.models.deletion
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Migration(migrations.Migration):
 | 
			
		||||
 | 
			
		||||
    initial = True
 | 
			
		||||
 | 
			
		||||
    dependencies = [
 | 
			
		||||
        ('participation', '0001_initial'),
 | 
			
		||||
        ('registration', '0001_initial'),
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    operations = [
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='tournament',
 | 
			
		||||
            name='organizers',
 | 
			
		||||
            field=models.ManyToManyField(related_name='organized_tournaments', to='registration.VolunteerRegistration', verbose_name='organizers'),
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AddIndex(
 | 
			
		||||
            model_name='team',
 | 
			
		||||
            index=models.Index(fields=['trigram'], name='participati_trigram_239255_idx'),
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='synthesis',
 | 
			
		||||
            name='participation',
 | 
			
		||||
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='participation.participation', verbose_name='participation'),
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='synthesis',
 | 
			
		||||
            name='passage',
 | 
			
		||||
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='syntheses', to='participation.passage', verbose_name='passage'),
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='solution',
 | 
			
		||||
            name='participation',
 | 
			
		||||
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='solutions', to='participation.participation', verbose_name='participation'),
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='pool',
 | 
			
		||||
            name='juries',
 | 
			
		||||
            field=models.ManyToManyField(related_name='jury_in', to='registration.VolunteerRegistration', verbose_name='juries'),
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='pool',
 | 
			
		||||
            name='participations',
 | 
			
		||||
            field=models.ManyToManyField(related_name='pools', to='participation.Participation', verbose_name='participations'),
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='pool',
 | 
			
		||||
            name='tournament',
 | 
			
		||||
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pools', to='participation.tournament', verbose_name='tournament'),
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='passage',
 | 
			
		||||
            name='defender',
 | 
			
		||||
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='+', to='participation.participation', verbose_name='defender'),
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='passage',
 | 
			
		||||
            name='opponent',
 | 
			
		||||
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='+', to='participation.participation', verbose_name='opponent'),
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='passage',
 | 
			
		||||
            name='pool',
 | 
			
		||||
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='passages', to='participation.pool', verbose_name='pool'),
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='passage',
 | 
			
		||||
            name='reporter',
 | 
			
		||||
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='+', to='participation.participation', verbose_name='reporter'),
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='participation',
 | 
			
		||||
            name='team',
 | 
			
		||||
            field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='participation.team', verbose_name='team'),
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='participation',
 | 
			
		||||
            name='tournament',
 | 
			
		||||
            field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, to='participation.tournament', verbose_name='tournament'),
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='note',
 | 
			
		||||
            name='jury',
 | 
			
		||||
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='notes', to='registration.volunteerregistration', verbose_name='jury'),
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='note',
 | 
			
		||||
            name='passage',
 | 
			
		||||
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='notes', to='participation.passage', verbose_name='passage'),
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AddIndex(
 | 
			
		||||
            model_name='tournament',
 | 
			
		||||
            index=models.Index(fields=['name', 'date_start', 'date_end'], name='participati_name_b43174_idx'),
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AlterUniqueTogether(
 | 
			
		||||
            name='synthesis',
 | 
			
		||||
            unique_together={('participation', 'passage', 'type')},
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AlterUniqueTogether(
 | 
			
		||||
            name='solution',
 | 
			
		||||
            unique_together={('participation', 'problem', 'final_solution')},
 | 
			
		||||
        ),
 | 
			
		||||
    ]
 | 
			
		||||
@@ -101,8 +101,8 @@ class StudentRegistrationForm(forms.ModelForm):
 | 
			
		||||
    """
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = StudentRegistration
 | 
			
		||||
        fields = ('team', 'student_class', 'birth_date', 'gender', 'address', 'phone_number', 'health_issues',
 | 
			
		||||
                  'school', 'responsible_name', 'responsible_phone', 'responsible_email',
 | 
			
		||||
        fields = ('team', 'student_class', 'birth_date', 'gender', 'address', 'zip_code', 'city', 'phone_number',
 | 
			
		||||
                  'health_issues', 'school', 'responsible_name', 'responsible_phone', 'responsible_email',
 | 
			
		||||
                  'give_contact_to_animath', 'email_confirmed',)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -178,8 +178,8 @@ class CoachRegistrationForm(forms.ModelForm):
 | 
			
		||||
    """
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = CoachRegistration
 | 
			
		||||
        fields = ('team', 'birth_date', 'gender', 'address', 'phone_number', 'health_issues', 'professional_activity',
 | 
			
		||||
                  'give_contact_to_animath', 'email_confirmed',)
 | 
			
		||||
        fields = ('team', 'gender', 'address', 'zip_code', 'city', 'phone_number', 'health_issues',
 | 
			
		||||
                  'professional_activity', 'give_contact_to_animath', 'email_confirmed',)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class VolunteerRegistrationForm(forms.ModelForm):
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										29
									
								
								apps/registration/migrations/0002_auto_20230110_2031.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								apps/registration/migrations/0002_auto_20230110_2031.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
			
		||||
# Generated by Django 3.2.13 on 2023-01-10 19:31
 | 
			
		||||
 | 
			
		||||
import datetime
 | 
			
		||||
from django.db import migrations, models
 | 
			
		||||
import phonenumber_field.modelfields
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Migration(migrations.Migration):
 | 
			
		||||
 | 
			
		||||
    dependencies = [
 | 
			
		||||
        ('registration', '0001_initial'),
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    operations = [
 | 
			
		||||
        migrations.RemoveField(
 | 
			
		||||
            model_name='participantregistration',
 | 
			
		||||
            name='birth_date',
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='studentregistration',
 | 
			
		||||
            name='birth_date',
 | 
			
		||||
            field=models.DateField(default=datetime.date.today, verbose_name='birth date'),
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AlterField(
 | 
			
		||||
            model_name='studentregistration',
 | 
			
		||||
            name='responsible_phone',
 | 
			
		||||
            field=phonenumber_field.modelfields.PhoneNumberField(default='', max_length=128, region=None, verbose_name='responsible phone number'),
 | 
			
		||||
        ),
 | 
			
		||||
    ]
 | 
			
		||||
@@ -123,11 +123,6 @@ class ParticipantRegistration(Registration):
 | 
			
		||||
        verbose_name=_("team"),
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    birth_date = models.DateField(
 | 
			
		||||
        verbose_name=_("birth date"),
 | 
			
		||||
        default=date.today,
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    gender = models.CharField(
 | 
			
		||||
        max_length=6,
 | 
			
		||||
        verbose_name=_("gender"),
 | 
			
		||||
@@ -174,6 +169,8 @@ class ParticipantRegistration(Registration):
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def under_18(self):
 | 
			
		||||
        if isinstance(self, CoachRegistration):
 | 
			
		||||
            return False  # In normal case
 | 
			
		||||
        important_date = timezone.now().date()
 | 
			
		||||
        if self.team and self.team.participation.tournament:
 | 
			
		||||
            important_date = self.team.participation.tournament.date_start
 | 
			
		||||
@@ -196,6 +193,11 @@ class StudentRegistration(ParticipantRegistration):
 | 
			
		||||
    Specific registration for students.
 | 
			
		||||
    They have a team, a student class and a school.
 | 
			
		||||
    """
 | 
			
		||||
    birth_date = models.DateField(
 | 
			
		||||
        verbose_name=_("birth date"),
 | 
			
		||||
        default=date.today,
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    student_class = models.IntegerField(
 | 
			
		||||
        choices=[
 | 
			
		||||
            (12, _("12th grade")),
 | 
			
		||||
@@ -218,7 +220,7 @@ class StudentRegistration(ParticipantRegistration):
 | 
			
		||||
 | 
			
		||||
    responsible_phone = PhoneNumberField(
 | 
			
		||||
        verbose_name=_("responsible phone number"),
 | 
			
		||||
        blank=True,
 | 
			
		||||
        default="",
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    responsible_email = models.EmailField(
 | 
			
		||||
 
 | 
			
		||||
@@ -39,8 +39,10 @@
 | 
			
		||||
                    </a>
 | 
			
		||||
                </dd>
 | 
			
		||||
 | 
			
		||||
                <dt class="col-sm-6 text-right">{% trans "Birth date:" %}</dt>
 | 
			
		||||
                <dd class="col-sm-6">{{ user_object.registration.birth_date }}</dd>
 | 
			
		||||
                {% if user_object.registration.studentregistration %}
 | 
			
		||||
                    <dt class="col-sm-6 text-right">{% trans "Birth date:" %}</dt>
 | 
			
		||||
                    <dd class="col-sm-6">{{ user_object.registration.birth_date }}</dd>
 | 
			
		||||
                {% endif %}
 | 
			
		||||
 | 
			
		||||
                <dt class="col-sm-6 text-right">{% trans "Gender:" %}</dt>
 | 
			
		||||
                <dd class="col-sm-6">{{ user_object.registration.get_gender_display }}</dd>
 | 
			
		||||
 
 | 
			
		||||
@@ -3,8 +3,9 @@
 | 
			
		||||
{{ object.user.email }}
 | 
			
		||||
{{ object.type }}
 | 
			
		||||
{{ object.professional_activity }}
 | 
			
		||||
{{ object.birth_date }}
 | 
			
		||||
{{ object.address }}
 | 
			
		||||
{{ object.zip_code }}
 | 
			
		||||
{{ object.city }}
 | 
			
		||||
{{ object.phone_number }}
 | 
			
		||||
{{ object.team.name }}
 | 
			
		||||
{{ object.team.trigram }}
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,8 @@
 | 
			
		||||
{{ object.school }}
 | 
			
		||||
{{ object.birth_date }}
 | 
			
		||||
{{ object.address }}
 | 
			
		||||
{{ object.zip_code }}
 | 
			
		||||
{{ object.city }}
 | 
			
		||||
{{ object.phone_number }}
 | 
			
		||||
{{ object.responsible_name }}
 | 
			
		||||
{{ object.reponsible_phone }}
 | 
			
		||||
 
 | 
			
		||||
@@ -178,7 +178,6 @@ class TestRegistration(TestCase):
 | 
			
		||||
            password1="azertyuiopazertyuiop",
 | 
			
		||||
            password2="azertyuiopazertyuiop",
 | 
			
		||||
            role="coach",
 | 
			
		||||
            birth_date="1980-01-01",
 | 
			
		||||
            gender="other",
 | 
			
		||||
            address="1 Rue de Rivoli",
 | 
			
		||||
            zip_code=75001,
 | 
			
		||||
@@ -264,8 +263,8 @@ class TestRegistration(TestCase):
 | 
			
		||||
                                               gender="female", address="1 Rue de Rivoli", zip_code=75001,
 | 
			
		||||
                                               city="Paris", responsible_name="Toto",
 | 
			
		||||
                                               responsible_email="toto@example.com")),
 | 
			
		||||
                           (self.coach, dict(professional_activity="God", birth_date="2001-01-01",
 | 
			
		||||
                                             gender="male", address="1 Rue de Rivoli", zip_code=75001, city="Paris"))]:
 | 
			
		||||
                           (self.coach, dict(professional_activity="God", gender="male",
 | 
			
		||||
                                             address="1 Rue de Rivoli", zip_code=75001, city="Paris"))]:
 | 
			
		||||
            response = self.client.get(reverse("registration:update_user", args=(user.pk,)))
 | 
			
		||||
            self.assertEqual(response.status_code, 200)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user