mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
backend: Change return value of compose_views.
As a preparatory step to refactoring json_success to accept request as a parameter, update helper function `compose_views` in `views.streams.py` to return the response data and call json_success from view functions that utilize `compose_views`. Also, updates related test in `zerver.tests.test_subs.py`.
This commit is contained in:
committed by
Tim Abbott
parent
a4b347bb5f
commit
dbddbee5a1
@@ -374,10 +374,12 @@ def update_subscriptions_backend(
|
||||
lambda: add_subscriptions_backend(request, user_profile, streams_raw=add),
|
||||
lambda: remove_subscriptions_backend(request, user_profile, streams_raw=delete),
|
||||
]
|
||||
return compose_views(thunks)
|
||||
data = compose_views(thunks)
|
||||
|
||||
return json_success(data)
|
||||
|
||||
|
||||
def compose_views(thunks: List[Callable[[], HttpResponse]]) -> HttpResponse:
|
||||
def compose_views(thunks: List[Callable[[], HttpResponse]]) -> Dict[str, Any]:
|
||||
"""
|
||||
This takes a series of thunks and calls them in sequence, and it
|
||||
smushes all the json results into a single response when
|
||||
@@ -391,7 +393,7 @@ def compose_views(thunks: List[Callable[[], HttpResponse]]) -> HttpResponse:
|
||||
for thunk in thunks:
|
||||
response = thunk()
|
||||
json_dict.update(orjson.loads(response.content))
|
||||
return json_success(json_dict)
|
||||
return json_dict
|
||||
|
||||
|
||||
check_principals: Validator[Union[List[str], List[int]]] = check_union(
|
||||
|
||||
@@ -103,7 +103,9 @@ def update_user_group_backend(
|
||||
request, user_profile, user_group_id=user_group_id, members=delete
|
||||
),
|
||||
]
|
||||
return compose_views(thunks)
|
||||
data = compose_views(thunks)
|
||||
|
||||
return json_success(data)
|
||||
|
||||
|
||||
def add_members_to_group_backend(
|
||||
|
||||
Reference in New Issue
Block a user