From 628f69e7723b13206d53876861bedfff1863a885 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Fri, 22 Jan 2021 09:04:44 +0100 Subject: [PATCH] Gender is not a date --- .../migrations/0002_participantregistration_gender.py | 4 ++-- apps/registration/models.py | 3 ++- apps/registration/tests.py | 9 ++++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/registration/migrations/0002_participantregistration_gender.py b/apps/registration/migrations/0002_participantregistration_gender.py index 0dd0e24..0bf81fa 100644 --- a/apps/registration/migrations/0002_participantregistration_gender.py +++ b/apps/registration/migrations/0002_participantregistration_gender.py @@ -1,4 +1,4 @@ -# Generated by Django 3.0.11 on 2021-01-22 07:42 +# Generated by Django 3.0.11 on 2021-01-22 08:00 from django.db import migrations, models @@ -13,6 +13,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name='participantregistration', name='gender', - field=models.DateField(choices=[('female', 'Female'), ('male', 'Male'), ('other', 'Other')], default='other', verbose_name='gender'), + field=models.CharField(choices=[('female', 'Female'), ('male', 'Male'), ('other', 'Other')], default='other', max_length=6, verbose_name='gender'), ), ] diff --git a/apps/registration/models.py b/apps/registration/models.py index ad1d3dd..3e12fce 100644 --- a/apps/registration/models.py +++ b/apps/registration/models.py @@ -128,7 +128,8 @@ class ParticipantRegistration(Registration): default=date.today, ) - gender = models.DateField( + gender = models.CharField( + max_length=6, verbose_name=_("gender"), choices=[ ("female", _("Female")), diff --git a/apps/registration/tests.py b/apps/registration/tests.py index ffa7955..6866f9f 100644 --- a/apps/registration/tests.py +++ b/apps/registration/tests.py @@ -130,6 +130,7 @@ class TestRegistration(TestCase): student_class=12, school="God", birth_date="2000-01-01", + gender="other", address="1 Rue de Rivoli, 75001 Paris, France", phone_number="0123456789", responsible_name="Toto", @@ -153,6 +154,7 @@ class TestRegistration(TestCase): student_class=12, school="God", birth_date="2000-01-01", + gender="other", address="1 Rue de Rivoli, 75001 Paris, France", phone_number="0123456789", responsible_name="Toto", @@ -173,6 +175,7 @@ class TestRegistration(TestCase): password2="azertyuiopazertyuiop", role="coach", birth_date="1980-01-01", + gender="other", address="1 Rue de Rivoli, 75001 Paris, France", phone_number="0123456789", professional_activity="God", @@ -252,10 +255,10 @@ class TestRegistration(TestCase): for user, data in [(self.user, dict(role="Bot")), (self.student, dict(student_class=11, school="Sky", birth_date="2001-01-01", - address="1 Rue de Rivoli, 75001 Paris, France", responsible_name="Toto", - responsible_email="toto@example.com")), + gender="female", address="1 Rue de Rivoli, 75001 Paris, France", + responsible_name="Toto", responsible_email="toto@example.com")), (self.coach, dict(professional_activity="God", birth_date="2001-01-01", - address="1 Rue de Rivoli, 75001 Paris, France"))]: + gender="male", address="1 Rue de Rivoli, 75001 Paris, France"))]: response = self.client.get(reverse("registration:update_user", args=(user.pk,))) self.assertEqual(response.status_code, 200)