From 5d285f742e89159b8e1f82ce5f1e48a2b520c195 Mon Sep 17 00:00:00 2001 From: aeltheos <aeltheos@crans.org> Date: Sat, 20 Nov 2021 14:43:15 +0100 Subject: [PATCH] Renamed added field to birth_date and birth_location to match the LDAP --- member/forms.py | 12 ++++-------- member/models.py | 8 ++++---- member/tests.py | 36 ++++++++++++++++++------------------ 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/member/forms.py b/member/forms.py index 6cb099b..7320910 100644 --- a/member/forms.py +++ b/member/forms.py @@ -47,19 +47,15 @@ class UserForm(forms.ModelForm): class PersonForm(forms.ModelForm): - date_of_birth = forms.DateField( - label=_('Date of birth'), - required=True, - ) - place_of_birth = forms.CharField( - label=_('Place of birth'), - max_length=256, + # Manually add birth_date on the form so that django does not fill the field with default value. + birth_date = forms.DateField( + label=_('Birth date'), required=True, ) class Meta: model = Person - fields = ('address', 'telephone', 'date_of_birth', 'place_of_birth',) + fields = ('address', 'telephone', 'birth_date', 'birth_location',) class OrganizationForm(forms.ModelForm): diff --git a/member/models.py b/member/models.py index f5507bb..662c345 100644 --- a/member/models.py +++ b/member/models.py @@ -81,12 +81,12 @@ class Person(Profile): max_length=40, verbose_name=_("PGP fingerprint"), ) - date_of_birth = models.DateField( - verbose_name=_("Date of birth"), + birth_date = models.DateField( + verbose_name=_("Birth date"), default=datetime(1970, 1, 1), ) - place_of_birth = models.CharField( - verbose_name=_("Place of birth"), + birth_location = models.CharField( + verbose_name=_("Birth location"), max_length=256, default="", ) diff --git a/member/tests.py b/member/tests.py index f4e7b8b..7b1bab1 100644 --- a/member/tests.py +++ b/member/tests.py @@ -34,8 +34,8 @@ class TestMembers(TestCase): user=self.member, address="France", telephone="0123456789", - date_of_birth="1970-01-01", - place_of_birth="example" + birth_date="1970-01-01", + birth_location="example" ) self.organization = User.objects.create( @@ -118,8 +118,8 @@ class TestMembers(TestCase): 'password2': "toto1234", 'address': "France", 'telephone': "0100000000", - 'date_of_birth': "1970-01-01", - 'place_of_birth': "example", + 'birth_date': "1970-01-01", + 'birth_location': "example", 'gtu': True, 'no_double_account': True, }) @@ -137,8 +137,8 @@ class TestMembers(TestCase): 'password2': "toto1234", 'address': "France", 'telephone': "0100000000", - 'date_of_birth': "1970-01-01", - 'place_of_birth': "example", + 'birth_date': "1970-01-01", + 'birth_location': "example", 'gtu': True, 'no_double_account': True, }) @@ -155,8 +155,8 @@ class TestMembers(TestCase): 'password2': "toto1234", 'address': "France", 'telephone': "0100000000", - 'date_of_birth': "1970-01-01", - 'place_of_birth': "example", + 'birth_date': "1970-01-01", + 'birth_location': "example", 'gtu': True, 'no_double_account': True, }) @@ -173,8 +173,8 @@ class TestMembers(TestCase): 'password2': "pouetpouet", 'address': "", 'telephone': "", - 'date_of_birth': "", - 'place_of_birth': "", + 'birth_location': "", + 'birth_place': "", 'gtu': True, 'no_double_account': True, }) @@ -227,8 +227,8 @@ class TestMembers(TestCase): 'email': "god@example.com", 'address': "Earth", 'telephone': "0123456789", - 'date_of_birth': "1970-01-01", - 'place_of_birth': "example", + 'birth_date': "1970-01-01", + 'birth_location': "example", }) self.assertRedirects(response, reverse('member:user_detail', args=(self.admin.pk,))) self.admin.refresh_from_db() @@ -242,8 +242,8 @@ class TestMembers(TestCase): 'email': "member@example.com", 'address': "Earth", 'telephone': "0123456789", - 'date_of_birth': "1970-01-01", - 'place_of_birth': "example", + 'birth_date': "1970-01-01", + 'birth_location': "example", }) self.assertEqual(response.status_code, 200) self.assertIn('email', response.context['form'].errors) @@ -256,8 +256,8 @@ class TestMembers(TestCase): 'email': "admin@example.com", 'address': "", 'telephone': "", - 'date_of_birth': "", - 'place_of_birth': "", + 'birth_date': "", + 'birth_location': "", }) self.assertEqual(response.status_code, 200) self.assertIn('address', response.context['profile_form'].errors) @@ -270,8 +270,8 @@ class TestMembers(TestCase): 'email': "god@example.com", 'address': "Earth", 'telephone': "0123456789", - 'date_of_birth': "1970-01-01", - 'place_of_birth': "example", + 'birth_date': "1970-01-01", + 'birth_location': "example", }) self.assertEqual(response.status_code, 200) self.assertIn('username', response.context['form'].errors) -- GitLab