Skip to content

Commit 9c1bc0f

Browse files
committed
organisations: add geolocation checkbox in admin
1 parent 38c7fd9 commit 9c1bc0f

File tree

7 files changed

+72
-27
lines changed

7 files changed

+72
-27
lines changed

adhocracy-plus/config/settings/test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@
1010
CAPTCHA_TEST_ACCEPTED_ANSWER = "testpass"
1111
CAPTCHA_URL = "https://captcheck.netsyms.com/api.php"
1212
WAGTAILADMIN_BASE_URL = "http://localhost:8004"
13+
14+
try:
15+
from .polygons import *
16+
except ImportError:
17+
pass

adhocracy-plus/templates/a4dashboard/base_dashboard_project.html

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
{% block dashboard_nav %}
55
<div class="u-bg-secondary u-spacer-bottom-double py-3">
66
<div class="container">
7-
<nav class="breadcrumbs" aria-label="{% translate 'breadcrumbs' %}">
7+
<nav class="breadcrumbs" aria-label="{% translate "breadcrumbs" %}">
88
<ul>
99
<li>
1010
<a href="{% url 'a4dashboard:project-list' organisation_slug=view.organisation.slug %}">
1111
<i class="fa fa-arrow-left" aria-hidden="true"></i>
12-
{% translate 'All projects' %}
12+
{% translate "All projects" %}
1313
</a>
1414
</li>
1515
</ul>
1616
</nav>
1717
</div>
1818
</div>
19-
{% endblock %}
19+
{% endblock dashboard_nav %}
2020

2121
{% block dashboard_content %}
2222
{% closed_accordions project.id as closed_accordions %}
2323
<div class="row">
24-
<nav class="col-md-3 js-selector-update-dashboard" aria-label="{% translate 'Project Settings' %}">
24+
<nav class="col-md-3 js-selector-update-dashboard" aria-label="{% translate "Project Settings" %}">
2525
<div class="dashboard-nav">
2626
<div
2727
class="dashboard-nav__dropdown{% if project.id in closed_accordions.0 %} collapsed{% endif %}"
@@ -33,24 +33,38 @@
3333
data-bs-target="#dashboardCollapseProj"
3434
>
3535
{% if project_progress.project_is_complete %}
36-
<i class="fas fa-check-circle text-info" title="{% translate 'Project ready for publication' %}" aria-label="{% translate 'Project ready for publication' %}"></i>
36+
<i class="fas fa-check-circle text-info" title="{% translate "Project ready for publication" %}" aria-label="{% translate "Project ready for publication" %}"></i>
3737
{% else %}
38-
<i class="fas fa-exclamation-circle text-danger" title="{% translate 'Project not ready for publication' %}" aria-label="{% translate 'Project not ready for publication' %}"></i>
38+
<i class="fas fa-exclamation-circle text-danger" title="{% translate "Project not ready for publication" %}" aria-label="{% translate "Project not ready for publication" %}"></i>
3939
{% endif %}
4040
{{ project.name }}
4141
<i class="fa fa-chevron-up" aria-hidden="true"></i>
4242
</div>
4343
<ul class="dashboard-nav__pages collapse{% if not project.id in closed_accordions.0 %} show{% endif %}" id="dashboardCollapseProj" aria-hidden="false">
4444
{% for item in dashboard_menu.project %}
45-
<li class="dashboard-nav__page">
46-
<a href="{{ item.url }}"
47-
class="dashboard-nav__item dashboard-nav__item--interactive {{ item.is_active|yesno:"is-active," }}">
48-
{% if not item.is_complete %}
49-
<i class="fa fa-exclamation-circle text-danger" title="{% translate 'Missing fields for publication' %}" aria-label="{% translate 'Missing fields for publication' %}"></i>
50-
{% endif %}
51-
{{ item.label }}
52-
</a>
53-
</li>
45+
{% if item.label != "Location" %}
46+
<li class="dashboard-nav__page">
47+
<a href="{{ item.url }}"
48+
class="dashboard-nav__item dashboard-nav__item--interactive {{ item.is_active|yesno:"is-active," }}">
49+
{% if not item.is_complete %}
50+
<i class="fa fa-exclamation-circle text-danger" title="{% translate "Missing fields for publication" %}" aria-label="{% translate "Missing fields for publication" %}"></i>
51+
{% endif %}
52+
{{ item.label }}
53+
</a>
54+
</li>
55+
{% else %}
56+
{% if project.organisation.enable_geolocation %}
57+
<li class="dashboard-nav__page">
58+
<a href="{{ item.url }}"
59+
class="dashboard-nav__item dashboard-nav__item--interactive {{ item.is_active|yesno:"is-active," }}">
60+
{% if not item.is_complete %}
61+
<i class="fa fa-exclamation-circle text-danger" title="{% translate "Missing fields for publication" %}" aria-label="{% translate "Missing fields for publication" %}"></i>
62+
{% endif %}
63+
{{ item.label }}
64+
</a>
65+
</li>
66+
{% endif %}
67+
{% endif %}
5468
{% endfor %}
5569
</ul>
5670
</div>
@@ -67,8 +81,8 @@
6781
<form enctype="multipart/form-data" action="{% url 'a4dashboard:module-delete' slug=module_menu.module.slug organisation_slug=project.organisation.slug %}" method="post">
6882
{% csrf_token %}
6983
<input type="hidden" name="referrer" value="{{ request.path }}" />
70-
<button type="submit" class="btn btn--none" value="{% translate 'Delete' %}">
71-
{% translate 'Delete' %}
84+
<button type="submit" class="btn btn--none" value="{% translate "Delete" %}">
85+
{% translate "Delete" %}
7286
</button>
7387
</form>
7488
</a>
@@ -86,9 +100,9 @@
86100
data-bs-target="#dashboardCollapse_{{ forloop.counter }}"
87101
>
88102
{% if module_menu.is_complete %}
89-
<i class="fas fa-check-circle text-info" title="{% translate 'Module ready for addition' %}" aria-label="{% translate 'Module ready for addition' %}"></i>
103+
<i class="fas fa-check-circle text-info" title="{% translate "Module ready for addition" %}" aria-label="{% translate "Module ready for addition" %}"></i>
90104
{% else %}
91-
<i class="fas fa-exclamation-circle text-danger" title="{% translate 'Module not ready for addition' %}" aria-label="{% translate 'Module not ready for addition' %}"></i>
105+
<i class="fas fa-exclamation-circle text-danger" title="{% translate "Module not ready for addition" %}" aria-label="{% translate "Module not ready for addition" %}"></i>
92106
{% endif %}
93107
{{ module_menu.module.name }}
94108
<i class="fa fa-chevron-up {% if module_menu.module.is_draft %}dashboard-nav-i-spacer{% endif %}" aria-hidden="true"></i>
@@ -100,7 +114,7 @@
100114
<a href="{{ item.url }}"
101115
class="dashboard-nav__item dashboard-nav__item--interactive {{ item.is_active|yesno:"is-active," }}">
102116
{% if not item.is_complete %}
103-
<i class="fa fa-exclamation-circle text-danger" title="{% translate 'Missing fields for publication' %}" aria-label="{% translate 'Missing fields for publication' %}"></i>
117+
<i class="fa fa-exclamation-circle text-danger" title="{% translate "Missing fields for publication" %}" aria-label="{% translate "Missing fields for publication" %}"></i>
104118
{% endif %}
105119
{{ item.label }}
106120
</a>
@@ -129,7 +143,7 @@
129143
checked
130144
{% if not project.is_draft %}disabled{% endif %}>
131145
<label class="form-check-label dashboard-nav__toggle-label" for="dashboardToggle_{{ forloop.counter }}">
132-
{% translate 'Hide from project' %}
146+
{% translate "Hide from project" %}
133147
</label>
134148
{% else %}
135149
<button name="action" value="publish" class="btn btn--none p-0 btn--none-reset"></button>
@@ -139,7 +153,7 @@
139153
id="dashboardToggle_{{ forloop.counter }}"
140154
{% if not module_menu.is_complete %}disabled{% endif %}>
141155
<label class="form-check-label dashboard-nav__toggle-label" for="dashboardToggle_{{ forloop.counter }}">
142-
{% translate 'Add to project' %}
156+
{% translate "Add to project" %}
143157
</label>
144158
{% endif %}
145159

@@ -154,12 +168,12 @@
154168

155169
{% has_perm 'a4projects.change_project' request.user view.project as user_may_add %}
156170
{% if user_may_add %}
157-
<a class="btn btn--light btn--full" href="{% url 'a4dashboard:module-blueprint-list' organisation_slug=project.organisation.slug project_slug=project.slug %}">{% translate 'Add Module' %}</a>
171+
<a class="btn btn--light btn--full" href="{% url 'a4dashboard:module-blueprint-list' organisation_slug=project.organisation.slug project_slug=project.slug %}">{% translate "Add Module" %}</a>
158172
{% endif %}
159173
</nav>
160174

161175
<div class="mb-5 col-md-6">
162-
{% block dashboard_project_content %}{% endblock %}
176+
{% block dashboard_project_content %}{% endblock dashboard_project_content %}
163177
</div>
164178

165179
<div class="col-md-3">
@@ -168,4 +182,4 @@
168182
{% include "a4dashboard/includes/preview.html" with project=project %}
169183
</div>
170184
</div>
171-
{% endblock %}
185+
{% endblock dashboard_content %}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
{% include "a4dashboard/includes/form_field.html" with field=form.administrative_district %}
21
{% include "a4dashboard/includes/form_field.html" with field=form.point %}

apps/organisations/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class OrganisationAdmin(TranslatableAdmin):
7474
(
7575
"Settings",
7676
{
77-
"fields": ("is_supporting", "language", "site"),
77+
"fields": ("is_supporting", "enable_geolocation", "language", "site"),
7878
},
7979
),
8080
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated by Django 4.2.13 on 2024-09-04 10:24
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("a4_candy_organisations", "0023_auto_20240328_1138"),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name="organisation",
15+
name="enable_geolocation",
16+
field=models.BooleanField(
17+
default=False,
18+
verbose_name="enable geolocation for projects",
19+
),
20+
),
21+
]

apps/organisations/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ class Organisation(TranslatableModel):
164164
"for donations is not displayed on their pages."
165165
),
166166
)
167+
enable_geolocation = models.BooleanField(
168+
default=False,
169+
verbose_name=_("enable geolocation for projects"),
170+
)
167171
language = models.CharField(
168172
verbose_name=_("Default language for e-mails"),
169173
choices=settings.LANGUAGES,

changelog/8304.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
### Added
22

33
- create project dashboard component for editing location
4+
- enable geolocation for projects from the admin in organisations
5+
- display location item in dashboard only if enable in the organisation

0 commit comments

Comments
 (0)