parent
4f5674073f
commit
3f28c04241
7 changed files with 62 additions and 16 deletions
|
@ -5,13 +5,13 @@ from . import VERSION
|
||||||
|
|
||||||
def settings(request):
|
def settings(request):
|
||||||
return {
|
return {
|
||||||
'UMAP_FEEDBACK_LINK': djsettings.UMAP_FEEDBACK_LINK,
|
"UMAP_FEEDBACK_LINK": djsettings.UMAP_FEEDBACK_LINK,
|
||||||
'SITE_NAME': djsettings.SITE_NAME,
|
"SITE_NAME": djsettings.SITE_NAME,
|
||||||
'ENABLE_ACCOUNT_LOGIN': djsettings.ENABLE_ACCOUNT_LOGIN,
|
"ENABLE_ACCOUNT_LOGIN": djsettings.ENABLE_ACCOUNT_LOGIN,
|
||||||
|
"UMAP_READONLY": djsettings.UMAP_READONLY,
|
||||||
|
"UMAP_DEMO_SITE": djsettings.UMAP_DEMO_SITE,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def version(request):
|
def version(request):
|
||||||
return {
|
return {"UMAP_VERSION": VERSION}
|
||||||
'UMAP_VERSION': VERSION
|
|
||||||
}
|
|
||||||
|
|
|
@ -30,7 +30,9 @@
|
||||||
<div class="col half center mwide">
|
<div class="col half center mwide">
|
||||||
{% spaceless %}
|
{% spaceless %}
|
||||||
<div class="button-bar {% if demo_map %}half{% endif %}">
|
<div class="button-bar {% if demo_map %}half{% endif %}">
|
||||||
<a href="{% url 'map_new' %}" class="button half">{% trans "Create a map" %}</a>
|
{% if not UMAP_READONLY %}
|
||||||
|
<a href="{% url 'map_new' %}" class="button half">{% trans "Create a map" %}</a>
|
||||||
|
{% endif %}
|
||||||
{% if demo_map %}
|
{% if demo_map %}
|
||||||
<a href="{{ demo_map.get_absolute_url }}" class="button half neutral">{% trans "Play with the demo" %}</a>
|
<a href="{{ demo_map.get_absolute_url }}" class="button half neutral">{% trans "Play with the demo" %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -18,6 +18,22 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{% if UMAP_READONLY %}
|
||||||
|
<div class="wrapper demo-instance-warning">
|
||||||
|
<div class="row">
|
||||||
|
<p>
|
||||||
|
{% blocktrans %}This instance of uMap is currently in read only mode, no creation/edit is allowed.{% endblocktrans %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if UMAP_DEMO_SITE %}
|
||||||
|
<div class="wrapper demo-instance-warning">
|
||||||
|
<div class="row">
|
||||||
|
{% 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 <a href="{{ stable_url }}">{{ stable_url }}</a>. You can also host your own instance, it's <a href="{{ repo_url }}">open source</a>!{% endblocktrans %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% block maincontent %}
|
{% block maincontent %}
|
||||||
{% endblock maincontent %}
|
{% endblock maincontent %}
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
|
@ -3,13 +3,6 @@
|
||||||
{% load umap_tags i18n %}
|
{% load umap_tags i18n %}
|
||||||
|
|
||||||
{% block maincontent %}
|
{% block maincontent %}
|
||||||
{% if DEMO_SITE %}
|
|
||||||
<div class="wrapper demo-instance-warning">
|
|
||||||
<div class="row">
|
|
||||||
{% 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 <a href="{{ stable_url }}">{{ stable_url }}</a>. You can also host your own instance, it's <a href="{{ repo_url }}">open source</a>!{% endblocktrans %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% include "umap/search_bar.html" %}
|
{% include "umap/search_bar.html" %}
|
||||||
{% include "umap/about_summary.html" %}
|
{% include "umap/about_summary.html" %}
|
||||||
{% if showcase_map %}
|
{% if showcase_map %}
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<a href="{% url 'map_new' %}" class="button">{% trans "Create a map" %}</a>
|
{% if not UMAP_READONLY %}
|
||||||
|
<a href="{% url 'map_new' %}" class="button">{% trans "Create a map" %}</a>
|
||||||
|
{% endif %}
|
||||||
</section>
|
</section>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
@ -162,3 +162,37 @@ def test_stats_basic(client, map, datalayer, user2):
|
||||||
"users_active_last_week_count": 1,
|
"users_active_last_week_count": 1,
|
||||||
"users_count": 2,
|
"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()
|
||||||
|
|
|
@ -125,7 +125,6 @@ class Home(TemplateView, PaginatorMixin):
|
||||||
"maps": maps,
|
"maps": maps,
|
||||||
"demo_map": demo_map,
|
"demo_map": demo_map,
|
||||||
"showcase_map": showcase_map,
|
"showcase_map": showcase_map,
|
||||||
"DEMO_SITE": settings.UMAP_DEMO_SITE,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_template_names(self):
|
def get_template_names(self):
|
||||||
|
|
Loading…
Reference in a new issue