Ticket #13304: django12-authdecorators-callable.diff
File django12-authdecorators-callable.diff, 2.0 KB (added by , 15 years ago) |
---|
-
django/contrib/auth/decorators.py
5 5 6 6 from django.contrib.auth import REDIRECT_FIELD_NAME 7 7 from django.http import HttpResponseRedirect 8 from django.utils.decorators import available_attrs 8 9 from django.utils.http import urlquote 9 10 10 11 … … 25 26 path = urlquote(request.get_full_path()) 26 27 tup = login_url, redirect_field_name, path 27 28 return HttpResponseRedirect('%s?%s=%s' % tup) 28 return wraps(view_func )(_wrapped_view)29 return wraps(view_func, assigned=available_attrs(view_func))(_wrapped_view) 29 30 return decorator 30 31 31 32 -
tests/regressiontests/auth_decorators/tests.py
1 from unittest import TestCase 2 3 from django.contrib.auth.decorators import login_required 4 5 6 class LoginRequiredTestCase(TestCase): 7 """ 8 Tests the login_required decorators 9 """ 10 def testCallable(self): 11 """ 12 Check that login_required is assignable to callable objects. 13 """ 14 class CallableView(object): 15 def __call__(self, *args, **kwargs): 16 pass 17 login_required(CallableView()) 18 19 def testView(self): 20 """ 21 Check that login_required is assignable to normal views. 22 """ 23 def normal_view(request): 24 pass 25 login_required(normal_view) 26 No newline at end of file