Fixed #25596 -- Fixed regression in password change view with custom user model.
The reverse() added in 50aa1a790c
crashed on a custom user model.
This commit is contained in:
parent
1f07da3e29
commit
5acf203db2
|
@ -148,8 +148,9 @@ class UserAdmin(admin.ModelAdmin):
|
||||||
update_session_auth_hash(request, form.user)
|
update_session_auth_hash(request, form.user)
|
||||||
return HttpResponseRedirect(
|
return HttpResponseRedirect(
|
||||||
reverse(
|
reverse(
|
||||||
'%s:auth_%s_change' % (
|
'%s:%s_%s_change' % (
|
||||||
self.admin_site.name,
|
self.admin_site.name,
|
||||||
|
user._meta.app_label,
|
||||||
user._meta.model_name,
|
user._meta.model_name,
|
||||||
),
|
),
|
||||||
args=(user.pk,),
|
args=(user.pk,),
|
||||||
|
@ -178,7 +179,7 @@ class UserAdmin(admin.ModelAdmin):
|
||||||
'save_as': False,
|
'save_as': False,
|
||||||
'show_save': True,
|
'show_save': True,
|
||||||
}
|
}
|
||||||
context.update(admin.site.each_context(request))
|
context.update(self.admin_site.each_context(request))
|
||||||
|
|
||||||
request.current_app = self.admin_site.name
|
request.current_app = self.admin_site.name
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,3 @@ with RemoveGroupsAndPermissions():
|
||||||
class UUIDUser(AbstractUser):
|
class UUIDUser(AbstractUser):
|
||||||
"""A user with a UUID as primary key"""
|
"""A user with a UUID as primary key"""
|
||||||
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
|
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
|
||||||
|
|
||||||
class Meta:
|
|
||||||
app_label = 'auth'
|
|
||||||
|
|
|
@ -292,7 +292,7 @@ class CustomUserModelBackendAuthenticateTest(TestCase):
|
||||||
self.assertEqual(test_user, authenticated_user)
|
self.assertEqual(test_user, authenticated_user)
|
||||||
|
|
||||||
|
|
||||||
@override_settings(AUTH_USER_MODEL='auth.UUIDUser')
|
@override_settings(AUTH_USER_MODEL='auth_tests.UUIDUser')
|
||||||
class UUIDUserTests(TestCase):
|
class UUIDUserTests(TestCase):
|
||||||
|
|
||||||
def test_login(self):
|
def test_login(self):
|
||||||
|
|
|
@ -404,7 +404,7 @@ class CustomUserPasswordResetTest(AuthViewsTestCase):
|
||||||
self.assertRedirects(response, '/reset/done/')
|
self.assertRedirects(response, '/reset/done/')
|
||||||
|
|
||||||
|
|
||||||
@override_settings(AUTH_USER_MODEL='auth.UUIDUser')
|
@override_settings(AUTH_USER_MODEL='auth_tests.UUIDUser')
|
||||||
class UUIDUserPasswordResetTest(CustomUserPasswordResetTest):
|
class UUIDUserPasswordResetTest(CustomUserPasswordResetTest):
|
||||||
|
|
||||||
def _test_confirm_start(self):
|
def _test_confirm_start(self):
|
||||||
|
@ -991,7 +991,7 @@ class ChangelistTests(AuthViewsTestCase):
|
||||||
|
|
||||||
|
|
||||||
@override_settings(
|
@override_settings(
|
||||||
AUTH_USER_MODEL='auth.UUIDUser',
|
AUTH_USER_MODEL='auth_tests.UUIDUser',
|
||||||
ROOT_URLCONF='auth_tests.urls_custom_user_admin',
|
ROOT_URLCONF='auth_tests.urls_custom_user_admin',
|
||||||
)
|
)
|
||||||
class UUIDUserTests(TestCase):
|
class UUIDUserTests(TestCase):
|
||||||
|
@ -1000,7 +1000,7 @@ class UUIDUserTests(TestCase):
|
||||||
u = UUIDUser.objects.create_superuser(username='uuid', email='foo@bar.com', password='test')
|
u = UUIDUser.objects.create_superuser(username='uuid', email='foo@bar.com', password='test')
|
||||||
self.assertTrue(self.client.login(username='uuid', password='test'))
|
self.assertTrue(self.client.login(username='uuid', password='test'))
|
||||||
|
|
||||||
user_change_url = reverse('custom_user_admin:auth_uuiduser_change', args=(u.pk,))
|
user_change_url = reverse('custom_user_admin:auth_tests_uuiduser_change', args=(u.pk,))
|
||||||
response = self.client.get(user_change_url)
|
response = self.client.get(user_change_url)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue