confirmation: Rename create_confirmation_link realm_creation arg.

This commit is contained in:
Mateusz Mandera 2023-12-07 22:38:44 +01:00 committed by Tim Abbott
parent b4b9f29e21
commit bba02044f5
3 changed files with 9 additions and 5 deletions

View File

@ -117,13 +117,17 @@ def create_confirmation_link(
*, *,
validity_in_minutes: Union[Optional[int], UnspecifiedValue] = UnspecifiedValue(), validity_in_minutes: Union[Optional[int], UnspecifiedValue] = UnspecifiedValue(),
url_args: Mapping[str, str] = {}, url_args: Mapping[str, str] = {},
realm_creation: bool = False, no_associated_realm_object: bool = False,
) -> str: ) -> str:
# validity_in_minutes is an override for the default values which are # validity_in_minutes is an override for the default values which are
# determined by the confirmation_type - its main purpose is for use # determined by the confirmation_type - its main purpose is for use
# in tests which may want to have control over the exact expiration time. # in tests which may want to have control over the exact expiration time.
key = generate_key() key = generate_key()
if realm_creation:
# Some confirmation objects, like those for realm creation or those used
# for the self-hosted management flows, are not associated with a realm
# hosted by this Zulip server.
if no_associated_realm_object:
realm = None realm = None
else: else:
assert not isinstance(obj, PreregistrationRealm) assert not isinstance(obj, PreregistrationRealm)

View File

@ -71,7 +71,7 @@ def register_development_realm(request: HttpRequest) -> HttpResponse:
email, realm_name, realm_subdomain, realm_type, realm_default_language email, realm_name, realm_subdomain, realm_type, realm_default_language
) )
activation_url = create_confirmation_link( activation_url = create_confirmation_link(
prereg_realm, Confirmation.REALM_CREATION, realm_creation=True prereg_realm, Confirmation.REALM_CREATION, no_associated_realm_object=True
) )
key = activation_url.split("/")[-1] key = activation_url.split("/")[-1]
# Need to add test data to POST request as it doesn't originally contain the required parameters # Need to add test data to POST request as it doesn't originally contain the required parameters
@ -104,7 +104,7 @@ def register_demo_development_realm(request: HttpRequest) -> HttpResponse:
email, realm_name, realm_subdomain, realm_type, realm_default_language email, realm_name, realm_subdomain, realm_type, realm_default_language
) )
activation_url = create_confirmation_link( activation_url = create_confirmation_link(
prereg_realm, Confirmation.REALM_CREATION, realm_creation=True prereg_realm, Confirmation.REALM_CREATION, no_associated_realm_object=True
) )
key = activation_url.split("/")[-1] key = activation_url.split("/")[-1]
# Need to add test data to POST request as it doesn't originally contain the required parameters # Need to add test data to POST request as it doesn't originally contain the required parameters

View File

@ -753,7 +753,7 @@ def prepare_realm_activation_url(
email, realm_name, string_id, org_type, default_language email, realm_name, string_id, org_type, default_language
) )
activation_url = create_confirmation_link( activation_url = create_confirmation_link(
prereg_realm, Confirmation.REALM_CREATION, realm_creation=True prereg_realm, Confirmation.REALM_CREATION, no_associated_realm_object=True
) )
if settings.DEVELOPMENT: if settings.DEVELOPMENT: