Skip to content

Commit 90b4794

Browse files
committed
Fix django 1.7 incompatibilities: The role_required() decorator isn’t signature-preserving — which now breaks reverse().
- Legacy-Id: 8832
1 parent ee2892e commit 90b4794

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

ietf/ietfauth/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# various authentication and authorization utilities
22

3+
from functools import wraps
4+
35
from django.utils.http import urlquote
46
from django.conf import settings
57
from django.db.models import Q
68
from django.http import HttpResponseRedirect, HttpResponseForbidden
79
from django.contrib.auth import REDIRECT_FIELD_NAME
10+
from django.utils.decorators import available_attrs
811

912
from ietf.group.models import Role
1013
from ietf.person.models import Person
@@ -78,6 +81,7 @@ def passes_test_decorator(test_func, message):
7881
error. The test function should be on the form fn(user) ->
7982
true/false."""
8083
def decorate(view_func):
84+
@wraps(view_func, assigned=available_attrs(view_func))
8185
def inner(request, *args, **kwargs):
8286
if not request.user.is_authenticated():
8387
return HttpResponseRedirect('%s?%s=%s' % (settings.LOGIN_URL, REDIRECT_FIELD_NAME, urlquote(request.get_full_path())))
@@ -88,6 +92,7 @@ def inner(request, *args, **kwargs):
8892
return inner
8993
return decorate
9094

95+
9196
def role_required(*role_names):
9297
"""View decorator for checking that the user is logged in and
9398
has one of the listed roles."""

0 commit comments

Comments
 (0)