From 072f234269129984a58f4d65600f403423f9bb7b Mon Sep 17 00:00:00 2001 From: Mateusz Mandera Date: Sat, 5 Jul 2025 01:54:58 +0800 Subject: [PATCH] confirmation: Rename REALM_CREATION to NEW_REALM_USER_REGISTRATION. Clears up some naming confusion - `REALM_CREATION_LINK_VALIDITY_DAYS` is a setting which describes the validaty period of RealmCreationKey, not of Confirmation with REALM_CREATION type. Now that the latter is called NEW_REALM_USER_REGISTRATION, there should be no confusion about this. --- confirmation/models.py | 6 +++--- corporate/views/support.py | 2 +- templates/corporate/support/support.html | 2 +- zerver/tests/test_slack_importer.py | 4 +++- zerver/views/development/registration.py | 4 ++-- zerver/views/registration.py | 10 +++++----- zerver/views/tusd.py | 2 +- 7 files changed, 16 insertions(+), 14 deletions(-) diff --git a/confirmation/models.py b/confirmation/models.py index f0bd55c0a8..7dfbd7ac21 100644 --- a/confirmation/models.py +++ b/confirmation/models.py @@ -232,7 +232,7 @@ class Confirmation(models.Model): UNSUBSCRIBE = 4 SERVER_REGISTRATION = 5 MULTIUSE_INVITE = 6 - REALM_CREATION = 7 + NEW_REALM_USER_REGISTRATION = 7 REALM_REACTIVATION = 8 REMOTE_SERVER_BILLING_LEGACY_LOGIN = 9 REMOTE_REALM_BILLING_LEGACY_LOGIN = 10 @@ -272,7 +272,7 @@ _properties = { Confirmation.MULTIUSE_INVITE: ConfirmationType( "join", validity_in_days=settings.INVITATION_LINK_VALIDITY_DAYS ), - Confirmation.REALM_CREATION: ConfirmationType("get_prereg_key_and_redirect"), + Confirmation.NEW_REALM_USER_REGISTRATION: ConfirmationType("get_prereg_key_and_redirect"), Confirmation.REALM_REACTIVATION: ConfirmationType("realm_reactivation_get"), } if settings.ZILENCER_ENABLED: @@ -298,7 +298,7 @@ def one_click_unsubscribe_link(user_profile: UserProfile, email_type: str) -> st # management command. # Note that being validated here will just allow the user to access the create_realm # form, where they will enter their email and go through the regular -# Confirmation.REALM_CREATION pathway. +# Confirmation.NEW_REALM_USER_REGISTRATION pathway. # Arguably RealmCreationKey should just be another ConfirmationObjT and we should # add another Confirmation.type for this; it's this way for historical reasons. diff --git a/corporate/views/support.py b/corporate/views/support.py index 7bd5b2b6d3..26936877ae 100644 --- a/corporate/views/support.py +++ b/corporate/views/support.py @@ -632,7 +632,7 @@ def support( user.id for user in PreregistrationRealm.objects.filter(email__in=key_words) ] confirmations += get_confirmations( - [Confirmation.REALM_CREATION], + [Confirmation.NEW_REALM_USER_REGISTRATION], preregistration_realm_ids, hostname=request.get_host(), ) diff --git a/templates/corporate/support/support.html b/templates/corporate/support/support.html index b6d25e2788..f87ea84955 100644 --- a/templates/corporate/support/support.html +++ b/templates/corporate/support/support.html @@ -76,7 +76,7 @@ {% set email = object.email %} {% set realm = object.realm %} {% set show_realm_details = True %} - {% elif confirmation.type == Confirmation.REALM_CREATION %} + {% elif confirmation.type == Confirmation.NEW_REALM_USER_REGISTRATION %}

Realm creation

{% set email = object.email %} {% set show_realm_details = False %} diff --git a/zerver/tests/test_slack_importer.py b/zerver/tests/test_slack_importer.py index 5ea5e27ac7..9e8b26d879 100644 --- a/zerver/tests/test_slack_importer.py +++ b/zerver/tests/test_slack_importer.py @@ -2273,7 +2273,9 @@ by Pieter # Confirmation key at this point is marked, used but since we # are mocking the process, we need to do it manually here. - get_object_from_key(confirmation_key, [Confirmation.REALM_CREATION], mark_object_used=True) + get_object_from_key( + confirmation_key, [Confirmation.NEW_REALM_USER_REGISTRATION], mark_object_used=True + ) result = self.client_get(f"/json/realm/import/status/{confirmation_key}") self.assert_in_success_response(["No users matching provided email"], result) diff --git a/zerver/views/development/registration.py b/zerver/views/development/registration.py index 9dad20acb2..4ed76d44ff 100644 --- a/zerver/views/development/registration.py +++ b/zerver/views/development/registration.py @@ -71,7 +71,7 @@ def register_development_realm(request: HttpRequest) -> HttpResponse: email, realm_name, realm_subdomain, realm_type, realm_default_language ) activation_url = create_confirmation_link( - prereg_realm, Confirmation.REALM_CREATION, no_associated_realm_object=True + prereg_realm, Confirmation.NEW_REALM_USER_REGISTRATION, no_associated_realm_object=True ) key = activation_url.split("/")[-1] # Need to add test data to POST request as it doesn't originally contain the required parameters @@ -106,7 +106,7 @@ def register_demo_development_realm(request: HttpRequest) -> HttpResponse: email, realm_name, realm_subdomain, realm_type, realm_default_language ) activation_url = create_confirmation_link( - prereg_realm, Confirmation.REALM_CREATION, no_associated_realm_object=True + prereg_realm, Confirmation.NEW_REALM_USER_REGISTRATION, no_associated_realm_object=True ) key = activation_url.split("/")[-1] # Need to add test data to POST request as it doesn't originally contain the required parameters diff --git a/zerver/views/registration.py b/zerver/views/registration.py index 28d5e782f2..73c22c932d 100644 --- a/zerver/views/registration.py +++ b/zerver/views/registration.py @@ -194,7 +194,7 @@ def check_prereg_key( confirmation_types = [ Confirmation.USER_REGISTRATION, Confirmation.INVITATION, - Confirmation.REALM_CREATION, + Confirmation.NEW_REALM_USER_REGISTRATION, ] prereg_object = get_object_from_key( @@ -203,7 +203,7 @@ def check_prereg_key( assert isinstance(prereg_object, PreregistrationRealm | PreregistrationUser) confirmation_obj = prereg_object.confirmation.get() - realm_creation = confirmation_obj.type == Confirmation.REALM_CREATION + realm_creation = confirmation_obj.type == Confirmation.NEW_REALM_USER_REGISTRATION if realm_creation: assert isinstance(prereg_object, PreregistrationRealm) @@ -998,7 +998,7 @@ def prepare_realm_activation_url( import_form, ) activation_url = create_confirmation_link( - prereg_realm, Confirmation.REALM_CREATION, no_associated_realm_object=True + prereg_realm, Confirmation.NEW_REALM_USER_REGISTRATION, no_associated_realm_object=True ) if settings.DEVELOPMENT: @@ -1052,7 +1052,7 @@ def realm_import_status( try: preregistration_realm = get_object_from_key( confirmation_key, - [Confirmation.REALM_CREATION], + [Confirmation.NEW_REALM_USER_REGISTRATION], mark_object_used=False, allow_used=True, ) @@ -1147,7 +1147,7 @@ def realm_import_post_process( try: preregistration_realm = get_object_from_key( confirmation_key, - [Confirmation.REALM_CREATION], + [Confirmation.NEW_REALM_USER_REGISTRATION], mark_object_used=False, allow_used=True, ) diff --git a/zerver/views/tusd.py b/zerver/views/tusd.py index 23b4db7f8f..0e902a1cf9 100644 --- a/zerver/views/tusd.py +++ b/zerver/views/tusd.py @@ -320,7 +320,7 @@ def handle_tusd_hook( return reject_upload("Unauthenticated upload", 401) try: prereg_object = get_object_from_key( - key, [Confirmation.REALM_CREATION], mark_object_used=False + key, [Confirmation.NEW_REALM_USER_REGISTRATION], mark_object_used=False ) except ConfirmationKeyError: return reject_upload("Unauthenticated upload", 401)