Ticket #7553: 7553-sites-decorators-ref.diff
File 7553-sites-decorators-ref.diff, 3.6 KB (added by , 16 years ago) |
---|
-
django/views/decorators/cache.py
42 42 """ 43 43 def _wrapped_view_func(request, *args, **kwargs): 44 44 response = view_func(request, *args, **kwargs) 45 # Although rare, it is possible for a view to return None (e.g. the 46 # django.contrib.admin.sites.AdminSite.login view in one corner-case) 47 if response: 48 add_never_cache_headers(response) 45 add_never_cache_headers(response) 49 46 return response 50 47 return wraps(view_func)(_wrapped_view_func) -
django/contrib/admin/sites.py
71 71 model_or_iterable = [model_or_iterable] 72 72 for model in model_or_iterable: 73 73 if model in self._registry: 74 raise AlreadyRegistered ('The model %s is already registered' % model.__name__)74 raise AlreadyRegistered, _('The model %s is already registered') % model.__name__ 75 75 self._registry[model] = admin_class(model, self) 76 76 77 77 def unregister(self, model_or_iterable): … … 84 84 model_or_iterable = [model_or_iterable] 85 85 for model in model_or_iterable: 86 86 if model not in self._registry: 87 raise NotRegistered ('The model %s is not registered' % model.__name__)87 raise NotRegistered, _('The model %s is not registered') % model.__name__ 88 88 del self._registry[model] 89 89 90 90 def has_permission(self, request): … … 111 111 # The 'logout' view doesn't require that the person is logged in. 112 112 if url == 'logout': 113 113 return self.logout(request) 114 114 115 # Check for permission or show login form 115 116 if not self.has_permission(request): 116 response = self.login(request) 117 if response: 118 # make sure that there is a response before returning 119 # this addresses any post data that might persist from 120 # expired sessions and continue through (#5999) 121 return response 117 return self.login(request) 122 118 123 119 if url == '': 124 120 return self.index(request) … … 244 240 245 241 # The user data is correct; log in the user in and continue. 246 242 else: 247 if user.is_a ctiveand user.is_staff:243 if user.is_authenticated() and user.is_staff: 248 244 login(request, user) 249 245 # TODO: set last_login with an event. 250 246 user.last_login = datetime.datetime.now() 251 247 user.save() 252 248 if request.POST.has_key('post_data'): 249 request.session.delete_test_cookie() 253 250 post_data = _decode_post_data(request.POST['post_data']) 254 251 if post_data and not post_data.has_key(LOGIN_FORM_KEY): 255 252 # overwrite request.POST with the saved post_data, and continue 256 253 request.POST = post_data 257 254 request.user = user 258 return None255 return self.root(request, request.path.split(self.root_path)[-1]) 259 256 else: 260 request.session.delete_test_cookie()261 257 return http.HttpResponseRedirect(request.path) 262 258 else: 263 259 return self.display_login_form(request, ERROR_MESSAGE)