From e0760ca403055c317fe1da4fdd922dcc475f3d63 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Wed, 31 May 2023 17:20:22 +0200 Subject: [PATCH] Only ask to send edit link if email has been set up --- umap/settings/base.py | 1 + umap/static/umap/js/umap.js | 6 +++++- umap/urls.py | 19 +++++++++++-------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/umap/settings/base.py b/umap/settings/base.py index 196c2a18..4e051c40 100644 --- a/umap/settings/base.py +++ b/umap/settings/base.py @@ -115,6 +115,7 @@ INSTALLED_APPS = ( DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" +FROM_EMAIL = None # ============================================================================= # Calculation of directories relative to the project module location diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index 9fcc106c..57299e87 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -1342,7 +1342,11 @@ L.U.Map.include({ alert.duration = Infinity this.options.umap_id = data.id this.permissions.setOptions(data.permissions) - if (data.permissions && data.permissions.anonymous_edit_url) { + if ( + data.permissions && + data.permissions.anonymous_edit_url && + this.options.urls.map_send_edit_link + ) { alert.actions = [ { label: L._('Send me the link'), diff --git a/umap/urls.py b/umap/urls.py index 33ffccfb..e4d71291 100644 --- a/umap/urls.py +++ b/umap/urls.py @@ -99,8 +99,7 @@ i18n_urls += decorated_patterns( name="map_star", ), ) -i18n_urls += decorated_patterns( - [map_permissions_check, never_cache], +map_urls = [ re_path( r"^map/(?P[\d]+)/update/settings/$", views.MapUpdate.as_view(), @@ -111,11 +110,6 @@ i18n_urls += decorated_patterns( views.UpdateMapPermissions.as_view(), name="map_update_permissions", ), - re_path( - r"^map/(?P[\d]+)/send-edit-link/$", - views.SendEditLink.as_view(), - name="map_send_edit_link", - ), re_path( r"^map/(?P[\d]+)/update/owner/$", views.AttachAnonymousMap.as_view(), @@ -146,7 +140,16 @@ i18n_urls += decorated_patterns( views.DataLayerDelete.as_view(), name="datalayer_delete", ), -) +] +if settings.FROM_EMAIL: + map_urls.append( + re_path( + r"^map/(?P[\d]+)/send-edit-link/$", + views.SendEditLink.as_view(), + name="map_send_edit_link", + ) + ) +i18n_urls += decorated_patterns([map_permissions_check, never_cache], *map_urls) urlpatterns += i18n_patterns( re_path(r"^$", views.home, name="home"), re_path(