From 9c1bc0f4909e4de56d5869b2f7cd4b227f4f8e95 Mon Sep 17 00:00:00 2001 From: Mara Karagianni Date: Wed, 4 Sep 2024 17:00:30 +0100 Subject: [PATCH] organisations: add geolocation checkbox in admin --- adhocracy-plus/config/settings/test.py | 5 ++ .../a4dashboard/base_dashboard_project.html | 64 +++++++++++-------- .../includes/project_location_form.html | 1 - apps/organisations/admin.py | 2 +- .../0024_organisation_enable_geolocation.py | 21 ++++++ apps/organisations/models.py | 4 ++ changelog/8304.md | 2 + 7 files changed, 72 insertions(+), 27 deletions(-) create mode 100644 apps/organisations/migrations/0024_organisation_enable_geolocation.py diff --git a/adhocracy-plus/config/settings/test.py b/adhocracy-plus/config/settings/test.py index 0c085e35b..5025abe94 100644 --- a/adhocracy-plus/config/settings/test.py +++ b/adhocracy-plus/config/settings/test.py @@ -10,3 +10,8 @@ CAPTCHA_TEST_ACCEPTED_ANSWER = "testpass" CAPTCHA_URL = "https://captcheck.netsyms.com/api.php" WAGTAILADMIN_BASE_URL = "http://localhost:8004" + +try: + from .polygons import * +except ImportError: + pass diff --git a/adhocracy-plus/templates/a4dashboard/base_dashboard_project.html b/adhocracy-plus/templates/a4dashboard/base_dashboard_project.html index de1a0ff42..1ab62ff54 100644 --- a/adhocracy-plus/templates/a4dashboard/base_dashboard_project.html +++ b/adhocracy-plus/templates/a4dashboard/base_dashboard_project.html @@ -4,24 +4,24 @@ {% block dashboard_nav %}
-{% endblock %} +{% endblock dashboard_nav %} {% block dashboard_content %} {% closed_accordions project.id as closed_accordions %}
-
-{% endblock %} +{% endblock dashboard_content %} diff --git a/adhocracy-plus/templates/a4dashboard/includes/project_location_form.html b/adhocracy-plus/templates/a4dashboard/includes/project_location_form.html index 6da8eeb7d..d11c1d69e 100644 --- a/adhocracy-plus/templates/a4dashboard/includes/project_location_form.html +++ b/adhocracy-plus/templates/a4dashboard/includes/project_location_form.html @@ -1,2 +1 @@ -{% include "a4dashboard/includes/form_field.html" with field=form.administrative_district %} {% include "a4dashboard/includes/form_field.html" with field=form.point %} diff --git a/apps/organisations/admin.py b/apps/organisations/admin.py index 798152d6a..5652ec89e 100644 --- a/apps/organisations/admin.py +++ b/apps/organisations/admin.py @@ -74,7 +74,7 @@ class OrganisationAdmin(TranslatableAdmin): ( "Settings", { - "fields": ("is_supporting", "language", "site"), + "fields": ("is_supporting", "enable_geolocation", "language", "site"), }, ), ) diff --git a/apps/organisations/migrations/0024_organisation_enable_geolocation.py b/apps/organisations/migrations/0024_organisation_enable_geolocation.py new file mode 100644 index 000000000..eb26f3f47 --- /dev/null +++ b/apps/organisations/migrations/0024_organisation_enable_geolocation.py @@ -0,0 +1,21 @@ +# Generated by Django 4.2.13 on 2024-09-04 10:24 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("a4_candy_organisations", "0023_auto_20240328_1138"), + ] + + operations = [ + migrations.AddField( + model_name="organisation", + name="enable_geolocation", + field=models.BooleanField( + default=False, + verbose_name="enable geolocation for projects", + ), + ), + ] diff --git a/apps/organisations/models.py b/apps/organisations/models.py index fbf3e6b0e..b2bb2ef44 100644 --- a/apps/organisations/models.py +++ b/apps/organisations/models.py @@ -164,6 +164,10 @@ class Organisation(TranslatableModel): "for donations is not displayed on their pages." ), ) + enable_geolocation = models.BooleanField( + default=False, + verbose_name=_("enable geolocation for projects"), + ) language = models.CharField( verbose_name=_("Default language for e-mails"), choices=settings.LANGUAGES, diff --git a/changelog/8304.md b/changelog/8304.md index dd2260b06..5ec747cee 100644 --- a/changelog/8304.md +++ b/changelog/8304.md @@ -1,3 +1,5 @@ ### Added - create project dashboard component for editing location +- enable geolocation for projects from the admin in organisations +- display location item in dashboard only if enable in the organisation