Merge pull request #1324 from openbrian/add-username-to-features

Add username to features
This commit is contained in:
David Larlet 2023-09-25 11:08:32 -04:00 committed by GitHub
commit 27e8fd0cac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 4 deletions

View file

@ -250,6 +250,7 @@ DATABASES = {
} }
UMAP_DEFAULT_SHARE_STATUS = None UMAP_DEFAULT_SHARE_STATUS = None
UMAP_DEFAULT_EDIT_STATUS = None UMAP_DEFAULT_EDIT_STATUS = None
UMAP_DEFAULT_FEATURES_HAVE_OWNERS = False
UMAP_READONLY = env('UMAP_READONLY', default=False) UMAP_READONLY = env('UMAP_READONLY', default=False)
UMAP_GZIP = True UMAP_GZIP = True

View file

@ -1565,16 +1565,23 @@ L.U.Editable = L.Editable.extend({
}, },
createPolyline: function (latlngs) { createPolyline: function (latlngs) {
return new L.U.Polyline(this.map, latlngs) return new L.U.Polyline(this.map, latlngs, this._getDefaultProperties())
}, },
createPolygon: function (latlngs) { createPolygon: function (latlngs) {
const polygon = new L.U.Polygon(this.map, latlngs) return new L.U.Polygon(this.map, latlngs, this._getDefaultProperties())
return polygon
}, },
createMarker: function (latlng) { 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) { connectCreatedToMap: function (layer) {

View file

@ -47,6 +47,7 @@ L.Map.mergeOptions({
easing: false, easing: false,
permissions: {}, permissions: {},
permanentCreditBackground: true, permanentCreditBackground: true,
featuresHaveOwner: false,
}) })
L.U.Map.include({ L.U.Map.include({

View file

@ -460,6 +460,7 @@ class MapDetailMixin:
(i, str(label)) for i, label in Map.SHARE_STATUS if i != Map.BLOCKED (i, str(label)) for i, label in Map.SHARE_STATUS if i != Map.BLOCKED
], ],
"umap_version": VERSION, "umap_version": VERSION,
"featuresHaveOwner": settings.UMAP_DEFAULT_FEATURES_HAVE_OWNERS,
} }
created = bool(getattr(self, "object", None)) created = bool(getattr(self, "object", None))
if (created and self.object.owner) or (not created and not user.is_anonymous): if (created and self.object.owner) or (not created and not user.is_anonymous):