summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauréline Guérin <zebuline@entrouvert.com>2019-10-21 13:31:04 (GMT)
committerLauréline Guérin <zebuline@entrouvert.com>2019-11-05 09:40:49 (GMT)
commit63a4bf975fc554df02abefea31bd505ddc9d7d9d (patch)
tree2572f242e3dde4a201e29d64330fcfdae83ddea0
parent992f6fc71a3164f6096a268571f1032f25aa0a11 (diff)
downloadcombo-wip/16908-maps-shortcuts.zip
combo-wip/16908-maps-shortcuts.tar.gz
combo-wip/16908-maps-shortcuts.tar.bz2
maps: add link to existing maps on manager map page (#16908)wip/16908-maps-shortcuts
-rw-r--r--combo/apps/maps/manager_views.py6
-rw-r--r--combo/apps/maps/templates/maps/manager_home.html24
-rw-r--r--tests/test_maps_manager.py15
3 files changed, 45 insertions, 0 deletions
diff --git a/combo/apps/maps/manager_views.py b/combo/apps/maps/manager_views.py
index c7e82ec..c934677 100644
--- a/combo/apps/maps/manager_views.py
+++ b/combo/apps/maps/manager_views.py
@@ -18,6 +18,7 @@ from django.core.urlresolvers import reverse_lazy
from django.views.generic import (TemplateView, ListView, CreateView,
UpdateView, DeleteView)
+from .models import Map
from .models import MapLayer
from .forms import MapNewLayerForm, MapLayerForm
@@ -30,6 +31,11 @@ class MapLayerMixin(object):
class ManagerHomeView(MapLayerMixin, ListView):
template_name = 'maps/manager_home.html'
+ def get_context_data(self, **kwargs):
+ context = super(ManagerHomeView, self).get_context_data(**kwargs)
+ context['map_list'] = Map.objects.all()
+ return context
+
class LayerAddView(MapLayerMixin, CreateView):
form_class = MapNewLayerForm
diff --git a/combo/apps/maps/templates/maps/manager_home.html b/combo/apps/maps/templates/maps/manager_home.html
index 4531edf..281dcb1 100644
--- a/combo/apps/maps/templates/maps/manager_home.html
+++ b/combo/apps/maps/templates/maps/manager_home.html
@@ -26,4 +26,28 @@
{% endblocktrans %}
</div>
{% endif %}
+
+<h2>{% trans 'Maps on site' %}</h2>
+
+{% if map_list %}
+<ul class="objects-list single-links maps">
+ {% for map in map_list %}
+ <li>
+ <a href="{% url 'combo-manager-page-view' pk=map.page_id %}#cell-{{ map.get_reference }}">
+ {% if map.title %}
+ {% blocktrans with map_title=map.title page_title=map.page.title %}Map "{{ map_title }}" on page "{{ page_title }}"{% endblocktrans %}
+ {% else %}
+ {% blocktrans with page_title=map.page.title %}Unnamed map on page "{{ page_title }}"{% endblocktrans %}
+ {% endif %}
+ </a>
+ </li>
+ {% endfor %}
+</ul>
+{% else %}
+<div class="big-msg-info">
+ {% blocktrans %}
+ This site doesn't have any map yet.
+ {% endblocktrans %}
+</div>
+{% endif %}
{% endblock %}
diff --git a/tests/test_maps_manager.py b/tests/test_maps_manager.py
index edb95b2..1c54d73 100644
--- a/tests/test_maps_manager.py
+++ b/tests/test_maps_manager.py
@@ -5,7 +5,9 @@ import mock
from django.contrib.auth.models import User
+from combo.apps.maps.models import Map
from combo.apps.maps.models import MapLayer
+from combo.data.models import Page
pytestmark = pytest.mark.django_db
@@ -66,6 +68,19 @@ def test_delete_layer(app, admin_user):
assert resp.location.endswith('/manage/maps/')
assert MapLayer.objects.count() == 0
+
+def test_list_layers(app, admin_user):
+ page = Page.objects.create(title='One', slug='one', template_name='standard')
+ map1 = Map.objects.create(page=page, placeholder='map 1', order=0)
+ map2 = Map.objects.create(page=page, placeholder='map 2', order=1)
+
+ test_add_layer(app, admin_user)
+ app = login(app)
+ resp = app.get('/manage/maps/', status=200)
+ assert '/manage/pages/{}/#cell-{}'.format(page.pk, map1.get_reference()) in resp.text
+ assert '/manage/pages/{}/#cell-{}'.format(page.pk, map2.get_reference()) in resp.text
+
+
@mock.patch('combo.apps.maps.models.requests.get')
def test_download_geojson(mock_request, app, admin_user):
test_add_layer(app, admin_user)