Commit graph

138 commits

Author SHA1 Message Date
Yohan Boniface
9f377da1b2 Introduce UMAP_HOME_FEED to control which maps are shown on the home page
For now we have only three modes:
- latest, which is the default and shows the last updated maps
- highlighted, which shows only the map that have been starred by a least
  one staff member
- None, which does not show any map
2024-01-16 12:31:50 +01:00
David Larlet
c4e55d82cb
Fix imports 2023-12-27 13:43:47 -05:00
David Larlet
7484e52142
Improve maps’ pagination for the dashboard 2023-12-27 13:26:31 -05:00
David Larlet
8d11815625
Move _urls_for_js to utils.py (circular imports) 2023-12-27 11:41:08 -05:00
Alexis Métaireau
f37ed700f6 [feat] add a simple conflict resolution mecanism.
The server tries to merge conflicting saves of
the same layer.

What it does:

- use the `If-Unmodified-Since` header to check
  if changes happened to the stored data ;
- Compare the incoming version with its reference version
  to get a diff.
- Reapply the diff on top of the latest version.
- If the merge is not possible, return a
  "422 Conflict" HTTP response.
- If the merge worked, return the merged document,
  to be updated by the client.
2023-11-29 13:04:24 +01:00
Alexis Métaireau
72b0bc44ad [chore] remove python2 imports 2023-11-24 23:31:18 +01:00
Alexis Métaireau
35dc1acb07 [fix] Use timezone aware datetimes 2023-11-24 23:31:18 +01:00
Yohan Boniface
160c4ae420 Do not exclude DEMO and SHOWCASE maps anymore from home
Those maps can be excluded by setting their share_status=OPEN

cf #1414
2023-11-21 10:15:31 +01:00
Yohan Boniface
9af5375dbf Fix heavy request for getting user maps
This was creating a huge INNER JOIN, and is replaced
by a UNION

cf https://explain.dalibo.com/plan/91af244fg9d1ec21

Also remove the conditional queryset, as now "my maps"
is serverd by the dashboard page, so we can only serve
public maps on this URL.
2023-11-18 20:09:19 +01:00
David Larlet
13ca7e3e5d
Add tests for favicon-related views 2023-11-15 14:13:33 -05:00
Yohan Boniface
be0cefd02a
Merge pull request #1396 from umap-project/backup-api
Full map download endpoint
2023-11-15 15:39:36 +01:00
David Larlet
6f73038f92
Redirect favicon.ico and dynamic webmanifest 2023-11-14 22:50:25 -05:00
David Larlet
915d6b6db4
Set a default favicon 2023-11-14 17:32:40 -05:00
David Larlet
97fa8c2754
Allow the ?download option in URL 2023-11-14 13:26:52 -05:00
David Larlet
0be42d39cb
Full map download endpoint 2023-11-14 12:07:17 -05:00
Yohan Boniface
c1698545bd Make sure SHORT_SITE_URL is defined to expose Map.short_url 2023-09-26 10:34:50 +02:00
David Larlet
27e8fd0cac
Merge pull request #1324 from openbrian/add-username-to-features
Add username to features
2023-09-25 11:08:32 -04:00
Yohan Boniface
27f3e08bc1 Fix anonymous maps displayed by mistake in user dashboard 2023-09-22 19:00:42 +02:00
Yohan Boniface
c36ea1e4b8 Fix error when trying to change map owner
This bug has been introduced with this change:

8b4842ff21

That was not the correct fix, and this one should be the proper one.

We don't want to edit the permissions reference until we do save, otherwise user
cannot save as it is already no more the owner.

So:
- change permissions.options
- save
- commit those changes to map.options.permissions
- use only those values to check for isOwner and isAnonymousMap
2023-09-22 17:34:44 +02:00
Yohan Boniface
5ffd1a1b10 Expose DataLayer.edit_status separately to the front
They now differ from the Map.edit_status ones
2023-09-22 17:32:19 +02:00
Yohan Boniface
3cbd6cca40 Add back Map.edit_status
Revert "Fix existing permissions related tests"

This reverts commit 36d7d87301c54a1a40bc6bbc164120768b258fae.

WIP
2023-09-22 17:32:19 +02:00
Yohan Boniface
24e4aed8d3 Rename allowEdit in editMode 2023-09-22 17:32:17 +02:00
Yohan Boniface
168cc01c2e Do not try to access self.object in MapCreate 2023-09-22 17:30:07 +02:00
Yohan Boniface
e52b40807a Expose correct edit statuses in anonymous mode 2023-09-22 17:26:57 +02:00
Yohan Boniface
1cefd4e851 Hide create/delete datalayers button + map settings to users without rights 2023-09-22 17:26:57 +02:00
Yohan Boniface
ee9acf3427 Fix map check in DataLayerUpdate view 2023-09-22 17:26:57 +02:00
Yohan Boniface
3d2e62c858 Do not use Map.edit_status anymore
But keep it for now, for data migration, and just in case
2023-09-22 17:26:55 +02:00
Yohan Boniface
89ab029cab WIP: move edit_status from Map to DataLayer 2023-09-22 17:25:55 +02:00
Yohan Boniface
73d19e849f Refactor share_status check in datalayers views 2023-09-22 17:24:01 +02:00
Brian DeRocher
6720f76d85 Set the map option. No need for setting boolean from query string.
Only add the owner property if the feature flag (map.options.featuresHaveOwner) is enabled.

Default to features do NOT have owners.
2023-09-20 13:16:52 -04:00
Brian DeRocher
77b56623ed Remove field from map settings form. 2023-09-20 13:07:12 -04:00
Brian DeRocher
6c58bf367d Use camelcase and fix typo. 2023-09-20 13:03:36 -04:00
Brian DeRocher
e25fb5d04f Add FeaturesHaveOwners map option.
WIP
2023-09-20 12:48:32 -04:00
Yohan Boniface
f6730a9829
Update umap/views.py
Co-authored-by: David Larlet <3556+davidbgk@users.noreply.github.com>
2023-09-20 15:17:29 +02:00
Yohan Boniface
43e5391c49 Fix map displayed more than once in user dashboard when multiple editors
fix #1325
2023-09-20 11:30:05 +02:00
David Larlet
6cacc7122b
Avoid using a tuple as a content type when guessed
Only use the content type with mimetypes.guess_type
2023-08-29 15:24:58 -04:00
Yohan Boniface
bcdac413be ajax proxy: quote URL before passing it to Nginx 2023-08-28 18:00:40 +02:00
Yohan Boniface
c4bdb04795 Use X-Accel-Redirect for serving ajax-proxy request
uMap allows to use remote URL as data sources, but those URLs
are not always CORS open, so this is why there is this "ajax-proxy"
feature, where the URL is passed to the backend.

Additionally, there is a caching feature, which duration is configurable
through frontend settings. Valid values are: disabled, 5 min, 1 hour,
1 day.

Initially, I wanted this to be totally handled by Nginx, but I never
found a wayt to set the proxy_cache_valid value from a query string.

Since then, at least in OSM France servers, the ajax-proxy is still
handled by a Django view, which then opens the remote URL and transfert
the data. This is not optimal. And I suppose this is what is causing
hicups on the OSM France servers lately.

This PR provides a mix option, where python deals with validating the
URL and parsing the TTL parameter, and then it passes the hand to
nginx which will serve the remote content.

So, roughtly:

- the client calls /ajax-proxy/?url=xxx&ttl=300
- python will validate the URL (not internal calls…)
- if UMAP_SENDFILE_HEADER is set, then the python returns an empty
  response with the path /proxy/http://url plus it will set the
  cache ttl through the header X-Accel-Expires
- this /proxy/ location is then handled by nginx
2023-08-24 13:41:34 +02:00
Yohan Boniface
25b3a66351 Allow to add more than one OAuth provider 2023-08-21 17:08:57 +02:00
Yohan Boniface
2b471be171 Very lite "My Profile" page to allow changing username 2023-08-21 15:09:30 +02:00
Yohan Boniface
b5d0b50183 Catch timeout error in ajax proxy 2023-08-17 17:43:25 +02:00
Yohan Boniface
fc37ad7c17 Adapt logout behaviour in ajax/not ajax modes 2023-07-27 15:02:51 +02:00
Yohan Boniface
2f89e99cb8 Add a timeout in proxy
This view should not be used in production, but it is sometimes, so
just in case…
2023-07-21 12:51:31 +02:00
Yohan Boniface
d91184a021 gzip file may not be yet created when computing the Last-Modified 2023-07-20 09:02:40 +02:00
Yohan Boniface
13a1c3bd5c Use gzip mtime for Last-Modified comparison when in gzip mode
Prior to 1.3.0, uMap was not setting the gzip mtime, so it was
whatever the time it get requested at first.
Since 1.3.0:
- when creating the geojson.gzip, we also force its mtime to be
  the geojson one
- we replaced If-Match by If-Unmodified, which relies on Last-Modified

When uMap is served by a proxy like Nginx (and X-Accel-Redirect),
and if user accepts gzip, then the Last-Modified would be the gzip
one, not the flat geojson one.

So when comparing that value in a subsequent update, we need to
compare with the correct value.

fix #1212
2023-07-19 14:21:00 +02:00
Yohan Boniface
617d6ba9ef Fix last maps returned when search was empty 2023-07-15 09:31:55 +02:00
Yohan Boniface
6b539b9d40 Add pagination to map table in user dashboard 2023-07-15 09:31:55 +02:00
Yohan Boniface
4d0ced9a98 Add very basic user dashboard 2023-07-12 09:09:01 +02:00
Yohan Boniface
339ef3555f Use LANGUAGE_CODE instead of locale name for browser APIs
fix #1187
2023-07-03 19:44:49 +02:00
David Larlet
51978f9f2a
Display latest created maps on empty search 2023-06-30 21:40:35 -04:00