zulip/zerver
Steve Howell 80c057d91d REQ: Use check_dict_only in update_user_backend.
Update the REQ check for profile_data in
update_user_backend by tweaking `check_profile_data`
to use `check_dict_only`.

Here is the relevant URL:

    path('users/<int:user_id>', rest_dispatch,
         {'GET': 'zerver.views.users.get_members_backend',

It would be nice to unify the validator
for these two views, but they are different:

    update_user_backend
    update_user_custom_profile_data

It's not completely clear to me why update_user_backend
seems to support a superset of the functionality
of `update_user_custom_profile_data`, but it has
this code to allow you to remove custom profile fields:

    clean_profile_data = []
    for entry in profile_data:
        assert isinstance(entry["id"], int)
        if entry["value"] is None or not entry["value"]:
            field_id = entry["id"]
            check_remove_custom_profile_field_value(target, field_id)
        else:
            clean_profile_data.append({
                "id": entry["id"],
                "value": entry["value"],
            })

Whereas the other view is much simpler:

def update_user_custom_profile_data(
    <snip>
) -> HttpResponse:

    validate_user_custom_profile_data(user_profile.realm.id, data)
    do_update_user_custom_profile_data_if_changed(user_profile, data)
    # We need to call this explicitly otherwise constraints are not check
    return json_success()
2020-06-25 10:54:15 -07:00
..
data_import mypy: Type simple generators as Iterator, not Iterable. 2020-06-23 11:29:54 -07:00
lib check_list: Make sub_validator a required argument. 2020-06-24 15:04:59 -07:00
management mypy: Type simple generators as Iterator, not Iterable. 2020-06-23 11:29:54 -07:00
migrations models: Add missing migrations from invite_as change. 2020-06-24 11:39:01 -07:00
openapi docs: Change next planned major release to 3.0. 2020-06-24 16:27:27 -07:00
templatetags openapi: Parse {!api-admin-only.md!} in OpenAPI markdown extension. 2020-06-19 11:04:46 -07:00
tests tests: Use check_tuple for realm filters. 2020-06-24 15:01:57 -07:00
tornado docs: Update some comments for the new release versioning scheme. 2020-06-25 10:33:03 -07:00
views REQ: Use check_dict_only in update_user_backend. 2020-06-25 10:54:15 -07:00
webhooks papertrail: Replace custom validator with check_dict. 2020-06-20 22:29:15 -07:00
worker docs: Update some comments for the new release versioning scheme. 2020-06-25 10:33:03 -07:00
__init__.py
apps.py python: Sort imports with isort. 2020-06-11 16:45:32 -07:00
context_processors.py auth: Make apple log in and sign up buttons consistent with others. 2020-06-18 13:06:10 -07:00
decorator.py decorator: Fix type of signature-changing decorators. 2020-06-23 11:29:54 -07:00
filters.py python: Sort imports with isort. 2020-06-11 16:45:32 -07:00
forms.py python: Sort imports with isort. 2020-06-11 16:45:32 -07:00
logging_handlers.py python: Sort imports with isort. 2020-06-11 16:45:32 -07:00
middleware.py python: Manually convert more percent-formatting to f-strings. 2020-06-14 23:27:22 -07:00
models.py models: Avoid undocumented sre_constants module. 2020-06-24 23:18:17 -07:00
signals.py python: Sort imports with isort. 2020-06-11 16:45:32 -07:00