From 3775d2df81053b230f7654f79f76656832a73065 Mon Sep 17 00:00:00 2001 From: Tudor Amariei Date: Mon, 28 Oct 2024 16:21:23 +0200 Subject: [PATCH] Remove history from the header during elections --- backend/hub/context_processors.py | 30 ++++++++++++++++++++------- backend/hub/templates/hub/about.html | 8 +++++++ backend/hub/templates/hub/header.html | 10 +++++---- backend/static_extras/css/colors.css | 2 ++ backend/static_extras/css/hub.css | 4 ++++ 5 files changed, 43 insertions(+), 11 deletions(-) diff --git a/backend/hub/context_processors.py b/backend/hub/context_processors.py index ec71235c..382c4b70 100644 --- a/backend/hub/context_processors.py +++ b/backend/hub/context_processors.py @@ -14,6 +14,14 @@ def hub_settings(_: WSGIRequest) -> Dict[str, Any]: if settings.ENABLE_ORG_REGISTRATION_FORM: register_url = reverse("ngos-register-request") + candidate_registration_enabled = flags.get(FLAG_CHOICES.enable_candidate_registration, False) + candidate_supporting_enabled = flags.get(FLAG_CHOICES.enable_candidate_supporting, False) + candidate_voting_enabled = flags.get(FLAG_CHOICES.enable_candidate_voting, False) + candidate_confirmation_enabled = flags.get(FLAG_CHOICES.enable_candidate_confirmation, False) + results_enabled = flags.get(FLAG_CHOICES.enable_results_display, False) + org_approval_enabled = flags.get(FLAG_CHOICES.enable_org_approval, False) + org_registration_enabled = flags.get(FLAG_CHOICES.enable_org_registration, False) + return { # Flags from settings.py: "ANALYTICS_ENABLED": settings.ANALYTICS_ENABLED, @@ -26,14 +34,22 @@ def hub_settings(_: WSGIRequest) -> Dict[str, Any]: "CONTACT_EMAIL": settings.CONTACT_EMAIL, "COMISSION_EMAIL": settings.COMISSION_EMAIL, # Flags from database: - "CANDIDATE_REGISTRATION_ENABLED": flags.get(FLAG_CHOICES.enable_candidate_registration, False), - "CANDIDATE_SUPPORTING_ENABLED": flags.get(FLAG_CHOICES.enable_candidate_supporting, False), - "CANDIDATE_VOTING_ENABLED": flags.get(FLAG_CHOICES.enable_candidate_voting, False), - "CANDIDATE_CONFIRMATION_ENABLED": flags.get(FLAG_CHOICES.enable_candidate_confirmation, False), - "RESULTS_ENABLED": flags.get(FLAG_CHOICES.enable_results_display, False), - "ORG_APPROVAL_ENABLED": flags.get(FLAG_CHOICES.enable_org_approval, False), - "ORG_REGISTRATION_ENABLED": flags.get(FLAG_CHOICES.enable_org_registration, False), + "CANDIDATE_REGISTRATION_ENABLED": candidate_registration_enabled, + "CANDIDATE_SUPPORTING_ENABLED": candidate_supporting_enabled, + "CANDIDATE_VOTING_ENABLED": candidate_voting_enabled, + "CANDIDATE_CONFIRMATION_ENABLED": candidate_confirmation_enabled, + "RESULTS_ENABLED": results_enabled, + "ORG_APPROVAL_ENABLED": org_approval_enabled, + "ORG_REGISTRATION_ENABLED": org_registration_enabled, # Settings flags "GLOBAL_SUPPORT_ENABLED": flags.get(FLAG_CHOICES.global_support_round, False), "VOTING_DOMAIN_ENABLED": flags.get(FLAG_CHOICES.enable_voting_domain, False), + # Composite flags + "ELECTION_IN_PROGRESS": ( + candidate_registration_enabled + or candidate_supporting_enabled + or candidate_voting_enabled + or candidate_confirmation_enabled + or org_registration_enabled + ), } diff --git a/backend/hub/templates/hub/about.html b/backend/hub/templates/hub/about.html index 7dabc950..9ea4dce2 100644 --- a/backend/hub/templates/hub/about.html +++ b/backend/hub/templates/hub/about.html @@ -20,6 +20,14 @@

+ + {% block left-side-view %}
diff --git a/backend/hub/templates/hub/header.html b/backend/hub/templates/hub/header.html index b9637634..944bd0c5 100644 --- a/backend/hub/templates/hub/header.html +++ b/backend/hub/templates/hub/header.html @@ -60,7 +60,7 @@ {% trans "Organizations" %} - {% if user.is_authenticated %} + {% if user.is_authenticated and ELECTION_IN_PROGRESS %} {% trans "Candidates" %} @@ -80,9 +80,11 @@ - - {% trans "History" %} - + {% if not ELECTION_IN_PROGRESS %} + + {% trans "History" %} + + {% endif %} diff --git a/backend/static_extras/css/colors.css b/backend/static_extras/css/colors.css index b1551b7f..eb39a993 100644 --- a/backend/static_extras/css/colors.css +++ b/backend/static_extras/css/colors.css @@ -14,4 +14,6 @@ --candidate-colorblock: #ffcc00; --ngo-colorblock: #5E72E4; + + --ngohub-yellow: #F9DE6E; } diff --git a/backend/static_extras/css/hub.css b/backend/static_extras/css/hub.css index d8a79100..9c55e178 100644 --- a/backend/static_extras/css/hub.css +++ b/backend/static_extras/css/hub.css @@ -584,6 +584,10 @@ hr.tight { background-color: var(--call2action); } +.button.is-main { + background-color: var(--ngohub-yellow); +} + .filter-grid { display: grid; overflow: hidden;