registration: Use a loop to set extra content value.

This commit is contained in:
Aman Agrawal
2025-09-24 11:59:42 +05:30
committed by Tim Abbott
parent 8e385661c5
commit c6bf35b392

View File

@@ -632,34 +632,19 @@ def registration_helper(
form.cleaned_data["how_realm_creator_found_zulip"] form.cleaned_data["how_realm_creator_found_zulip"]
] ]
how_realm_creator_found_zulip_extra_context = "" how_realm_creator_found_zulip_extra_context = ""
extra_context_options = {
"other": "how_realm_creator_found_zulip_other_text",
"ad": "how_realm_creator_found_zulip_where_ad",
"existing_user": "how_realm_creator_found_zulip_which_organization",
"review_site": "how_realm_creator_found_zulip_review_site",
}
for option, field_name in extra_context_options.items():
if ( if (
how_realm_creator_found_zulip how_realm_creator_found_zulip
== RealmAuditLog.HOW_REALM_CREATOR_FOUND_ZULIP_OPTIONS["other"] == RealmAuditLog.HOW_REALM_CREATOR_FOUND_ZULIP_OPTIONS[option]
): ):
how_realm_creator_found_zulip_extra_context = form.cleaned_data[ how_realm_creator_found_zulip_extra_context = form.cleaned_data[field_name]
"how_realm_creator_found_zulip_other_text" break
]
elif (
how_realm_creator_found_zulip
== RealmAuditLog.HOW_REALM_CREATOR_FOUND_ZULIP_OPTIONS["ad"]
):
how_realm_creator_found_zulip_extra_context = form.cleaned_data[
"how_realm_creator_found_zulip_where_ad"
]
elif (
how_realm_creator_found_zulip
== RealmAuditLog.HOW_REALM_CREATOR_FOUND_ZULIP_OPTIONS["existing_user"]
):
how_realm_creator_found_zulip_extra_context = form.cleaned_data[
"how_realm_creator_found_zulip_which_organization"
]
elif (
how_realm_creator_found_zulip
== RealmAuditLog.HOW_REALM_CREATOR_FOUND_ZULIP_OPTIONS["review_site"]
): # nocoverage
how_realm_creator_found_zulip_extra_context = form.cleaned_data[
"how_realm_creator_found_zulip_review_site"
]
realm = do_create_realm( realm = do_create_realm(
string_id, string_id,