Ticket #6363: 6363-1.diff
File 6363-1.diff, 2.7 KB (added by , 16 years ago) |
---|
-
django/contrib/admin/sites.py
1 1 from django import http, template 2 2 from django.contrib.admin import ModelAdmin 3 from django.contrib.auth import authenticate, login 3 from django.contrib.auth import authenticate, login, logout 4 4 from django.db.models.base import ModelBase 5 5 from django.shortcuts import render_to_response 6 6 from django.utils.safestring import mark_safe … … 243 243 else: 244 244 if user.is_active and user.is_staff: 245 245 login(request, user) 246 # TODO: set last_login with an event. 247 user.last_login = datetime.datetime.now() 248 user.save() 249 if request.POST.has_key('post_data'): 250 post_data = _decode_post_data(request.POST['post_data']) 251 if post_data and not post_data.has_key(LOGIN_FORM_KEY): 252 # overwrite request.POST with the saved post_data, and continue 253 request.POST = post_data 254 request.user = user 246 247 if self.has_permission(request): 248 # TODO: set last_login with an event. 249 user.last_login = datetime.datetime.now() 250 user.save() 251 if request.POST.has_key('post_data'): 252 post_data = _decode_post_data(request.POST['post_data']) 253 if post_data and not post_data.has_key(LOGIN_FORM_KEY): 254 # overwrite request.POST with the saved post_data, and continue 255 request.POST = post_data 256 request.user = user 257 return None 258 else: 259 request.session.delete_test_cookie() 260 return http.HttpResponseRedirect(request.path) 261 else: 255 262 return None 256 else: 257 request.session.delete_test_cookie() 258 return http.HttpResponseRedirect(request.path) 259 else: 260 return self.display_login_form(request, ERROR_MESSAGE) 263 264 # logged in a user without permission to access this admin site, un-do that 265 # and fall through to re-display the login form with an error message. 266 logout(request) 267 268 return self.display_login_form(request, ERROR_MESSAGE) 261 269 login = never_cache(login) 262 270 263 271 def index(self, request, extra_context=None):