From 39f294378e794c2a359717c53effccd6f008e7e6 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 21 Mar 2024 11:23:47 -0700 Subject: [PATCH 01/10] Add django-constnace to requirements files I can't run pip-compile since the macports MariaDB ports are broken due to a change in libxml2, so I manually edited the requirements.txt file. Not ideal. --- requirements/requirements.in | 3 +++ requirements/requirements.txt | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/requirements/requirements.in b/requirements/requirements.in index dfc31fc7..d6d790fd 100644 --- a/requirements/requirements.in +++ b/requirements/requirements.in @@ -66,3 +66,6 @@ django-htmx certifi>=2023.7.22 urllib3>=1.26.18 sqlparse>=0.4.4 + +# Dynamic settings +django-constance diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 6b04b099..ea1d67ab 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -65,6 +65,8 @@ django-anvil-consortium-manager @ git+https://github.com/UW-GAC/django-anvil-con # via -r requirements/requirements.in django-autocomplete-light==3.11.0 # via django-anvil-consortium-manager +django-constance==2.9.1 + # via -r requirements/requirements.in django-crispy-forms==2.1 # via # -r requirements/requirements.in @@ -88,6 +90,9 @@ django-maintenance-mode==0.21.1 # via -r requirements/requirements.in django-model-utils==4.4.0 # via -r requirements/requirements.in +django-picklefield==3.1.0 + # via -r requirements/requirements.in + # django-constnace django-simple-history==3.5.0 # via # -r requirements/requirements.in From 33f89b5c48672ae633b8fcb85960e68083ef5dda Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 21 Mar 2024 11:52:31 -0700 Subject: [PATCH 02/10] Install django-constance into the project Add django-constance to the third party apps section, and set the specific required settings for this app. We'll use the database backend for now, since we aren't using redis. --- config/settings/base.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config/settings/base.py b/config/settings/base.py index 9710eaeb..da185606 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -85,6 +85,7 @@ "simple_history", "dbbackup", "django_htmx", + "constance", ] LOCAL_APPS = [ @@ -368,6 +369,13 @@ # 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 = {} +CONSTANCE_BACKEND = "constance.backends.database.DatabaseBackend" +CONSTANCE_IGNORE_ADMIN_VERSION_CHECK = True +CONSTANCE_DATABASE_CACHE_BACKEND = "default" + # django-anvil-consortium-manager # ------------------------------------------------------------------------------ ANVIL_API_SERVICE_ACCOUNT_FILE = env("ANVIL_API_SERVICE_ACCOUNT_FILE") From a73e35b14919f1ce2d8f8df74378df5d92cbf30c Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 21 Mar 2024 12:01:11 -0700 Subject: [PATCH 03/10] Disable constance caching This isn't working locally - maybe we can enable it in prod later. --- config/settings/base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/settings/base.py b/config/settings/base.py index da185606..50296358 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -374,7 +374,8 @@ CONSTANCE_CONFIG = {} CONSTANCE_BACKEND = "constance.backends.database.DatabaseBackend" CONSTANCE_IGNORE_ADMIN_VERSION_CHECK = True -CONSTANCE_DATABASE_CACHE_BACKEND = "default" +# CONSTANCE_DATABASE_CACHE_BACKEND = "default" +CONSTANCE_DATABASE_CACHE_AUTOFILL_TIMEOUT = None # django-anvil-consortium-manager # ------------------------------------------------------------------------------ From 9903886b479e3f63efb024bafddcedb8f3f9b304 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 21 Mar 2024 12:02:40 -0700 Subject: [PATCH 04/10] Add a SITE_ANNOUNCEMENT constant to constance --- config/settings/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/settings/base.py b/config/settings/base.py index 50296358..24f58d19 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -371,7 +371,9 @@ # django-constance # ------------------------------------------------------------------------------ -CONSTANCE_CONFIG = {} +CONSTANCE_CONFIG = { + "SITE_ANNOUNCEMENT": ("", "Site-wide announcement message", str), +} CONSTANCE_BACKEND = "constance.backends.database.DatabaseBackend" CONSTANCE_IGNORE_ADMIN_VERSION_CHECK = True # CONSTANCE_DATABASE_CACHE_BACKEND = "default" From cf1aff5478c551de8793791eeee82acdddedeb72 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 21 Mar 2024 15:08:40 -0700 Subject: [PATCH 05/10] Change account link alert bg to warning --- primed/templates/base.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/primed/templates/base.html b/primed/templates/base.html index 59db3d77..275bab1d 100644 --- a/primed/templates/base.html +++ b/primed/templates/base.html @@ -120,13 +120,12 @@ {% endif %} {% if not request.user.account %} -