slack_import: Fix bug when need_select_realm_owner is not set.

When selecting the realm owner is not needed in the realm creation from
Slack flow, we don't set need_select_realm_owner value on the
preregistration_realm object. Thus, this codepath cannot expect to
always find the key - and instead should use .get(), defaulting to False.
This commit is contained in:
Mateusz Mandera
2025-06-18 18:11:36 +08:00
committed by Tim Abbott
parent bbd0f6e11c
commit 75da563776

View File

@@ -1094,15 +1094,15 @@ def realm_import_status(
pass
return json_success(request, {"status": _("Importing converted Slack data…")})
if (
not preregistration_realm.data_import_metadata["need_select_realm_owner"]
and preregistration_realm.created_realm is None
):
need_select_realm_owner = preregistration_realm.data_import_metadata.get(
"need_select_realm_owner", False
)
if not need_select_realm_owner and preregistration_realm.created_realm is None:
return json_success(request, {"status": _("Finalizing import…")})
# We have a non-deactivated realm and it's linked to the prereg key
result = {"status": _("Done!")}
if not preregistration_realm.data_import_metadata["need_select_realm_owner"]:
if not need_select_realm_owner:
importing_user = get_user_by_delivery_email(preregistration_realm.email, realm)
# Sanity check that this is a normal user account that can login.
assert (