fix: make sure to display anonymous edit link even if email is not configured
This commit is contained in:
parent
45812432fc
commit
8c20397209
2 changed files with 29 additions and 11 deletions
|
@ -1023,11 +1023,7 @@ U.Map = L.Map.extend({
|
|||
this.options.umap_id = data.id
|
||||
this.permissions.setOptions(data.permissions)
|
||||
this.permissions.commit()
|
||||
if (
|
||||
data.permissions &&
|
||||
data.permissions.anonymous_edit_url &&
|
||||
this.options.urls.map_send_edit_link
|
||||
) {
|
||||
if (data.permissions && data.permissions.anonymous_edit_url) {
|
||||
alert.duration = Infinity
|
||||
alert.content =
|
||||
L._(
|
||||
|
@ -1035,12 +1031,6 @@ U.Map = L.Map.extend({
|
|||
) + `<br>${data.permissions.anonymous_edit_url}`
|
||||
|
||||
alert.actions = [
|
||||
{
|
||||
label: L._('Send me the link'),
|
||||
input: L._('Email'),
|
||||
callback: this.sendEditLink,
|
||||
callbackContext: this,
|
||||
},
|
||||
{
|
||||
label: L._('Copy link'),
|
||||
callback: () => {
|
||||
|
@ -1053,6 +1043,14 @@ U.Map = L.Map.extend({
|
|||
callbackContext: this,
|
||||
},
|
||||
]
|
||||
if (this.options.urls.map_send_edit_link) {
|
||||
alert.actions.push({
|
||||
label: L._('Send me the link'),
|
||||
input: L._('Email'),
|
||||
callback: this.sendEditLink,
|
||||
callbackContext: this,
|
||||
})
|
||||
}
|
||||
}
|
||||
} else if (!this.permissions.isDirty) {
|
||||
// Do not override local changes to permissions,
|
||||
|
|
|
@ -203,3 +203,23 @@ def test_email_sending_error_are_catched(tilelayer, page, live_server):
|
|||
alert.get_by_role("button", name="Send me the link").click()
|
||||
assert patched.called
|
||||
expect(alert.get_by_text("Can't send email to foo@bar.com")).to_be_visible()
|
||||
|
||||
|
||||
def test_alert_message_after_create_show_link_even_without_mail(
|
||||
tilelayer, live_server, page, monkeypatch, settings
|
||||
):
|
||||
# Disable email
|
||||
settings.DEFAULT_FROM_EMAIL = None
|
||||
page.goto(f"{live_server.url}/en/map/new")
|
||||
with page.expect_response(re.compile(r".*/map/create/")):
|
||||
page.get_by_role("button", name="Save").click()
|
||||
alert = page.locator(".umap-alert")
|
||||
expect(alert).to_be_visible()
|
||||
expect(
|
||||
alert.get_by_text(
|
||||
"Your map has been created! As you are not logged in, here is your secret "
|
||||
"link to edit the map, please keep it safe:"
|
||||
)
|
||||
).to_be_visible()
|
||||
expect(alert.get_by_role("button", name="Copy")).to_be_visible()
|
||||
expect(alert.get_by_role("button", name="Send me the link")).to_be_hidden()
|
||||
|
|
Loading…
Reference in a new issue