mirror of https://github.com/zulip/zulip.git
custom_profile_fields: Make required field optional during update.
This commit is contained in:
parent
8c30b61201
commit
1abd356a91
|
@ -22,10 +22,10 @@ format used by the Zulip server that they are interacting with.
|
|||
|
||||
**Feature level 252**
|
||||
|
||||
* `PATCH /realm/profile_fields/{field_id}`: `name`, `hint`, `display_in_profile_summary`
|
||||
and `field_data` fields are now optional during an update. Previously we required
|
||||
the clients to populate the fields in the PATCH request even if there was no
|
||||
change to those fields' values.
|
||||
* `PATCH /realm/profile_fields/{field_id}`: `name`, `hint`, `display_in_profile_summary`,
|
||||
`required` and `field_data` fields are now optional during an update. Previously we
|
||||
required the clients to populate the fields in the PATCH request even if there was
|
||||
no change to those fields' values.
|
||||
|
||||
**Feature level 251**
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.9.3"
|
|||
# Changes should be accompanied by documentation explaining what the
|
||||
# new level means in api_docs/changelog.md, as well as "**Changes**"
|
||||
# entries in the endpoint's documentation in `zulip.yaml`.
|
||||
API_FEATURE_LEVEL = 251
|
||||
API_FEATURE_LEVEL = 252
|
||||
|
||||
# Bump the minor PROVISION_VERSION to indicate that folks should provision
|
||||
# only when going from an old version of the code to a newer version. Bump
|
||||
|
|
|
@ -105,14 +105,14 @@ def try_update_realm_custom_profile_field(
|
|||
hint: Optional[str] = None,
|
||||
field_data: Optional[ProfileFieldData] = None,
|
||||
display_in_profile_summary: Optional[bool] = None,
|
||||
required: bool = False,
|
||||
required: Optional[bool] = None,
|
||||
) -> None:
|
||||
if name is not None:
|
||||
field.name = name
|
||||
if hint is not None:
|
||||
field.hint = hint
|
||||
|
||||
field.required = required
|
||||
if required is not None:
|
||||
field.required = required
|
||||
if display_in_profile_summary is not None:
|
||||
field.display_in_profile_summary = display_in_profile_summary
|
||||
|
||||
|
|
|
@ -528,8 +528,7 @@ class UpdateCustomProfileFieldTest(CustomProfileFieldTestCase):
|
|||
},
|
||||
)
|
||||
self.assert_json_success(result)
|
||||
|
||||
field = CustomProfileField.objects.get(id=field.id, realm=realm)
|
||||
field.refresh_from_db()
|
||||
self.assertEqual(CustomProfileField.objects.count(), self.original_count)
|
||||
self.assertEqual(field.name, "New phone number")
|
||||
self.assertEqual(field.hint, "New contact number")
|
||||
|
@ -537,6 +536,18 @@ class UpdateCustomProfileFieldTest(CustomProfileFieldTestCase):
|
|||
self.assertEqual(field.display_in_profile_summary, True)
|
||||
self.assertEqual(field.required, True)
|
||||
|
||||
# Not sending required should not set it to false.
|
||||
result = self.client_patch(
|
||||
f"/json/realm/profile_fields/{field.id}",
|
||||
info={
|
||||
"hint": "New hint",
|
||||
},
|
||||
)
|
||||
self.assert_json_success(result)
|
||||
field.refresh_from_db()
|
||||
self.assertEqual(field.hint, "New hint")
|
||||
self.assertEqual(field.required, True)
|
||||
|
||||
result = self.client_patch(
|
||||
f"/json/realm/profile_fields/{field.id}",
|
||||
info={"name": "Name ", "display_in_profile_summary": "true"},
|
||||
|
|
|
@ -247,7 +247,7 @@ def update_realm_custom_profile_field(
|
|||
field_data: Optional[ProfileFieldData] = REQ(
|
||||
default=None, json_validator=check_profile_field_data
|
||||
),
|
||||
required: bool = REQ(default=False, json_validator=check_bool),
|
||||
required: Optional[bool] = REQ(default=None, json_validator=check_bool),
|
||||
display_in_profile_summary: Optional[bool] = REQ(default=None, json_validator=check_bool),
|
||||
) -> HttpResponse:
|
||||
realm = user_profile.realm
|
||||
|
|
Loading…
Reference in New Issue