Ticket #8159: 8159.diff
File 8159.diff, 3.2 KB (added by , 16 years ago) |
---|
-
django/contrib/admin/templates/admin/auth/user/delete_confirmation.html
1 {% extends "admin/delete_confirmation.html" %} 2 {% load i18n %} 3 4 {% block content %} 5 {% ifequal user object %} 6 <ul class="errorlist"> 7 <li>{% trans "You are attempting to delete yourself" %}</li> 8 </ul> 9 {% endifequal %} 10 {{block.super}} 11 {% endblock %} -
django/contrib/auth/admin.py
108 108 'root_path': self.admin_site.root_path, 109 109 }, context_instance=RequestContext(request)) 110 110 111 def log_deletion(self, request, object, object_repr): 112 'Do not record if the current user id is None, i.e. it has been deleted - ticket #8159' 113 114 if request.user.id: 115 super(UserAdmin, self).log_deletion(request, object, object_repr) 116 117 def message_user(self, request, message): 118 'Do not message if the current user id is None, i.e. it has been deleted - ticket #8159' 119 120 if request.user.id: 121 super(UserAdmin, self).message_user(request, message) 111 122 123 112 124 admin.site.register(Group, GroupAdmin) 113 125 admin.site.register(User, UserAdmin) 114 126 -
django/contrib/auth/__init__.py
1 1 import datetime 2 2 from django.core.exceptions import ImproperlyConfigured 3 from django.db.models.signals import post_delete 3 4 4 5 SESSION_KEY = '_auth_user_id' 5 6 BACKEND_SESSION_KEY = '_auth_user_backend' … … 78 79 request.user = AnonymousUser() 79 80 80 81 def get_user(request): 81 from django.contrib.auth.models import AnonymousUser82 from django.contrib.auth.models import User, AnonymousUser 82 83 try: 83 84 user_id = request.session[SESSION_KEY] 84 85 backend_path = request.session[BACKEND_SESSION_KEY] … … 86 87 user = backend.get_user(user_id) or AnonymousUser() 87 88 except KeyError: 88 89 user = AnonymousUser() 90 91 if not user.is_anonymous(): 92 post_delete.connect(user.check_if_deleted, sender=User) 93 89 94 return user -
django/contrib/auth/models.py
287 287 raise SiteProfileNotAvailable 288 288 return self._profile_cache 289 289 290 def check_if_deleted(self, sender, **kwargs): 291 'Check if this User has just been deleted, and set our id to None if so' 292 instance = kwargs['instance'] 293 id_name = User._meta.pk.attname 294 if getattr(self, id_name) == getattr(instance, id_name): 295 setattr(self, id_name, None) 296 297 290 298 class Message(models.Model): 291 299 """ 292 300 The message system is a lightweight way to queue messages for given