diff --git a/umap/settings/base.py b/umap/settings/base.py index a98413f5..1faa0aca 100644 --- a/umap/settings/base.py +++ b/umap/settings/base.py @@ -250,6 +250,7 @@ DATABASES = { } UMAP_DEFAULT_SHARE_STATUS = None UMAP_DEFAULT_EDIT_STATUS = None +UMAP_DEFAULT_FEATURES_HAVE_OWNERS = False UMAP_READONLY = env('UMAP_READONLY', default=False) UMAP_GZIP = True diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index 2c67911c..380bd134 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -1565,16 +1565,23 @@ L.U.Editable = L.Editable.extend({ }, createPolyline: function (latlngs) { - return new L.U.Polyline(this.map, latlngs) + return new L.U.Polyline(this.map, latlngs, this._getDefaultProperties()) }, createPolygon: function (latlngs) { - const polygon = new L.U.Polygon(this.map, latlngs) - return polygon + return new L.U.Polygon(this.map, latlngs, this._getDefaultProperties()) }, createMarker: function (latlng) { - return new L.U.Marker(this.map, latlng) + return new L.U.Marker(this.map, latlng, this._getDefaultProperties()) + }, + + _getDefaultProperties: function() { + const result = {} + if (this.map.options.featuresHaveOwner && this.map.options.hasOwnProperty('user')) { + result.geojson = { properties: { owner: this.map.options.user.id } } + } + return result }, connectCreatedToMap: function (layer) { diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index f363ec88..ccc961f3 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -47,6 +47,7 @@ L.Map.mergeOptions({ easing: false, permissions: {}, permanentCreditBackground: true, + featuresHaveOwner: false, }) L.U.Map.include({ diff --git a/umap/views.py b/umap/views.py index 7e7d11e4..cd907f7b 100644 --- a/umap/views.py +++ b/umap/views.py @@ -460,6 +460,7 @@ class MapDetailMixin: (i, str(label)) for i, label in Map.SHARE_STATUS if i != Map.BLOCKED ], "umap_version": VERSION, + "featuresHaveOwner": settings.UMAP_DEFAULT_FEATURES_HAVE_OWNERS, } created = bool(getattr(self, "object", None)) if (created and self.object.owner) or (not created and not user.is_anonymous):