Commit e9c18748 authored by Skia's avatar Skia

Make date of birth mandatory

parent c434e093
...@@ -10,7 +10,7 @@ class RegisteringForm(UserCreationForm): ...@@ -10,7 +10,7 @@ class RegisteringForm(UserCreationForm):
required_css_class = 'required' required_css_class = 'required'
class Meta: class Meta:
model = User model = User
fields = ('first_name', 'last_name', 'email') fields = ('first_name', 'last_name', 'email', 'date_of_birth')
def save(self, commit=True): def save(self, commit=True):
user = super(RegisteringForm, self).save(commit=False) user = super(RegisteringForm, self).save(commit=False)
......
# -*- 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): ...@@ -35,7 +35,7 @@ class User(AbstractBaseUser, PermissionsMixin):
first_name = models.CharField(_('first name'), max_length=30) first_name = models.CharField(_('first name'), max_length=30)
last_name = models.CharField(_('last name'), max_length=30) last_name = models.CharField(_('last name'), max_length=30)
email = models.EmailField(_('email address'), unique=True) 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) nick_name = models.CharField(max_length=30, blank=True)
is_staff = models.BooleanField( is_staff = models.BooleanField(
_('staff status'), _('staff status'),
...@@ -55,7 +55,7 @@ class User(AbstractBaseUser, PermissionsMixin): ...@@ -55,7 +55,7 @@ class User(AbstractBaseUser, PermissionsMixin):
objects = UserManager() objects = UserManager()
USERNAME_FIELD = 'username' USERNAME_FIELD = 'username'
REQUIRED_FIELDS = ['email', 'first_name', 'last_name'] REQUIRED_FIELDS = ['email', 'first_name', 'last_name', 'date_of_birth']
class Meta: class Meta:
verbose_name = _('user') verbose_name = _('user')
......
...@@ -13,6 +13,7 @@ class UserRegistrationTest(SimpleTestCase): ...@@ -13,6 +13,7 @@ class UserRegistrationTest(SimpleTestCase):
response = c.post(reverse('core:register'), {'first_name': 'Guy', response = c.post(reverse('core:register'), {'first_name': 'Guy',
'last_name': 'Carlier', 'last_name': 'Carlier',
'email': 'guy@git.an', 'email': 'guy@git.an',
'date_of_birth': '12/6/1942',
'password1': 'plop', 'password1': 'plop',
'password2': 'plop', 'password2': 'plop',
}) })
...@@ -27,6 +28,7 @@ class UserRegistrationTest(SimpleTestCase): ...@@ -27,6 +28,7 @@ class UserRegistrationTest(SimpleTestCase):
response = c.post(reverse('core:register'), {'first_name': 'Guy', response = c.post(reverse('core:register'), {'first_name': 'Guy',
'last_name': 'Carlier', 'last_name': 'Carlier',
'email': 'bibou@git.an', 'email': 'bibou@git.an',
'date_of_birth': '12/6/1942',
'password1': 'plop', 'password1': 'plop',
'password2': 'plop2', 'password2': 'plop2',
}) })
...@@ -41,6 +43,7 @@ class UserRegistrationTest(SimpleTestCase): ...@@ -41,6 +43,7 @@ class UserRegistrationTest(SimpleTestCase):
response = c.post(reverse('core:register'), {'first_name': 'Guy', response = c.post(reverse('core:register'), {'first_name': 'Guy',
'last_name': 'Carlier', 'last_name': 'Carlier',
'email': 'bibou.git.an', 'email': 'bibou.git.an',
'date_of_birth': '12/6/1942',
'password1': 'plop', 'password1': 'plop',
'password2': 'plop', 'password2': 'plop',
}) })
...@@ -55,6 +58,22 @@ class UserRegistrationTest(SimpleTestCase): ...@@ -55,6 +58,22 @@ class UserRegistrationTest(SimpleTestCase):
response = c.post(reverse('core:register'), {'first_name': 'Guy', response = c.post(reverse('core:register'), {'first_name': 'Guy',
'last_name': '', 'last_name': '',
'email': 'bibou@git.an', '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', 'password1': 'plop',
'password2': 'plop', 'password2': 'plop',
}) })
...@@ -69,6 +88,7 @@ class UserRegistrationTest(SimpleTestCase): ...@@ -69,6 +88,7 @@ class UserRegistrationTest(SimpleTestCase):
response = c.post(reverse('core:register'), {'first_name': '', response = c.post(reverse('core:register'), {'first_name': '',
'last_name': 'Carlier', 'last_name': 'Carlier',
'email': 'bibou@git.an', 'email': 'bibou@git.an',
'date_of_birth': '12/6/1942',
'password1': 'plop', 'password1': 'plop',
'password2': 'plop', 'password2': 'plop',
}) })
...@@ -83,12 +103,14 @@ class UserRegistrationTest(SimpleTestCase): ...@@ -83,12 +103,14 @@ class UserRegistrationTest(SimpleTestCase):
c.post(reverse('core:register'), {'first_name': 'Guy', c.post(reverse('core:register'), {'first_name': 'Guy',
'last_name': 'Carlier', 'last_name': 'Carlier',
'email': 'bibou@git.an', 'email': 'bibou@git.an',
'date_of_birth': '12/6/1942',
'password1': 'plop', 'password1': 'plop',
'password2': 'plop', 'password2': 'plop',
}) })
response = c.post(reverse('core:register'), {'first_name': 'Bibou', response = c.post(reverse('core:register'), {'first_name': 'Bibou',
'last_name': 'Carlier', 'last_name': 'Carlier',
'email': 'bibou@git.an', 'email': 'bibou@git.an',
'date_of_birth': '12/6/1942',
'password1': 'plop', 'password1': 'plop',
'password2': 'plop', 'password2': 'plop',
}) })
...@@ -103,6 +125,7 @@ class UserRegistrationTest(SimpleTestCase): ...@@ -103,6 +125,7 @@ class UserRegistrationTest(SimpleTestCase):
c.post(reverse('core:register'), {'first_name': 'Guy', c.post(reverse('core:register'), {'first_name': 'Guy',
'last_name': 'Carlier', 'last_name': 'Carlier',
'email': 'bibou@git.an', 'email': 'bibou@git.an',
'date_of_birth': '12/6/1942',
'password1': 'plop', 'password1': 'plop',
'password2': 'plop', 'password2': 'plop',
}) })
...@@ -118,6 +141,7 @@ class UserRegistrationTest(SimpleTestCase): ...@@ -118,6 +141,7 @@ class UserRegistrationTest(SimpleTestCase):
c.post(reverse('core:register'), {'first_name': 'Guy', c.post(reverse('core:register'), {'first_name': 'Guy',
'last_name': 'Carlier', 'last_name': 'Carlier',
'email': 'bibou@git.an', 'email': 'bibou@git.an',
'date_of_birth': '12/6/1942',
'password1': 'plop', 'password1': 'plop',
'password2': 'plop', 'password2': 'plop',
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment