mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 07:41:14 +00:00
Make date of birth mandatory
This commit is contained in:
parent
c434e093a0
commit
e9c18748b0
@ -10,7 +10,7 @@ class RegisteringForm(UserCreationForm):
|
||||
required_css_class = 'required'
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ('first_name', 'last_name', 'email')
|
||||
fields = ('first_name', 'last_name', 'email', 'date_of_birth')
|
||||
|
||||
def save(self, commit=True):
|
||||
user = super(RegisteringForm, self).save(commit=False)
|
||||
|
19
core/migrations/0008_auto_20151122_1717.py
Normal file
19
core/migrations/0008_auto_20151122_1717.py
Normal file
@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0007_auto_20151120_1347'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='user',
|
||||
name='date_of_birth',
|
||||
field=models.DateTimeField(verbose_name='date of birth'),
|
||||
),
|
||||
]
|
@ -35,7 +35,7 @@ class User(AbstractBaseUser, PermissionsMixin):
|
||||
first_name = models.CharField(_('first name'), max_length=30)
|
||||
last_name = models.CharField(_('last name'), max_length=30)
|
||||
email = models.EmailField(_('email address'), unique=True)
|
||||
date_of_birth = models.DateTimeField(_('date of birth'), default=timezone.make_aware(datetime(1942, 6, 12)))
|
||||
date_of_birth = models.DateTimeField(_('date of birth'))
|
||||
nick_name = models.CharField(max_length=30, blank=True)
|
||||
is_staff = models.BooleanField(
|
||||
_('staff status'),
|
||||
@ -55,7 +55,7 @@ class User(AbstractBaseUser, PermissionsMixin):
|
||||
objects = UserManager()
|
||||
|
||||
USERNAME_FIELD = 'username'
|
||||
REQUIRED_FIELDS = ['email', 'first_name', 'last_name']
|
||||
REQUIRED_FIELDS = ['email', 'first_name', 'last_name', 'date_of_birth']
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('user')
|
||||
|
@ -13,6 +13,7 @@ class UserRegistrationTest(SimpleTestCase):
|
||||
response = c.post(reverse('core:register'), {'first_name': 'Guy',
|
||||
'last_name': 'Carlier',
|
||||
'email': 'guy@git.an',
|
||||
'date_of_birth': '12/6/1942',
|
||||
'password1': 'plop',
|
||||
'password2': 'plop',
|
||||
})
|
||||
@ -27,6 +28,7 @@ class UserRegistrationTest(SimpleTestCase):
|
||||
response = c.post(reverse('core:register'), {'first_name': 'Guy',
|
||||
'last_name': 'Carlier',
|
||||
'email': 'bibou@git.an',
|
||||
'date_of_birth': '12/6/1942',
|
||||
'password1': 'plop',
|
||||
'password2': 'plop2',
|
||||
})
|
||||
@ -41,6 +43,7 @@ class UserRegistrationTest(SimpleTestCase):
|
||||
response = c.post(reverse('core:register'), {'first_name': 'Guy',
|
||||
'last_name': 'Carlier',
|
||||
'email': 'bibou.git.an',
|
||||
'date_of_birth': '12/6/1942',
|
||||
'password1': 'plop',
|
||||
'password2': 'plop',
|
||||
})
|
||||
@ -55,6 +58,22 @@ class UserRegistrationTest(SimpleTestCase):
|
||||
response = c.post(reverse('core:register'), {'first_name': 'Guy',
|
||||
'last_name': '',
|
||||
'email': 'bibou@git.an',
|
||||
'date_of_birth': '12/6/1942',
|
||||
'password1': 'plop',
|
||||
'password2': 'plop',
|
||||
})
|
||||
self.assertTrue(response.status_code == 200)
|
||||
self.assertTrue('TEST_REGISTER_USER_FORM_FAIL' in str(response.content))
|
||||
|
||||
def test_register_user_form_fail_missing_date_of_birth(self):
|
||||
"""
|
||||
Should not register a user correctly
|
||||
"""
|
||||
c = Client()
|
||||
response = c.post(reverse('core:register'), {'first_name': '',
|
||||
'last_name': 'Carlier',
|
||||
'email': 'bibou@git.an',
|
||||
'date_of_birth': '',
|
||||
'password1': 'plop',
|
||||
'password2': 'plop',
|
||||
})
|
||||
@ -69,6 +88,7 @@ class UserRegistrationTest(SimpleTestCase):
|
||||
response = c.post(reverse('core:register'), {'first_name': '',
|
||||
'last_name': 'Carlier',
|
||||
'email': 'bibou@git.an',
|
||||
'date_of_birth': '12/6/1942',
|
||||
'password1': 'plop',
|
||||
'password2': 'plop',
|
||||
})
|
||||
@ -83,12 +103,14 @@ class UserRegistrationTest(SimpleTestCase):
|
||||
c.post(reverse('core:register'), {'first_name': 'Guy',
|
||||
'last_name': 'Carlier',
|
||||
'email': 'bibou@git.an',
|
||||
'date_of_birth': '12/6/1942',
|
||||
'password1': 'plop',
|
||||
'password2': 'plop',
|
||||
})
|
||||
response = c.post(reverse('core:register'), {'first_name': 'Bibou',
|
||||
'last_name': 'Carlier',
|
||||
'email': 'bibou@git.an',
|
||||
'date_of_birth': '12/6/1942',
|
||||
'password1': 'plop',
|
||||
'password2': 'plop',
|
||||
})
|
||||
@ -103,6 +125,7 @@ class UserRegistrationTest(SimpleTestCase):
|
||||
c.post(reverse('core:register'), {'first_name': 'Guy',
|
||||
'last_name': 'Carlier',
|
||||
'email': 'bibou@git.an',
|
||||
'date_of_birth': '12/6/1942',
|
||||
'password1': 'plop',
|
||||
'password2': 'plop',
|
||||
})
|
||||
@ -118,6 +141,7 @@ class UserRegistrationTest(SimpleTestCase):
|
||||
c.post(reverse('core:register'), {'first_name': 'Guy',
|
||||
'last_name': 'Carlier',
|
||||
'email': 'bibou@git.an',
|
||||
'date_of_birth': '12/6/1942',
|
||||
'password1': 'plop',
|
||||
'password2': 'plop',
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user