mirror of https://github.com/zulip/zulip.git
rest: Remove kwargs from rest_path.
The only caller that passes the kwargs argument is the avatar rest_path. The application of kwargs can be rewritten with a wrapper. Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
parent
b05e70899d
commit
eb88fee745
|
@ -1,5 +1,5 @@
|
|||
from functools import wraps
|
||||
from typing import Any, Callable, Dict, Mapping, Set, Tuple, Union, cast
|
||||
from typing import Any, Callable, Dict, Set, Tuple, Union, cast
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.urls import path
|
||||
|
@ -199,7 +199,6 @@ def rest_dispatch(request: HttpRequest, **kwargs: Any) -> HttpResponse:
|
|||
|
||||
def rest_path(
|
||||
route: str,
|
||||
kwargs: Mapping[str, object] = {},
|
||||
**handlers: Union[Callable[..., HttpResponse], Tuple[Callable[..., HttpResponse], Set[str]]],
|
||||
) -> URLPattern:
|
||||
return path(route, rest_dispatch, {**kwargs, **handlers})
|
||||
return path(route, rest_dispatch, handlers)
|
||||
|
|
|
@ -324,6 +324,12 @@ def avatar(
|
|||
return redirect(url)
|
||||
|
||||
|
||||
def avatar_medium(
|
||||
request: HttpRequest, maybe_user_profile: Union[UserProfile, AnonymousUser], email_or_id: str
|
||||
) -> HttpResponse:
|
||||
return avatar(request, maybe_user_profile, email_or_id, medium=True)
|
||||
|
||||
|
||||
def get_stream_name(stream: Optional[Stream]) -> Optional[str]:
|
||||
if stream:
|
||||
return stream.name
|
||||
|
|
|
@ -195,6 +195,7 @@ from zerver.views.user_settings import (
|
|||
from zerver.views.users import (
|
||||
add_bot_backend,
|
||||
avatar,
|
||||
avatar_medium,
|
||||
create_user_backend,
|
||||
deactivate_bot_backend,
|
||||
deactivate_user_backend,
|
||||
|
@ -725,8 +726,10 @@ urls += [
|
|||
),
|
||||
rest_path(
|
||||
"avatar/<email_or_id>/medium",
|
||||
{"medium": True},
|
||||
GET=(avatar, {"override_api_url_scheme", "allow_anonymous_user_web"}),
|
||||
GET=(
|
||||
avatar_medium,
|
||||
{"override_api_url_scheme", "allow_anonymous_user_web"},
|
||||
),
|
||||
),
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in New Issue