Merge pull request #1112 from umap-project/1095-read-only-banner
Banner + no create buttons when in read only mode
This commit is contained in:
commit
b6628a3015
7 changed files with 62 additions and 16 deletions
|
@ -5,13 +5,13 @@ from . import VERSION
|
|||
|
||||
def settings(request):
|
||||
return {
|
||||
'UMAP_FEEDBACK_LINK': djsettings.UMAP_FEEDBACK_LINK,
|
||||
'SITE_NAME': djsettings.SITE_NAME,
|
||||
'ENABLE_ACCOUNT_LOGIN': djsettings.ENABLE_ACCOUNT_LOGIN,
|
||||
"UMAP_FEEDBACK_LINK": djsettings.UMAP_FEEDBACK_LINK,
|
||||
"SITE_NAME": djsettings.SITE_NAME,
|
||||
"ENABLE_ACCOUNT_LOGIN": djsettings.ENABLE_ACCOUNT_LOGIN,
|
||||
"UMAP_READONLY": djsettings.UMAP_READONLY,
|
||||
"UMAP_DEMO_SITE": djsettings.UMAP_DEMO_SITE,
|
||||
}
|
||||
|
||||
|
||||
def version(request):
|
||||
return {
|
||||
'UMAP_VERSION': VERSION
|
||||
}
|
||||
return {"UMAP_VERSION": VERSION}
|
||||
|
|
|
@ -30,7 +30,9 @@
|
|||
<div class="col half center mwide">
|
||||
{% spaceless %}
|
||||
<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 %}
|
||||
<a href="{{ demo_map.get_absolute_url }}" class="button half neutral">{% trans "Play with the demo" %}</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -18,6 +18,22 @@
|
|||
{% endblock %}
|
||||
|
||||
{% 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 %}
|
||||
{% endblock maincontent %}
|
||||
{% endblock content %}
|
||||
|
|
|
@ -3,13 +3,6 @@
|
|||
{% load umap_tags i18n %}
|
||||
|
||||
{% 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/about_summary.html" %}
|
||||
{% if showcase_map %}
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
</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>
|
||||
</nav>
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue