Merge pull request #1748 from umap-project/hide_delete_button
fix: hide delete button for editors in dashboard
This commit is contained in:
commit
0a6b736049
3 changed files with 17 additions and 0 deletions
|
@ -68,6 +68,7 @@
|
||||||
<span class="sr-only">{% translate "Clone" %}</span>
|
<span class="sr-only">{% translate "Clone" %}</span>
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
{% if map_inst|can_delete_map:request %}
|
||||||
<form action="{% url 'map_delete' map_inst.pk %}"
|
<form action="{% url 'map_delete' map_inst.pk %}"
|
||||||
method="post"
|
method="post"
|
||||||
class="map-delete">
|
class="map-delete">
|
||||||
|
@ -78,6 +79,7 @@
|
||||||
<span class="sr-only">{% translate "Delete" %}</span>
|
<span class="sr-only">{% translate "Delete" %}</span>
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
|
@ -43,6 +43,11 @@ def tilelayer_preview(tilelayer):
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
@register.filter
|
||||||
|
def can_delete_map(map, request):
|
||||||
|
return map.can_delete(request.user, request)
|
||||||
|
|
||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
def notag(s):
|
def notag(s):
|
||||||
return s.replace("<", "<")
|
return s.replace("<", "<")
|
||||||
|
|
|
@ -36,3 +36,13 @@ def test_dashboard_map_preview(map, live_server, datalayer, login):
|
||||||
expect(dialog).to_be_visible()
|
expect(dialog).to_be_visible()
|
||||||
# Let's check we have a marker on it, so we can guess the map loaded correctly
|
# Let's check we have a marker on it, so we can guess the map loaded correctly
|
||||||
expect(dialog.locator(".leaflet-marker-icon")).to_be_visible()
|
expect(dialog.locator(".leaflet-marker-icon")).to_be_visible()
|
||||||
|
|
||||||
|
|
||||||
|
def test_no_delete_button_for_editors(map, live_server, datalayer, login, user):
|
||||||
|
map.name = "Map I cannot delete"
|
||||||
|
map.editors.add(user)
|
||||||
|
map.save()
|
||||||
|
page = login(user)
|
||||||
|
page.goto(f"{live_server.url}/en/me")
|
||||||
|
expect(page.get_by_text("Map I cannot delete")).to_be_visible()
|
||||||
|
expect(page.get_by_title("Delete")).to_be_hidden()
|
||||||
|
|
Loading…
Reference in a new issue