new apps.lyric.views login FBV; new login path in .urls; new UT in .tests.test_views to assert the FBV's redirect to '/'
This commit is contained in:
@@ -33,3 +33,8 @@ class SendLoginEmailViewTest(TestCase):
|
||||
"Check your email!—there you'll find a magic login link. But hurry… it's only temporary!",
|
||||
)
|
||||
self.assertEqual(message.tags, "success")
|
||||
|
||||
class LoginViewTest(TestCase):
|
||||
def test_redirects_to_home_page(self):
|
||||
response = self.client.get("/apps/lyric/login?token=abc123")
|
||||
self.assertRedirects(response, "/")
|
||||
|
||||
@@ -3,5 +3,6 @@ from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('send_login_email', views.send_login_email, name='send_login_email'),
|
||||
path('login', views.login, name="login"),
|
||||
]
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from django.contrib import messages
|
||||
from django.core.mail import send_mail
|
||||
from django.shortcuts import redirect
|
||||
from ..dashboard.forms import ItemForm
|
||||
|
||||
def send_login_email(request):
|
||||
email = request.POST["email"]
|
||||
@@ -15,3 +16,6 @@ def send_login_email(request):
|
||||
"Check your email!—there you'll find a magic login link. But hurry… it's only temporary!",
|
||||
)
|
||||
return redirect("/")
|
||||
|
||||
def login(request):
|
||||
return redirect("/")
|
||||
|
||||
Reference in New Issue
Block a user