diff --git a/static/src/scss/_hero.scss b/static/src/scss/_hero.scss index 89f34f6..193c1d0 100644 --- a/static/src/scss/_hero.scss +++ b/static/src/scss/_hero.scss @@ -104,3 +104,8 @@ section.hero { margin-bottom: 0 !important; } } + +#view-restriction-banner { + text-align: center; + border-radius: 0; +} diff --git a/static/src/scss/_password_required.scss b/static/src/scss/_password_required.scss new file mode 100644 index 0000000..4aca004 --- /dev/null +++ b/static/src/scss/_password_required.scss @@ -0,0 +1,43 @@ +body.page-password-required { + height: 100vh; + + main { + height: 100%; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + margin-bottom: 0; + text-align: center; + } + + form { + width: 80%; + max-width: 500px; + } + + .input { + text-align: center; + + @include dark-mode { + background-color: color.adjust($dark, $alpha: -0.2); + color: $dark-mode-text; + + &::placeholder { + color: rgba(214 210 205 / 80%); + } + } + } + + .errorlist { + color: $danger; + margin-bottom: 1rem; + } + + h1, + p { + @include dark-mode { + color: $dark-mode-text; + } + } +} diff --git a/static/src/scss/base.scss b/static/src/scss/base.scss index f8ff93d..c8d24d6 100644 --- a/static/src/scss/base.scss +++ b/static/src/scss/base.scss @@ -19,6 +19,7 @@ @import "spotify"; @import "404"; @import "contact"; +@import "password_required"; html, body { diff --git a/website/common/templates/password_required.html b/website/common/templates/password_required.html new file mode 100644 index 0000000..99feecc --- /dev/null +++ b/website/common/templates/password_required.html @@ -0,0 +1,41 @@ +{% extends "base.html" %} + +{% load static wagtailcore_tags wagtailimages_tags %} + +{% block body_class %}page-password-required{% endblock %} + +{% block title %}Password required{% endblock %} + +{% block extra_head %} + +{% endblock %} + +{% block main_content %} +

+

Password required

+

You need a password to access this page.

+ +
+ {% csrf_token %} + + {{ form.non_field_errors }} + {{ form.password.errors }} + +
+ +
+ + {% for field in form.hidden_fields %} + {{ field }} + {% endfor %} + + +
+{% endblock %} diff --git a/website/common/templates/wagtail_base.html b/website/common/templates/wagtail_base.html index 15307a4..c09dc65 100644 --- a/website/common/templates/wagtail_base.html +++ b/website/common/templates/wagtail_base.html @@ -15,6 +15,12 @@ {% endif %} + {% if page.get_view_restrictions.exists %} +
+ Note: This page has a view restriction. Please do not share its content until the page is public or this message is removed. +
+ {% endif %} +
diff --git a/website/common/tests/test_pages.py b/website/common/tests/test_pages.py index 433397c..a5246e5 100644 --- a/website/common/tests/test_pages.py +++ b/website/common/tests/test_pages.py @@ -35,7 +35,7 @@ class ContentPageTestCase(TestCase): self.assertEqual(response.status_code, 200) def test_queries(self) -> None: - with self.assertNumQueries(26): + with self.assertNumQueries(28): self.client.get(self.page.url) @@ -52,7 +52,7 @@ class ListingPageTestCase(TestCase): ContentPageFactory(parent=cls.page) def test_accessible(self) -> None: - with self.assertNumQueries(31): + with self.assertNumQueries(33): response = self.client.get(self.page.url) self.assertEqual(response.status_code, 200) self.assertEqual(len(response.context["listing_pages"]), 2) diff --git a/website/settings.py b/website/settings.py index 3e47b4f..5216042 100644 --- a/website/settings.py +++ b/website/settings.py @@ -187,6 +187,7 @@ BASE_HOSTNAME = env("BASE_HOSTNAME") WAGTAILADMIN_BASE_URL = f"https://{BASE_HOSTNAME}" WAGTAIL_FRONTEND_LOGIN_URL = "/admin/login/" +PASSWORD_REQUIRED_TEMPLATE = "password_required.html" DEFAULT_AUTO_FIELD = "django.db.models.AutoField"