Skip to content

Commit

Permalink
organisations: add geolocation checkbox in admin
Browse files Browse the repository at this point in the history
  • Loading branch information
m4ra committed Sep 4, 2024
1 parent 38c7fd9 commit 9c1bc0f
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 27 deletions.
5 changes: 5 additions & 0 deletions adhocracy-plus/config/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
64 changes: 39 additions & 25 deletions adhocracy-plus/templates/a4dashboard/base_dashboard_project.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
{% block dashboard_nav %}
<div class="u-bg-secondary u-spacer-bottom-double py-3">
<div class="container">
<nav class="breadcrumbs" aria-label="{% translate 'breadcrumbs' %}">
<nav class="breadcrumbs" aria-label="{% translate "breadcrumbs" %}">
<ul>
<li>
<a href="{% url 'a4dashboard:project-list' organisation_slug=view.organisation.slug %}">
<i class="fa fa-arrow-left" aria-hidden="true"></i>
{% translate 'All projects' %}
{% translate "All projects" %}
</a>
</li>
</ul>
</nav>
</div>
</div>
{% endblock %}
{% endblock dashboard_nav %}

{% block dashboard_content %}
{% closed_accordions project.id as closed_accordions %}
<div class="row">
<nav class="col-md-3 js-selector-update-dashboard" aria-label="{% translate 'Project Settings' %}">
<nav class="col-md-3 js-selector-update-dashboard" aria-label="{% translate "Project Settings" %}">
<div class="dashboard-nav">
<div
class="dashboard-nav__dropdown{% if project.id in closed_accordions.0 %} collapsed{% endif %}"
Expand All @@ -33,24 +33,38 @@
data-bs-target="#dashboardCollapseProj"
>
{% if project_progress.project_is_complete %}
<i class="fas fa-check-circle text-info" title="{% translate 'Project ready for publication' %}" aria-label="{% translate 'Project ready for publication' %}"></i>
<i class="fas fa-check-circle text-info" title="{% translate "Project ready for publication" %}" aria-label="{% translate "Project ready for publication" %}"></i>
{% else %}
<i class="fas fa-exclamation-circle text-danger" title="{% translate 'Project not ready for publication' %}" aria-label="{% translate 'Project not ready for publication' %}"></i>
<i class="fas fa-exclamation-circle text-danger" title="{% translate "Project not ready for publication" %}" aria-label="{% translate "Project not ready for publication" %}"></i>
{% endif %}
{{ project.name }}
<i class="fa fa-chevron-up" aria-hidden="true"></i>
</div>
<ul class="dashboard-nav__pages collapse{% if not project.id in closed_accordions.0 %} show{% endif %}" id="dashboardCollapseProj" aria-hidden="false">
{% for item in dashboard_menu.project %}
<li class="dashboard-nav__page">
<a href="{{ item.url }}"
class="dashboard-nav__item dashboard-nav__item--interactive {{ item.is_active|yesno:"is-active," }}">
{% if not item.is_complete %}
<i class="fa fa-exclamation-circle text-danger" title="{% translate 'Missing fields for publication' %}" aria-label="{% translate 'Missing fields for publication' %}"></i>
{% endif %}
{{ item.label }}
</a>
</li>
{% if item.label != "Location" %}
<li class="dashboard-nav__page">
<a href="{{ item.url }}"
class="dashboard-nav__item dashboard-nav__item--interactive {{ item.is_active|yesno:"is-active," }}">
{% if not item.is_complete %}
<i class="fa fa-exclamation-circle text-danger" title="{% translate "Missing fields for publication" %}" aria-label="{% translate "Missing fields for publication" %}"></i>
{% endif %}
{{ item.label }}
</a>
</li>
{% else %}
{% if project.organisation.enable_geolocation %}
<li class="dashboard-nav__page">
<a href="{{ item.url }}"
class="dashboard-nav__item dashboard-nav__item--interactive {{ item.is_active|yesno:"is-active," }}">
{% if not item.is_complete %}
<i class="fa fa-exclamation-circle text-danger" title="{% translate "Missing fields for publication" %}" aria-label="{% translate "Missing fields for publication" %}"></i>
{% endif %}
{{ item.label }}
</a>
</li>
{% endif %}
{% endif %}
{% endfor %}
</ul>
</div>
Expand All @@ -67,8 +81,8 @@
<form enctype="multipart/form-data" action="{% url 'a4dashboard:module-delete' slug=module_menu.module.slug organisation_slug=project.organisation.slug %}" method="post">
{% csrf_token %}
<input type="hidden" name="referrer" value="{{ request.path }}" />
<button type="submit" class="btn btn--none" value="{% translate 'Delete' %}">
{% translate 'Delete' %}
<button type="submit" class="btn btn--none" value="{% translate "Delete" %}">
{% translate "Delete" %}
</button>
</form>
</a>
Expand All @@ -86,9 +100,9 @@
data-bs-target="#dashboardCollapse_{{ forloop.counter }}"
>
{% if module_menu.is_complete %}
<i class="fas fa-check-circle text-info" title="{% translate 'Module ready for addition' %}" aria-label="{% translate 'Module ready for addition' %}"></i>
<i class="fas fa-check-circle text-info" title="{% translate "Module ready for addition" %}" aria-label="{% translate "Module ready for addition" %}"></i>
{% else %}
<i class="fas fa-exclamation-circle text-danger" title="{% translate 'Module not ready for addition' %}" aria-label="{% translate 'Module not ready for addition' %}"></i>
<i class="fas fa-exclamation-circle text-danger" title="{% translate "Module not ready for addition" %}" aria-label="{% translate "Module not ready for addition" %}"></i>
{% endif %}
{{ module_menu.module.name }}
<i class="fa fa-chevron-up {% if module_menu.module.is_draft %}dashboard-nav-i-spacer{% endif %}" aria-hidden="true"></i>
Expand All @@ -100,7 +114,7 @@
<a href="{{ item.url }}"
class="dashboard-nav__item dashboard-nav__item--interactive {{ item.is_active|yesno:"is-active," }}">
{% if not item.is_complete %}
<i class="fa fa-exclamation-circle text-danger" title="{% translate 'Missing fields for publication' %}" aria-label="{% translate 'Missing fields for publication' %}"></i>
<i class="fa fa-exclamation-circle text-danger" title="{% translate "Missing fields for publication" %}" aria-label="{% translate "Missing fields for publication" %}"></i>
{% endif %}
{{ item.label }}
</a>
Expand Down Expand Up @@ -129,7 +143,7 @@
checked
{% if not project.is_draft %}disabled{% endif %}>
<label class="form-check-label dashboard-nav__toggle-label" for="dashboardToggle_{{ forloop.counter }}">
{% translate 'Hide from project' %}
{% translate "Hide from project" %}
</label>
{% else %}
<button name="action" value="publish" class="btn btn--none p-0 btn--none-reset"></button>
Expand All @@ -139,7 +153,7 @@
id="dashboardToggle_{{ forloop.counter }}"
{% if not module_menu.is_complete %}disabled{% endif %}>
<label class="form-check-label dashboard-nav__toggle-label" for="dashboardToggle_{{ forloop.counter }}">
{% translate 'Add to project' %}
{% translate "Add to project" %}
</label>
{% endif %}

Expand All @@ -154,12 +168,12 @@

{% has_perm 'a4projects.change_project' request.user view.project as user_may_add %}
{% if user_may_add %}
<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>
<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>
{% endif %}
</nav>

<div class="mb-5 col-md-6">
{% block dashboard_project_content %}{% endblock %}
{% block dashboard_project_content %}{% endblock dashboard_project_content %}
</div>

<div class="col-md-3">
Expand All @@ -168,4 +182,4 @@
{% include "a4dashboard/includes/preview.html" with project=project %}
</div>
</div>
{% endblock %}
{% endblock dashboard_content %}
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
{% include "a4dashboard/includes/form_field.html" with field=form.administrative_district %}
{% include "a4dashboard/includes/form_field.html" with field=form.point %}
2 changes: 1 addition & 1 deletion apps/organisations/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class OrganisationAdmin(TranslatableAdmin):
(
"Settings",
{
"fields": ("is_supporting", "language", "site"),
"fields": ("is_supporting", "enable_geolocation", "language", "site"),
},
),
)
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
),
),
]
4 changes: 4 additions & 0 deletions apps/organisations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions changelog/8304.md
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9c1bc0f

Please sign in to comment.