mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
subdomains: Don't compute realm_subdomain if not needed.
We were doing an unnecessary database query on every user registration checking the availability of the user's subdomain, when in fact this is only required for realm creation.
This commit is contained in:
@@ -99,9 +99,11 @@ class RegistrationForm(forms.Form):
|
||||
|
||||
def clean_realm_subdomain(self):
|
||||
# type: () -> str
|
||||
if not self.realm_creation:
|
||||
return Realm.SUBDOMAIN_FOR_ROOT_DOMAIN
|
||||
subdomain = self.cleaned_data['realm_subdomain']
|
||||
if not subdomain:
|
||||
return ''
|
||||
return Realm.SUBDOMAIN_FOR_ROOT_DOMAIN
|
||||
check_subdomain_available(subdomain)
|
||||
return subdomain
|
||||
|
||||
|
||||
@@ -305,7 +305,7 @@ class LoginTest(ZulipTestCase):
|
||||
with queries_captured() as queries:
|
||||
self.register(self.nonreg_email('test'), "test")
|
||||
# Ensure the number of queries we make is not O(streams)
|
||||
self.assert_length(queries, 69)
|
||||
self.assert_length(queries, 68)
|
||||
user_profile = self.nonreg_user('test')
|
||||
self.assertEqual(get_session_dict_user(self.client.session), user_profile.id)
|
||||
self.assertFalse(user_profile.enable_stream_desktop_notifications)
|
||||
|
||||
Reference in New Issue
Block a user