Require login for index view
This commit is contained in:
parent
a5b65974fb
commit
dd67ee91da
3 changed files with 23 additions and 3 deletions
|
@ -14,7 +14,17 @@ TEST_PASSWORD = "secret"
|
|||
|
||||
|
||||
class IndexViewTest(TestCase):
|
||||
def test_index_view_anonymous(self):
|
||||
response = self.client.get(reverse("dashboard"))
|
||||
self.assertRedirects(response, "/accounts/login/?next=/")
|
||||
|
||||
def test_index_view(self):
|
||||
user = User.objects.create(username=TEST_USER)
|
||||
user.set_password(TEST_PASSWORD)
|
||||
user.save()
|
||||
|
||||
self.client.login(username=TEST_USER, password=TEST_PASSWORD)
|
||||
|
||||
response = self.client.get(reverse("dashboard"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed(response, "dashboard/index.html")
|
||||
|
|
|
@ -3,13 +3,14 @@ This module defines the views for the gnuviechadmin customer dashboard.
|
|||
|
||||
"""
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.views.generic import DetailView, TemplateView
|
||||
from gvacommon.viewmixins import StaffOrSelfLoginRequiredMixin
|
||||
|
||||
from hostingpackages.models import CustomerHostingPackage
|
||||
|
||||
|
||||
class IndexView(TemplateView):
|
||||
class IndexView(LoginRequiredMixin, TemplateView):
|
||||
"""
|
||||
This is the dashboard view.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue