diff --git a/umap/static/umap/js/umap.datalayer.permissions.js b/umap/static/umap/js/umap.datalayer.permissions.js index c9d3f42d..9e3e6211 100644 --- a/umap/static/umap/js/umap.datalayer.permissions.js +++ b/umap/static/umap/js/umap.datalayer.permissions.js @@ -34,11 +34,11 @@ L.U.DataLayerPermissions = L.Class.extend({ { handler: 'IntSelect', label: L._('Who can edit "{layer}"', { layer: this.datalayer.getName() }), - selectOptions: this.datalayer.map.options.edit_statuses, + selectOptions: this.datalayer.map.options.datalayer_edit_statuses, }, ], ], - builder = new L.U.FormBuilder(this, fields), + builder = new L.U.FormBuilder(this, fields, {className: 'umap-form datalayer-permissions'}), form = builder.build() container.appendChild(form) }, diff --git a/umap/tests/integration/test_anonymous_owned_map.py b/umap/tests/integration/test_anonymous_owned_map.py index 54e87fd9..20bc201e 100644 --- a/umap/tests/integration/test_anonymous_owned_map.py +++ b/umap/tests/integration/test_anonymous_owned_map.py @@ -83,6 +83,14 @@ def test_owner_permissions_form(map, datalayer, live_server, owner_session): expect(editors_field).to_be_hidden() datalayer_label = owner_session.get_by_text('Who can edit "test datalayer"') expect(datalayer_label).to_be_visible() + options = owner_session.locator( + ".datalayer-permissions select[name='edit_status'] option" + ) + expect(options).to_have_count(3) + option = owner_session.locator( + ".datalayer-permissions select[name='edit_status'] option:checked" + ) + expect(option).to_have_text("Inherit") def test_anonymous_can_add_marker_on_editable_layer( @@ -92,7 +100,9 @@ def test_anonymous_can_add_marker_on_editable_layer( datalayer.name = "Should not be in the select" datalayer.save() # Non editable by anonymous users assert datalayer.map == anonymap - other = DataLayerFactory(map=anonymap, edit_status=DataLayer.ANONYMOUS, name="Editable") + other = DataLayerFactory( + map=anonymap, edit_status=DataLayer.ANONYMOUS, name="Editable" + ) assert other.map == anonymap page.goto(f"{live_server.url}{anonymap.get_absolute_url()}?edit") add_marker = page.get_by_title("Draw a marker") diff --git a/umap/tests/integration/test_owned_map.py b/umap/tests/integration/test_owned_map.py index 171b8ca8..3bb9477e 100644 --- a/umap/tests/integration/test_owned_map.py +++ b/umap/tests/integration/test_owned_map.py @@ -88,6 +88,14 @@ def test_owner_permissions_form(map, datalayer, live_server, login): expect(editors_field).to_be_visible() datalayer_label = page.get_by_text('Who can edit "test datalayer"') expect(datalayer_label).to_be_visible() + options = page.locator( + ".datalayer-permissions select[name='edit_status'] option" + ) + expect(options).to_have_count(4) + option = page.locator( + ".datalayer-permissions select[name='edit_status'] option:checked" + ) + expect(option).to_have_text("Inherit") def test_map_update_with_editor(map, live_server, login, user): diff --git a/umap/views.py b/umap/views.py index f7fe3327..a0aa014e 100644 --- a/umap/views.py +++ b/umap/views.py @@ -464,8 +464,14 @@ class MapDetailMixin: properties["edit_statuses"] = [ (i, str(label)) for i, label in Map.EDIT_STATUS ] + properties["datalayer_edit_statuses"] = [ + (i, str(label)) for i, label in DataLayer.EDIT_STATUS + ] else: properties["edit_statuses"] = [ + (i, str(label)) for i, label in AnonymousMapPermissionsForm.STATUS + ] + properties["datalayer_edit_statuses"] = [ (i, str(label)) for i, label in AnonymousDataLayerPermissionsForm.STATUS ] if self.get_short_url():