mirror of https://github.com/zulip/zulip.git
custom_profile_fields: Display_in_profile_summary optional for update.
This commit is contained in:
parent
137776b092
commit
8c30b61201
|
@ -22,10 +22,10 @@ format used by the Zulip server that they are interacting with.
|
||||||
|
|
||||||
**Feature level 252**
|
**Feature level 252**
|
||||||
|
|
||||||
* `PATCH /realm/profile_fields/{field_id}`: `name`, `hint` and `field_data` fields are
|
* `PATCH /realm/profile_fields/{field_id}`: `name`, `hint`, `display_in_profile_summary`
|
||||||
now optional during an update. Previously we required the clients to populate
|
and `field_data` fields are now optional during an update. Previously we required
|
||||||
the fields in the PATCH request even if there was no change to those fields'
|
the clients to populate the fields in the PATCH request even if there was no
|
||||||
values.
|
change to those fields' values.
|
||||||
|
|
||||||
**Feature level 251**
|
**Feature level 251**
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ def try_update_realm_custom_profile_field(
|
||||||
name: Optional[str] = None,
|
name: Optional[str] = None,
|
||||||
hint: Optional[str] = None,
|
hint: Optional[str] = None,
|
||||||
field_data: Optional[ProfileFieldData] = None,
|
field_data: Optional[ProfileFieldData] = None,
|
||||||
display_in_profile_summary: bool = False,
|
display_in_profile_summary: Optional[bool] = None,
|
||||||
required: bool = False,
|
required: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
if name is not None:
|
if name is not None:
|
||||||
|
@ -112,8 +112,9 @@ def try_update_realm_custom_profile_field(
|
||||||
if hint is not None:
|
if hint is not None:
|
||||||
field.hint = hint
|
field.hint = hint
|
||||||
|
|
||||||
field.display_in_profile_summary = display_in_profile_summary
|
|
||||||
field.required = required
|
field.required = required
|
||||||
|
if display_in_profile_summary is not None:
|
||||||
|
field.display_in_profile_summary = display_in_profile_summary
|
||||||
|
|
||||||
if field.field_type in (
|
if field.field_type in (
|
||||||
CustomProfileField.SELECT,
|
CustomProfileField.SELECT,
|
||||||
|
|
|
@ -581,6 +581,18 @@ class UpdateCustomProfileFieldTest(CustomProfileFieldTestCase):
|
||||||
)
|
)
|
||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
|
|
||||||
|
# Not sending display_in_profile_summary should not set it to false.
|
||||||
|
result = self.client_patch(
|
||||||
|
f"/json/realm/profile_fields/{field.id}",
|
||||||
|
info={
|
||||||
|
"hint": "Fav editor",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
field.refresh_from_db()
|
||||||
|
self.assertEqual(field.hint, "Fav editor")
|
||||||
|
self.assertEqual(field.display_in_profile_summary, True)
|
||||||
|
self.assert_json_success(result)
|
||||||
|
|
||||||
field = CustomProfileField.objects.get(name="Birthday", realm=realm)
|
field = CustomProfileField.objects.get(name="Birthday", realm=realm)
|
||||||
result = self.client_patch(
|
result = self.client_patch(
|
||||||
f"/json/realm/profile_fields/{field.id}",
|
f"/json/realm/profile_fields/{field.id}",
|
||||||
|
|
|
@ -118,7 +118,7 @@ def validate_custom_profile_field(
|
||||||
|
|
||||||
def validate_custom_profile_field_update(
|
def validate_custom_profile_field_update(
|
||||||
field: CustomProfileField,
|
field: CustomProfileField,
|
||||||
display_in_profile_summary: bool,
|
display_in_profile_summary: Optional[bool] = None,
|
||||||
field_data: Optional[ProfileFieldData] = None,
|
field_data: Optional[ProfileFieldData] = None,
|
||||||
name: Optional[str] = None,
|
name: Optional[str] = None,
|
||||||
hint: Optional[str] = None,
|
hint: Optional[str] = None,
|
||||||
|
@ -134,6 +134,8 @@ def validate_custom_profile_field_update(
|
||||||
field_data = {}
|
field_data = {}
|
||||||
else:
|
else:
|
||||||
field_data = orjson.loads(field.field_data)
|
field_data = orjson.loads(field.field_data)
|
||||||
|
if display_in_profile_summary is None:
|
||||||
|
display_in_profile_summary = field.display_in_profile_summary
|
||||||
|
|
||||||
assert field_data is not None
|
assert field_data is not None
|
||||||
validate_custom_profile_field(
|
validate_custom_profile_field(
|
||||||
|
@ -245,8 +247,8 @@ def update_realm_custom_profile_field(
|
||||||
field_data: Optional[ProfileFieldData] = REQ(
|
field_data: Optional[ProfileFieldData] = REQ(
|
||||||
default=None, json_validator=check_profile_field_data
|
default=None, json_validator=check_profile_field_data
|
||||||
),
|
),
|
||||||
display_in_profile_summary: bool = REQ(default=False, json_validator=check_bool),
|
|
||||||
required: bool = REQ(default=False, json_validator=check_bool),
|
required: bool = REQ(default=False, json_validator=check_bool),
|
||||||
|
display_in_profile_summary: Optional[bool] = REQ(default=None, json_validator=check_bool),
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
realm = user_profile.realm
|
realm = user_profile.realm
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue