From e5f7d65231000ec0b8614eea740d40ee2be953f0 Mon Sep 17 00:00:00 2001 From: Vishnu Ks Date: Tue, 25 Dec 2018 12:45:01 +0000 Subject: [PATCH] signup: Set oldest account as default option in import settings. Fixes: #11018 --- templates/zerver/register.html | 12 ++++++++---- zerver/lib/users.py | 4 ++-- zerver/tests/test_signup.py | 11 +++++++++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/templates/zerver/register.html b/templates/zerver/register.html index 55d7f17473..a5ca3bee68 100644 --- a/templates/zerver/register.html +++ b/templates/zerver/register.html @@ -104,16 +104,20 @@ Form is validated both client-side using jquery-validate (see signup.js) and ser {% if accounts %}
- +
diff --git a/zerver/lib/users.py b/zerver/lib/users.py index 1c8304cdd2..1f39b93e81 100644 --- a/zerver/lib/users.py +++ b/zerver/lib/users.py @@ -185,8 +185,8 @@ def access_user_by_id(user_profile: UserProfile, user_id: int, def get_accounts_for_email(email: str) -> List[Dict[str, Optional[str]]]: profiles = UserProfile.objects.select_related('realm').filter(delivery_email__iexact=email.strip(), is_active=True, - is_bot=False, - realm__deactivated=False) + realm__deactivated=False, + is_bot=False).order_by('date_joined') return [{"realm_name": profile.realm.name, "string_id": profile.realm.string_id, "full_name": profile.full_name, diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py index ee4af33197..b2b57e9f17 100644 --- a/zerver/tests/test_signup.py +++ b/zerver/tests/test_signup.py @@ -2221,6 +2221,17 @@ class UserSignUpTest(ZulipTestCase): confirmation_url = self.get_confirmation_url_from_outbox(email) result = self.client_get(confirmation_url, subdomain=subdomain) self.assertEqual(result.status_code, 200) + + result = self.client_post( + '/accounts/register/', + {'password': password, + 'key': find_key_by_email(email), + 'from_confirmation': '1'}, + subdomain=subdomain) + self.assert_in_success_response(["Import settings from existing Zulip account", + "selected >\n Zulip Dev", + "We just need you to do one last thing."], result) + result = self.submit_reg_form_for_user(email, password, source_realm="zulip", HTTP_HOST=subdomain + ".testserver")