Skip to content

Commit

Permalink
Support email addresses up to 254 chars long
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Jan 14, 2016
1 parent 098d3d2 commit eb6d23c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
15 changes: 15 additions & 0 deletions casepro/profiles/migrations/0003_username_max_length.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('profiles', '0002_auto_20150514_1510'),
]

operations = [
migrations.RunSQL("ALTER TABLE auth_user ALTER COLUMN username TYPE VARCHAR(254);")
]
9 changes: 6 additions & 3 deletions casepro/profiles/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

class UserPatchTest(BaseCasesTest):
def test_create_user(self):
user = User.create(self.unicef, self.moh, ROLE_MANAGER, "Mo Polls", "mo@moh.com", "Qwerty123", False)
self.assertEqual(user.profile.full_name, "Mo Polls")
user = User.create(self.unicef, self.moh, ROLE_MANAGER, "Mo Cases", "mo@moh.com", "Qwerty123", False)
self.assertEqual(user.profile.full_name, "Mo Cases")

self.assertEqual(user.first_name, "")
self.assertEqual(user.last_name, "")
self.assertEqual(user.email, "mo@moh.com")
self.assertEqual(user.get_full_name(), "Mo Polls")
self.assertEqual(user.get_full_name(), "Mo Cases")
self.assertIsNotNone(user.password)

self.assertFalse(user.profile.change_password)
Expand All @@ -25,6 +25,9 @@ def test_create_user(self):
user.set_org(self.unicef)
self.assertEqual(user.get_org_group(), Group.objects.get(name="Editors"))

# test creating user with long email
User.create(self.unicef, self.moh, ROLE_MANAGER, "Mo Cases", "mo123456789012345678901234567890@moh.com", "Qwerty123", False)

def test_update_role(self):
self.user1.update_role(self.unicef, ROLE_ANALYST)
self.assertTrue(self.user1 in self.unicef.viewers.all())
Expand Down
2 changes: 1 addition & 1 deletion casepro/profiles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class UserForm(forms.ModelForm):

role = forms.ChoiceField(label=_("Role"), choices=ROLE_CHOICES, required=True, initial=ROLE_ANALYST)

email = forms.CharField(label=_("Email"), max_length=256,
email = forms.CharField(label=_("Email"), max_length=254,
help_text=_("Email address and login."))

password = forms.CharField(label=_("Password"), widget=forms.PasswordInput, validators=[MinLengthValidator(8)],
Expand Down

0 comments on commit eb6d23c

Please sign in to comment.