Expose DataLayer.edit_status separately to the front

They now differ from the Map.edit_status ones
This commit is contained in:
Yohan Boniface 2023-09-19 08:37:06 +02:00
parent 6ba8166f86
commit 5ffd1a1b10
4 changed files with 27 additions and 3 deletions

View file

@ -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)
},

View file

@ -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")

View file

@ -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):

View file

@ -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():