-
{% trans "Create a map" %}
+ {% if not UMAP_READONLY %}
+
{% trans "Create a map" %}
+ {% endif %}
{% if demo_map %}
{% trans "Play with the demo" %}
{% endif %}
diff --git a/umap/templates/umap/content.html b/umap/templates/umap/content.html
index ca7fb698..dbd38ce5 100644
--- a/umap/templates/umap/content.html
+++ b/umap/templates/umap/content.html
@@ -18,6 +18,22 @@
{% endblock %}
{% block content %}
+ {% if UMAP_READONLY %}
+
+
+
+ {% blocktrans %}This instance of uMap is currently in read only mode, no creation/edit is allowed.{% endblocktrans %}
+
+
+
+ {% endif %}
+ {% if UMAP_DEMO_SITE %}
+
+
+ {% blocktrans with repo_url="https://github.com/umap-project/umap" stable_url="http://umap.openstreetmap.fr" %}This is a demo instance, used for tests and pre-rolling releases. If you need a stable instance, please use
{{ stable_url }}. You can also host your own instance, it's
open source!{% endblocktrans %}
+
+
+ {% endif %}
{% block maincontent %}
{% endblock maincontent %}
{% endblock content %}
diff --git a/umap/templates/umap/home.html b/umap/templates/umap/home.html
index b405786e..45bef52d 100644
--- a/umap/templates/umap/home.html
+++ b/umap/templates/umap/home.html
@@ -3,13 +3,6 @@
{% load umap_tags i18n %}
{% block maincontent %}
-{% if DEMO_SITE %}
-
-
- {% blocktrans with repo_url="https://github.com/umap-project/umap" stable_url="http://umap.openstreetmap.fr" %}This is a demo instance, used for tests and pre-rolling releases. If you need a stable instance, please use
{{ stable_url }}. You can also host your own instance, it's
open source!{% endblocktrans %}
-
-
-{% endif %}
{% include "umap/search_bar.html" %}
{% include "umap/about_summary.html" %}
{% if showcase_map %}
diff --git a/umap/templates/umap/navigation.html b/umap/templates/umap/navigation.html
index acde349a..58c4d8e6 100644
--- a/umap/templates/umap/navigation.html
+++ b/umap/templates/umap/navigation.html
@@ -24,6 +24,8 @@
diff --git a/umap/tests/test_views.py b/umap/tests/test_views.py
index d1f025a7..a4fa8d23 100644
--- a/umap/tests/test_views.py
+++ b/umap/tests/test_views.py
@@ -162,3 +162,37 @@ def test_stats_basic(client, map, datalayer, user2):
"users_active_last_week_count": 1,
"users_count": 2,
}
+
+
+@pytest.mark.django_db
+def test_read_only_displays_message_if_enabled(client, settings):
+ settings.UMAP_READONLY = True
+ response = client.get(reverse("home"))
+ assert (
+ "This instance of uMap is currently in read only mode"
+ in response.content.decode()
+ )
+
+
+@pytest.mark.django_db
+def test_read_only_does_not_display_message_if_disabled(client, settings):
+ settings.UMAP_READONLY = False
+ response = client.get(reverse("home"))
+ assert (
+ "This instance of uMap is currently in read only mode"
+ not in response.content.decode()
+ )
+
+
+@pytest.mark.django_db
+def test_read_only_hides_create_buttons_if_enabled(client, settings):
+ settings.UMAP_READONLY = True
+ response = client.get(reverse("home"))
+ assert "Create a map" not in response.content.decode()
+
+
+@pytest.mark.django_db
+def test_read_only_shows_create_buttons_if_disabled(client, settings):
+ settings.UMAP_READONLY = False
+ response = client.get(reverse("home"))
+ assert "Create a map" in response.content.decode()
diff --git a/umap/views.py b/umap/views.py
index 16018c49..ed242369 100644
--- a/umap/views.py
+++ b/umap/views.py
@@ -125,7 +125,6 @@ class Home(TemplateView, PaginatorMixin):
"maps": maps,
"demo_map": demo_map,
"showcase_map": showcase_map,
- "DEMO_SITE": settings.UMAP_DEMO_SITE,
}
def get_template_names(self):