Ticket #16958: patch_1_admin_password_change_limited.diff
File patch_1_admin_password_change_limited.diff, 2.5 KB (added by , 13 years ago) |
---|
-
django/contrib/auth/admin.py
108 108 def user_change_password(self, request, id): 109 109 if not self.has_change_permission(request): 110 110 raise PermissionDenied 111 user = get_object_or_404(self. model, pk=id)111 user = get_object_or_404(self.queryset(request), pk=id) 112 112 if request.method == 'POST': 113 113 form = self.change_password_form(user, request.POST) 114 114 if form.is_valid(): -
tests/regressiontests/admin_views/tests.py
2951 2951 response = self.client.get('/test_admin/admin/auth/user/%s/' % u.pk) 2952 2952 self.assertEqual(response.status_code, 200) 2953 2953 2954 def test_user_password_change_limited_queryset(self): 2955 su = User.objects.filter(is_superuser=True)[0] 2956 response = self.client.get('/test_admin/admin2/auth/user/%s/password/' % su.pk) 2957 self.assertEquals(response.status_code, 404) 2958 2954 2959 2955 2960 class GroupAdminTest(TestCase): 2956 2961 """ -
tests/regressiontests/admin_views/customadmin.py
5 5 from django.contrib import admin 6 6 from django.http import HttpResponse 7 import django.contrib.auth.models 8 import django.contrib.auth.admin 7 9 8 10 import models, forms, admin as base_admin 9 11 … … 27 28 def my_view(self, request): 28 29 return HttpResponse("Django is a magical pony!") 29 30 31 class UserLimitedAdmin(django.contrib.auth.admin.UserAdmin): 32 # used for testing password change on a user not in queryset 33 def queryset(self, request): 34 qs = super(UserLimitedAdmin, self).queryset(request) 35 return qs.filter(is_superuser=False) 36 30 37 site = Admin2(name="admin2") 31 38 32 39 site.register(models.Article, base_admin.ArticleAdmin) … … 34 41 site.register(models.Thing, base_admin.ThingAdmin) 35 42 site.register(models.Fabric, base_admin.FabricAdmin) 36 43 site.register(models.ChapterXtra1, base_admin.ChapterXtra1Admin) 44 site.register(django.contrib.auth.models.User, UserLimitedAdmin)