Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
google_analytics: Track realm registration separately from user signup.
Aman Agrawalc928c876453f
diff --git a/templates/confirmation/confirm_preregistrationuser.html b/templates/confirmation/confirm_preregistrationuser.htmlindex fba8331e38c..9e6efdfafb6 100644--- a/templates/confirmation/confirm_preregistrationuser.html+++ b/templates/confirmation/confirm_preregistrationuser.html@@ -13,7 +13,7 @@ requisite context to make a useful signup form. Therefore, we immediatelypost to another view which executes in our code to produce the desired form.#}-<form id="register" action="/accounts/register/" method="post">+<form id="register" action="{{ registration_url }}" method="post">{{ csrf_input }}<input type="hidden" value="{{ key }}" name="key"/><input type="hidden" value="1" name="from_confirmation"/>diff --git a/zerver/tests/test_management_commands.py b/zerver/tests/test_management_commands.pyindex 0d59668c1c8..d31dcd6ef8a 100644--- a/zerver/tests/test_management_commands.py+++ b/zerver/tests/test_management_commands.py@@ -306,7 +306,7 @@ class TestGenerateRealmCreationLink(ZulipTestCase):# Bypass sending mail for confirmation, go straight to creation formresult = self.client_get(result["Location"])- self.assert_in_response('action="/accounts/register/"', result)+ self.assert_in_response('action="/realm/register/"', result)# Original link is now deadresult = self.client_get(generated_link)diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.pyindex 78e434a011a..f80553a3578 100644--- a/zerver/tests/test_signup.py+++ b/zerver/tests/test_signup.py@@ -3625,7 +3625,7 @@ class RealmCreationTest(ZulipTestCase):"key": find_key_by_email(email),"from_confirmation": "1",}- result = self.client_post("/accounts/register/", payload)+ result = self.client_post("/realm/register/", payload)# Assert that the form did not prompt the user for enabling# marketing emails.self.assert_not_in_success_response(['input id="id_enable_marketing_emails"'], result)diff --git a/zerver/views/registration.py b/zerver/views/registration.pyindex 3b844090800..5293ea30363 100644--- a/zerver/views/registration.py+++ b/zerver/views/registration.py@@ -116,14 +116,24 @@ def get_prereg_key_and_redirect(accidentally adding an extra character after pasting)."""try:- check_prereg_key(request, confirmation_key)+ prereg_user = check_prereg_key(request, confirmation_key)except ConfirmationKeyError as e:return render_confirmation_key_error(request, e)+ realm_creation = prereg_user.realm_creation++ registration_url = reverse("accounts_register")+ if realm_creation:+ registration_url = reverse("realm_register")+return render(request,"confirmation/confirm_preregistrationuser.html",- context={"key": confirmation_key, "full_name": full_name},+ context={+ "key": confirmation_key,+ "full_name": full_name,+ "registration_url": registration_url,+ },)@@ -150,8 +160,17 @@ def check_prereg_key(request: HttpRequest, confirmation_key: str) -> Preregistra@add_google_analytics@require_post+def realm_register(*args: Any, **kwargs: Any) -> HttpResponse:+ return registration_helper(*args, **kwargs)+++@require_post+def accounts_register(*args: Any, **kwargs: Any) -> HttpResponse:+ return registration_helper(*args, **kwargs)++@has_request_variables-def accounts_register(+def registration_helper(request: HttpRequest,key: str = REQ(default=""),timezone: str = REQ(default="", converter=to_timezone_or_empty),diff --git a/zproject/urls.py b/zproject/urls.pyindex 71805a2a5b5..18a6175e668 100644--- a/zproject/urls.py+++ b/zproject/urls.py@@ -127,6 +127,7 @@ from zerver.views.registration import (get_prereg_key_and_redirect,new_realm_send_confirm,realm_redirect,+ realm_register,signup_send_confirm,)from zerver.views.report import (@@ -579,6 +580,7 @@ i18n_urls = [name="new_realm_send_confirm",),path("accounts/register/", accounts_register, name="accounts_register"),+ path("realm/register/", realm_register, name="realm_register"),path("accounts/do_confirm/<confirmation_key>",get_prereg_key_and_redirect,