summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmmanuel Cazenave <ecazenave@entrouvert.com>2022-06-09 15:48:40 (GMT)
committerEmmanuel Cazenave <ecazenave@entrouvert.com>2022-06-13 19:21:43 (GMT)
commit8481eade60cd91b3f4d09e6bbc13c8d394fb10bd (patch)
treef441ca1aba358af518bbb2353844d21e98e4859d
parent67217e48b7a56f697606b502b48d20d5ab37e195 (diff)
downloaddocbow-8481eade60cd91b3f4d09e6bbc13c8d394fb10bd.zip
docbow-8481eade60cd91b3f4d09e6bbc13c8d394fb10bd.tar.gz
docbow-8481eade60cd91b3f4d09e6bbc13c8d394fb10bd.tar.bz2
django 3.2: use standard functools.wrap capabilities (#64430)
-rw-r--r--docbow_project/docbow/decorators.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/docbow_project/docbow/decorators.py b/docbow_project/docbow/decorators.py
index 05b3f80..1244e9b 100644
--- a/docbow_project/docbow/decorators.py
+++ b/docbow_project/docbow/decorators.py
@@ -1,11 +1,8 @@
-try:
- from functools import wraps
-except ImportError:
- from django.utils.functional import wraps # Python 2.4 fallback.
+from functools import wraps
+
from django.shortcuts import redirect
from django.contrib import messages
from django.utils.translation import ugettext as _
-from django.utils.decorators import available_attrs
from django.utils.cache import patch_cache_control
from django.views.decorators.cache import never_cache as old_never_cache
@@ -15,7 +12,7 @@ def no_delegate(view_func):
Forbid delegated account to use this view.
"""
- @wraps(view_func, assigned=available_attrs(view_func))
+ @wraps(view_func)
def f(request, *args, **kwargs):
if hasattr(request.user, 'delegate'):
messages.warning(request, _('Your delegation does not allow you to do this action'))
@@ -31,7 +28,7 @@ def as_delegate(view_func):
given view.
"""
- @wraps(view_func, assigned=available_attrs(view_func))
+ @wraps(view_func)
def f(request, *args, **kwargs):
if hasattr(request.user, 'delegate'):
old_user = request.user
@@ -49,7 +46,7 @@ def never_cache(view_func):
'''Block client caching in all browsers.'''
view_func = old_never_cache(view_func)
- @wraps(view_func, assigned=available_attrs(view_func))
+ @wraps(view_func)
def f(request, *args, **kwargs):
result = view_func(request, *args, **kwargs)
patch_cache_control(result, no_cache=True)