diff --git a/config/settings/base.py b/config/settings/base.py index 9710eaeb..61828a23 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -85,6 +85,8 @@ "simple_history", "dbbackup", "django_htmx", + "constance", + "constance.backends.database", ] LOCAL_APPS = [ @@ -205,6 +207,7 @@ "django.template.context_processors.static", "django.template.context_processors.tz", "django.contrib.messages.context_processors.messages", + "constance.context_processors.config", "primed.utils.context_processors.settings_context", ], }, @@ -368,6 +371,17 @@ # https://django-tables2.readthedocs.io/en/latest/pages/custom-rendering.html?highlight=django_tables2_template#available-templates DJANGO_TABLES2_TEMPLATE = "django_tables2/bootstrap5.html" +# django-constance +# ------------------------------------------------------------------------------ +CONSTANCE_CONFIG = { + "ANNOUNCEMENT_TEXT": ("", "Site-wide announcement message", str), +} + +CONSTANCE_BACKEND = "constance.backends.database.DatabaseBackend" +CONSTANCE_IGNORE_ADMIN_VERSION_CHECK = True +# CONSTANCE_DATABASE_CACHE_BACKEND = "default" +CONSTANCE_DATABASE_CACHE_AUTOFILL_TIMEOUT = None + # django-anvil-consortium-manager # ------------------------------------------------------------------------------ ANVIL_API_SERVICE_ACCOUNT_FILE = env("ANVIL_API_SERVICE_ACCOUNT_FILE") diff --git a/primed/primed_anvil/tests/test_views.py b/primed/primed_anvil/tests/test_views.py index b84d4c5f..9e1b079f 100644 --- a/primed/primed_anvil/tests/test_views.py +++ b/primed/primed_anvil/tests/test_views.py @@ -3,6 +3,7 @@ from anvil_consortium_manager import models as acm_models from anvil_consortium_manager.tests.factories import AccountFactory from anvil_consortium_manager.views import AccountList +from constance.test import override_config from django.conf import settings from django.contrib.auth import get_user_model from django.contrib.auth.models import Permission @@ -133,6 +134,12 @@ def test_user_has_not_linked_account(self): response, reverse("anvil_consortium_manager:accounts:link") ) + def test_unauthenticated_user_has_not_linked_account_message(self): + response = self.client.get(settings.LOGIN_URL, follow=True) + self.assertNotContains( + response, reverse("anvil_consortium_manager:accounts:link") + ) + def test_staff_view_links(self): user = UserFactory.create() user.user_permissions.add( @@ -163,6 +170,24 @@ def test_view_links(self): response, '"{}"'.format(reverse("anvil_consortium_manager:index")) ) + def test_site_announcement_no_text(self): + self.client.force_login(self.user) + response = self.client.get(self.get_url()) + self.assertNotContains(response, """id="alert-announcement""") + + @override_config(ANNOUNCEMENT_TEXT="This is a test announcement") + def test_site_announcement_text(self): + self.client.force_login(self.user) + response = self.client.get(self.get_url()) + self.assertContains(response, """id="alert-announcement""") + self.assertContains(response, "This is a test announcement") + + @override_config(ANNOUNCEMENT_TEXT="This is a test announcement") + def test_site_announcement_text_unauthenticated_user(self): + response = self.client.get(self.get_url(), follow=True) + self.assertContains(response, """id="alert-announcement""") + self.assertContains(response, "This is a test announcement") + class StudyDetailTest(TestCase): """Tests for the StudyDetail view.""" diff --git a/primed/static/css/project.css b/primed/static/css/project.css index 6243cad2..78fa7855 100644 --- a/primed/static/css/project.css +++ b/primed/static/css/project.css @@ -134,7 +134,6 @@ h3, .h3 { } h4, .h4 { - font-size: calc(1.275rem + 0.3vw); } @media (min-width: 1200px) { @@ -12012,9 +12011,6 @@ a.navbar-brand:hover { background-color: unset; } -.navbar { - min-height: 132px; -} .navbar-brand { height: 100px; diff --git a/primed/templates/base.html b/primed/templates/base.html index 59db3d77..1789536c 100644 --- a/primed/templates/base.html +++ b/primed/templates/base.html @@ -108,23 +108,32 @@ - {% block extra_navbar %} - {% endblock %}
-
+
- {% if messages %} - {% for message in messages %} - - {% endfor %} + {% if config.ANNOUNCEMENT_TEXT %} + {% endif %} - {% if not request.user.account %} -