registration: Rename source_realm field to source_realm_id.

Now that we are passing source realm's id instead of string_id in
source realm selector, it makes sense to rename the "source_realm" field
to "source_realm_id".
This commit is contained in:
Siddharth Asthana
2020-12-05 00:15:58 +05:30
committed by Tim Abbott
parent 4262c04db1
commit 55da3329ef
4 changed files with 11 additions and 11 deletions

View File

@@ -107,18 +107,18 @@ Form is validated both client-side using jquery-validate (see signup.js) and ser
{% if accounts %}
<div class="input-box">
<label for="source_realm" class="inline-block">{{ _('Import settings from existing Zulip account') }}</label>
<label for="source_realm_id" class="inline-block">{{ _('Import settings from existing Zulip account') }}</label>
</div>
<div id="source_realm_select_section" class="input-group m-10 inline-block">
<select class="select" name="source_realm" id="source_realm_select">
<select class="select" name="source_realm_id" id="source_realm_select">
<option value=""
{% if "source_realm" in form.data and form.data["source_realm"] == "" %}selected {% endif %}>
{% if "source_realm_id" in form.data and form.data["source_realm_id"] == "" %}selected {% endif %}>
{{ _('Don&rsquo;t import settings') }}
</option>
{% for account in accounts %}
<option value="{{ account.realm_id }}" data-full-name="{{account.full_name}}" data-avatar="{{account.avatar}}"
{% if ("source_realm" in form.data and account.realm_id == form.data["source_realm"]|int)
or ("source_realm" not in form.data and loop.index0 == 0) %} selected {% endif %}>
{% if ("source_realm_id" in form.data and account.realm_id == form.data["source_realm_id"]|int)
or ("source_realm_id" not in form.data and loop.index0 == 0) %} selected {% endif %}>
{{ account.realm_name }}
</option>
{% endfor %}

View File

@@ -611,7 +611,7 @@ Output:
timezone: str = "",
realm_in_root_domain: Optional[str] = None,
default_stream_groups: Sequence[str] = [],
source_realm: str = "",
source_realm_id: str = "",
key: Optional[str] = None,
**kwargs: Any,
) -> HttpResponse:
@@ -635,7 +635,7 @@ Output:
"terms": True,
"from_confirmation": from_confirmation,
"default_stream_group": default_stream_groups,
"source_realm": source_realm,
"source_realm_id": source_realm_id,
}
if realm_in_root_domain is not None:
payload["realm_in_root_domain"] = realm_in_root_domain

View File

@@ -3611,7 +3611,7 @@ class UserSignUpTest(InviteUserBase):
result = self.client_get(confirmation_url, subdomain=subdomain)
self.assertEqual(result.status_code, 200)
result = self.submit_reg_form_for_user(
email, password, source_realm="", HTTP_HOST=subdomain + ".testserver"
email, password, source_realm_id="", HTTP_HOST=subdomain + ".testserver"
)
hamlet = get_user(self.example_email("hamlet"), realm)
@@ -3667,7 +3667,7 @@ class UserSignUpTest(InviteUserBase):
result = self.submit_reg_form_for_user(
email,
password,
source_realm=str(hamlet_in_zulip.realm.id),
source_realm_id=str(hamlet_in_zulip.realm.id),
HTTP_HOST=subdomain + ".testserver",
)
@@ -3750,7 +3750,7 @@ class UserSignUpTest(InviteUserBase):
password,
realm_subdomain=realm.string_id,
realm_name=realm_name,
source_realm=str(realm.id),
source_realm_id=str(realm.id),
)
self.assert_in_success_response(
[

View File

@@ -311,7 +311,7 @@ def accounts_register(request: HttpRequest) -> HttpResponse:
if "timezone" in request.POST and request.POST["timezone"] in pytz.all_timezones_set:
timezone = request.POST["timezone"]
if "source_realm" in request.POST and request.POST["source_realm"] != "":
if "source_realm_id" in request.POST and request.POST["source_realm_id"] != "":
source_profile: Optional[UserProfile] = get_source_profile(
email, int(request.POST["source_realm_id"])
)