mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Refactored out RedirectURLMixin.get_success_url().
This also adds a default implementation of get_default_redirect_url().
This commit is contained in:
committed by
Mariusz Felisiak
parent
04bc2564b6
commit
5dfa6fca96
@@ -18,6 +18,7 @@ from django.contrib.auth.models import Permission, User
|
||||
from django.contrib.auth.views import (
|
||||
INTERNAL_RESET_SESSION_TOKEN,
|
||||
LoginView,
|
||||
RedirectURLMixin,
|
||||
logout_then_login,
|
||||
redirect_to_login,
|
||||
)
|
||||
@@ -40,6 +41,20 @@ from .models import CustomUser, UUIDUser
|
||||
from .settings import AUTH_TEMPLATES
|
||||
|
||||
|
||||
class RedirectURLMixinTests(TestCase):
|
||||
@override_settings(ROOT_URLCONF="auth_tests.urls")
|
||||
def test_get_default_redirect_url_next_page(self):
|
||||
class RedirectURLView(RedirectURLMixin):
|
||||
next_page = "/custom/"
|
||||
|
||||
self.assertEqual(RedirectURLView().get_default_redirect_url(), "/custom/")
|
||||
|
||||
def test_get_default_redirect_url_no_next_page(self):
|
||||
msg = "No URL to redirect to. Provide a next_page."
|
||||
with self.assertRaisesMessage(ImproperlyConfigured, msg):
|
||||
RedirectURLMixin().get_default_redirect_url()
|
||||
|
||||
|
||||
@override_settings(
|
||||
LANGUAGES=[("en", "English")],
|
||||
LANGUAGE_CODE="en",
|
||||
|
||||
Reference in New Issue
Block a user