Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

custom profile fields: Rename "SELECT" field validator.

tushar91298a6bdbd4ccd
diff --git a/zerver/lib/validator.py b/zerver/lib/validator.py
index 34ccacad45a..7cb06ab428c 100644
--- a/zerver/lib/validator.py
+++ b/zerver/lib/validator.py
@@ -357,7 +357,7 @@ def check_external_account_url_pattern(var_name: str, val: object) -> str:
return s
-def validate_choice_field_data(field_data: ProfileFieldData) -> Dict[str, Dict[str, str]]:
+def validate_select_field_data(field_data: ProfileFieldData) -> Dict[str, Dict[str, str]]:
"""
This function is used to validate the data sent to the server while
creating/editing choices of the choice field in Organization settings.
@@ -379,7 +379,7 @@ def validate_choice_field_data(field_data: ProfileFieldData) -> Dict[str, Dict[s
return cast(Dict[str, Dict[str, str]], field_data)
-def validate_choice_field(var_name: str, field_data: str, value: object) -> str:
+def validate_select_field(var_name: str, field_data: str, value: object) -> str:
"""
This function is used to validate the value selected by the user against a
choice field. This is not used to validate admin data.
diff --git a/zerver/models.py b/zerver/models.py
index 60cf3f67b64..829b0f9a5e3 100644
--- a/zerver/models.py
+++ b/zerver/models.py
@@ -88,7 +88,7 @@ from zerver.lib.validator import (
check_long_string,
check_short_string,
check_url,
- validate_choice_field,
+ validate_select_field,
)
MAX_TOPIC_NAME_LENGTH = 60
@@ -3308,7 +3308,7 @@ class CustomProfileField(models.Model):
# and value argument. i.e. SELECT require field_data, USER require
# realm as argument.
SELECT_FIELD_TYPE_DATA: List[ExtendedFieldElement] = [
- (SELECT, ugettext_lazy("List of options"), validate_choice_field, str, "SELECT"),
+ (SELECT, ugettext_lazy("List of options"), validate_select_field, str, "SELECT"),
]
USER_FIELD_TYPE_DATA: List[UserFieldElement] = [
(USER, ugettext_lazy("Person picker"), check_valid_user_ids, ast.literal_eval, "USER"),
diff --git a/zerver/views/custom_profile_fields.py b/zerver/views/custom_profile_fields.py
index 61b9b72c351..4d90e483851 100644
--- a/zerver/views/custom_profile_fields.py
+++ b/zerver/views/custom_profile_fields.py
@@ -29,7 +29,7 @@ from zerver.lib.validator import (
check_list,
check_string,
check_union,
- validate_choice_field_data,
+ validate_select_field_data,
)
from zerver.models import CustomProfileField, UserProfile, custom_profile_fields_for_realm
@@ -62,7 +62,7 @@ def validate_custom_field_data(field_type: int, field_data: ProfileFieldData) ->
# Choice type field must have at least have one choice
if len(field_data) < 1:
raise JsonableError(_("Field must have at least one choice."))
- validate_choice_field_data(field_data)
+ validate_select_field_data(field_data)
elif field_type == CustomProfileField.EXTERNAL_ACCOUNT:
validate_external_account_field_data(field_data)
except ValidationError as error: