Skip to content
Permalink
Browse files

Bug 1052195 - Select sole verified email by default in the signup page

This will only affect the sign up page for users that don't have a
public email in their github profiles. The default is still the public
email for users that have one.
  • Loading branch information...
adusca committed Dec 28, 2014
1 parent ebbd8df commit d74877d804628d48f7b6f8a951aec0687d546039
Showing with 20 additions and 5 deletions.
  1. +14 −3 kuma/users/tests/test_views.py
  2. +6 −2 kuma/users/views.py
@@ -688,7 +688,7 @@ class KumaGitHubTests(UserTestCase):
"company": "GitHub",
"blog": "https://github.com/blog",
"location": "San Francisco",
"email": "octocat@github.com",
"email": %(public_email)s,
"hireable": false,
"bio": "There once was...",
"public_repos": 2,
@@ -758,6 +758,8 @@ def test_email_addresses(self):
{'verified': True,
'email': 'octo.cat@github-inc.com',
'primary': True})
# then check if the radio button's default value is the public email address
self.assertEqual(response.context["form"].initial["email"], 'octocat@github.com')

unverified_email = 'o.ctocat@gmail.com'
data = {
@@ -775,6 +777,13 @@ def test_email_addresses(self):
self.assertTrue(unverified_email_addresses[0].primary)
self.assertFalse(unverified_email_addresses[0].verified)

def test_email_addresses_with_no_public(self):
self.login(username='private_octocat',
verified_email='octocat@github.com',
public_email=None)
response = self.client.get(self.signup_url)
self.assertEqual(response.context["form"].initial["email"], 'octocat@github.com')

def test_matching_accounts(self):
testemail = 'octo.cat.III@github-inc.com'
self.login(username='octocat3', verified_email=testemail)
@@ -826,7 +835,8 @@ def test_account_refresh_token_saved_next_login(self):
def login(self,
username='octocat',
verified_email='octo.cat@github-inc.com',
process='login', with_refresh_token=True):
process='login', with_refresh_token=True,
public_email='octocat@github.com'):
resp = self.client.get(reverse('github_login',
locale=settings.WIKI_DEFAULT_LANGUAGE),
{'process': process})
@@ -842,7 +852,8 @@ def login(self,
{'content-type': 'application/json'}),
MockedResponse(200,
self.mocked_user_response %
{'username': username}),
{'username': username,
'public_email': json.dumps(public_email)}),
MockedResponse(200,
self.mocked_email_response %
{'verified_email': verified_email})):
@@ -332,17 +332,21 @@ def get_form(self, form_class):
'primary': False,
}
choices = []
verified_emails = []
for email_address in self.email_addresses.values():
if email_address['verified']:
label = _('%(email)s <b>Verified</b>')
verified_emails.append(email_address['email'])
else:
label = _('%(email)s Unverified')
email = email_address['email']
choices.append((email, label % {'email': email}))
next_email = email_address['email']
choices.append((next_email, label % {'email': next_email}))
choices.append((form.other_email_value, _('Other:')))
email_select = forms.RadioSelect(choices=choices,
attrs={'id': 'email'})
form.fields['email'].widget = email_select
if not email and len(verified_emails) == 1:
form.initial.update(email=verified_emails[0])
return form

def get_form_kwargs(self):

0 comments on commit d74877d

Please sign in to comment.
You can’t perform that action at this time.