Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
decorator: Updated user_passes_test function from Django 2.2.
arpit5510d6047840b28
diff --git a/zerver/decorator.py b/zerver/decorator.pyindex 4ef7b51a1fb..3a51fad7cbb 100644--- a/zerver/decorator.py+++ b/zerver/decorator.py@@ -23,7 +23,6 @@ from django.http import (from django.http.multipartparser import MultiPartParserfrom django.shortcuts import resolve_urlfrom django.template.response import SimpleTemplateResponse-from django.utils.decorators import available_attrsfrom django.utils.timezone import now as timezone_nowfrom django.utils.translation import ugettext as _from django.views.decorators.csrf import csrf_exempt@@ -388,7 +387,11 @@ def redirect_to_login(next: str, login_url: Optional[str]=None,return HttpResponseRedirect(urllib.parse.urlunparse(login_url_parts))-# From Django 1.8+# From Django 2.2, modified to pass the request rather than just the+# user into test_func; this is useful so that we can revalidate the+# subdomain matches the user's realm. It is likely that we could make+# the subdomain validation happen elsewhere and switch to using the+# stock Django version.def user_passes_test(test_func: Callable[[HttpResponse], bool], login_url: Optional[str]=None,redirect_field_name: str=REDIRECT_FIELD_NAME) -> Callable[[ViewFuncT], ViewFuncT]:"""@@ -397,7 +400,7 @@ def user_passes_test(test_func: Callable[[HttpResponse], bool], login_url: Optiothat takes the user object and returns True if the user passes."""def decorator(view_func: ViewFuncT) -> ViewFuncT:- @wraps(view_func, assigned=available_attrs(view_func))+ @wraps(view_func)def _wrapped_view(request: HttpRequest, *args: object, **kwargs: object) -> HttpResponse:if test_func(request):return view_func(request, *args, **kwargs)