2012-11-20 03:47:19 -06:00
|
|
|
from django.conf import settings
|
2013-05-14 06:23:40 -05:00
|
|
|
from django.conf.urls.i18n import i18n_patterns
|
2018-05-19 04:12:19 -05:00
|
|
|
from django.conf.urls.static import static
|
2012-11-20 03:47:19 -06:00
|
|
|
from django.contrib import admin
|
2016-01-04 13:43:08 -06:00
|
|
|
from django.contrib.auth import views as auth_views
|
2019-04-09 02:42:09 -05:00
|
|
|
from django.contrib.auth.decorators import login_required
|
2023-11-14 21:50:25 -06:00
|
|
|
from django.contrib.staticfiles.storage import staticfiles_storage
|
2018-05-19 04:12:19 -05:00
|
|
|
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
2023-11-23 11:04:23 -06:00
|
|
|
from django.urls import include, path, re_path
|
2023-02-23 04:10:24 -06:00
|
|
|
from django.views.decorators.cache import cache_control, cache_page, never_cache
|
2018-05-19 04:12:19 -05:00
|
|
|
from django.views.decorators.csrf import ensure_csrf_cookie
|
2023-11-14 21:50:25 -06:00
|
|
|
from django.views.generic.base import RedirectView
|
2013-06-08 08:40:53 -05:00
|
|
|
|
2012-11-20 03:47:19 -06:00
|
|
|
from . import views
|
2023-02-23 04:10:24 -06:00
|
|
|
from .decorators import (
|
2023-09-08 02:39:28 -05:00
|
|
|
can_edit_map,
|
2023-09-22 10:19:18 -05:00
|
|
|
can_view_map,
|
2023-11-23 11:04:23 -06:00
|
|
|
login_required_if_not_anonymous_allowed,
|
2023-02-23 04:10:24 -06:00
|
|
|
)
|
2018-05-19 04:12:19 -05:00
|
|
|
from .utils import decorated_patterns
|
2012-11-20 03:47:19 -06:00
|
|
|
|
|
|
|
admin.autodiscover()
|
|
|
|
|
2016-04-24 09:14:47 -05:00
|
|
|
urlpatterns = [
|
2023-02-23 04:10:24 -06:00
|
|
|
re_path(r"^admin/", admin.site.urls),
|
|
|
|
re_path("", include("social_django.urls", namespace="social")),
|
|
|
|
re_path(r"^m/(?P<pk>\d+)/$", views.MapShortUrl.as_view(), name="map_short_url"),
|
|
|
|
re_path(r"^ajax-proxy/$", cache_page(180)(views.ajax_proxy), name="ajax-proxy"),
|
|
|
|
re_path(
|
|
|
|
r"^change-password/",
|
|
|
|
auth_views.PasswordChangeView.as_view(),
|
|
|
|
{"template_name": "umap/password_change.html"},
|
|
|
|
name="password_change",
|
|
|
|
),
|
|
|
|
re_path(
|
|
|
|
r"^change-password-done/",
|
|
|
|
auth_views.PasswordChangeDoneView.as_view(),
|
|
|
|
{"template_name": "umap/password_change_done.html"},
|
|
|
|
name="password_change_done",
|
|
|
|
),
|
|
|
|
re_path(r"^i18n/", include("django.conf.urls.i18n")),
|
|
|
|
re_path(r"^agnocomplete/", include("agnocomplete.urls")),
|
2024-01-11 13:50:02 -06:00
|
|
|
re_path(r"^map/oembed/", views.MapOEmbed.as_view(), name="map_oembed"),
|
2023-11-08 14:20:59 -06:00
|
|
|
re_path(
|
|
|
|
r"^map/(?P<map_id>\d+)/download/",
|
|
|
|
can_view_map(views.MapDownload.as_view()),
|
|
|
|
name="map_download",
|
|
|
|
),
|
2016-04-24 09:14:47 -05:00
|
|
|
]
|
2018-05-19 04:12:19 -05:00
|
|
|
|
|
|
|
i18n_urls = [
|
2024-01-24 04:54:51 -06:00
|
|
|
re_path(r"^login/$", auth_views.LoginView.as_view(), name="login"),
|
2023-02-23 04:10:24 -06:00
|
|
|
re_path(
|
|
|
|
r"^login/popup/end/$", views.LoginPopupEnd.as_view(), name="login_popup_end"
|
|
|
|
),
|
|
|
|
re_path(r"^logout/$", views.logout, name="logout"),
|
|
|
|
re_path(
|
2023-09-22 10:19:18 -05:00
|
|
|
r"^map/(?P<map_id>\d+)/geojson/$",
|
2023-02-23 04:10:24 -06:00
|
|
|
views.MapViewGeoJSON.as_view(),
|
|
|
|
name="map_geojson",
|
|
|
|
),
|
|
|
|
re_path(
|
|
|
|
r"^map/anonymous-edit/(?P<signature>.+)$",
|
|
|
|
views.MapAnonymousEditUrl.as_view(),
|
|
|
|
name="map_anonymous_edit_url",
|
|
|
|
),
|
|
|
|
re_path(
|
|
|
|
r"^pictogram/json/$",
|
|
|
|
views.PictogramJSONList.as_view(),
|
|
|
|
name="pictogram_list_json",
|
|
|
|
),
|
2018-05-19 04:12:19 -05:00
|
|
|
]
|
2023-02-23 04:10:24 -06:00
|
|
|
i18n_urls += decorated_patterns(
|
2023-09-22 10:19:18 -05:00
|
|
|
[can_view_map, cache_control(must_revalidate=True)],
|
2024-02-22 08:08:13 -06:00
|
|
|
path(
|
|
|
|
"datalayer/<int:map_id>/<uuid:pk>/",
|
2023-02-23 04:10:24 -06:00
|
|
|
views.DataLayerView.as_view(),
|
|
|
|
name="datalayer_view",
|
|
|
|
),
|
2024-02-22 08:08:13 -06:00
|
|
|
path(
|
|
|
|
"datalayer/<int:map_id>/<uuid:pk>/versions/",
|
2023-02-23 04:10:24 -06:00
|
|
|
views.DataLayerVersions.as_view(),
|
|
|
|
name="datalayer_versions",
|
|
|
|
),
|
2024-02-22 08:08:13 -06:00
|
|
|
path(
|
|
|
|
"datalayer/<int:map_id>/<uuid:pk>/<str:name>",
|
2023-02-23 04:10:24 -06:00
|
|
|
views.DataLayerVersion.as_view(),
|
|
|
|
name="datalayer_version",
|
|
|
|
),
|
2018-05-19 04:12:19 -05:00
|
|
|
)
|
2023-02-23 04:10:24 -06:00
|
|
|
i18n_urls += decorated_patterns(
|
2023-09-22 10:19:18 -05:00
|
|
|
[can_view_map, ensure_csrf_cookie],
|
2023-02-23 04:10:24 -06:00
|
|
|
re_path(
|
2023-09-22 10:19:18 -05:00
|
|
|
r"^map/(?P<slug>[-_\w]+)_(?P<map_id>\d+)$", views.MapView.as_view(), name="map"
|
2023-02-23 04:10:24 -06:00
|
|
|
),
|
2023-09-22 10:19:18 -05:00
|
|
|
)
|
|
|
|
i18n_urls += decorated_patterns(
|
|
|
|
[ensure_csrf_cookie],
|
2024-02-01 05:24:22 -06:00
|
|
|
re_path(r"^map/$", views.MapPreview.as_view(), name="map_preview"),
|
2023-02-23 04:10:24 -06:00
|
|
|
re_path(r"^map/new/$", views.MapNew.as_view(), name="map_new"),
|
2018-05-19 04:12:19 -05:00
|
|
|
)
|
|
|
|
i18n_urls += decorated_patterns(
|
|
|
|
[login_required_if_not_anonymous_allowed, never_cache],
|
2023-02-23 04:10:24 -06:00
|
|
|
re_path(r"^map/create/$", views.MapCreate.as_view(), name="map_create"),
|
2018-05-19 04:12:19 -05:00
|
|
|
)
|
2019-04-09 02:42:09 -05:00
|
|
|
i18n_urls += decorated_patterns(
|
|
|
|
[login_required],
|
|
|
|
re_path(
|
2023-05-22 16:47:04 -05:00
|
|
|
r"^map/(?P<map_id>[\d]+)/star/$",
|
2023-05-05 15:13:10 -05:00
|
|
|
views.ToggleMapStarStatus.as_view(),
|
2023-05-22 16:47:04 -05:00
|
|
|
name="map_star",
|
2019-04-09 02:42:09 -05:00
|
|
|
),
|
2023-11-24 16:04:47 -06:00
|
|
|
re_path(r"^me$", views.user_dashboard, name="user_dashboard"),
|
|
|
|
re_path(r"^me/profile$", views.user_profile, name="user_profile"),
|
|
|
|
re_path(r"^me/download$", views.user_download, name="user_download"),
|
2019-04-09 02:42:09 -05:00
|
|
|
)
|
2023-05-31 10:20:22 -05:00
|
|
|
map_urls = [
|
2023-02-23 04:10:24 -06:00
|
|
|
re_path(
|
|
|
|
r"^map/(?P<map_id>[\d]+)/update/settings/$",
|
|
|
|
views.MapUpdate.as_view(),
|
|
|
|
name="map_update",
|
|
|
|
),
|
|
|
|
re_path(
|
|
|
|
r"^map/(?P<map_id>[\d]+)/update/permissions/$",
|
|
|
|
views.UpdateMapPermissions.as_view(),
|
|
|
|
name="map_update_permissions",
|
|
|
|
),
|
|
|
|
re_path(
|
|
|
|
r"^map/(?P<map_id>[\d]+)/update/owner/$",
|
|
|
|
views.AttachAnonymousMap.as_view(),
|
|
|
|
name="map_attach_owner",
|
|
|
|
),
|
|
|
|
re_path(
|
|
|
|
r"^map/(?P<map_id>[\d]+)/update/delete/$",
|
|
|
|
views.MapDelete.as_view(),
|
|
|
|
name="map_delete",
|
|
|
|
),
|
|
|
|
re_path(
|
|
|
|
r"^map/(?P<map_id>[\d]+)/update/clone/$",
|
|
|
|
views.MapClone.as_view(),
|
|
|
|
name="map_clone",
|
|
|
|
),
|
|
|
|
re_path(
|
|
|
|
r"^map/(?P<map_id>[\d]+)/datalayer/create/$",
|
|
|
|
views.DataLayerCreate.as_view(),
|
|
|
|
name="datalayer_create",
|
|
|
|
),
|
2024-02-22 08:08:13 -06:00
|
|
|
path(
|
|
|
|
"map/<int:map_id>/datalayer/delete/<uuid:pk>/",
|
2023-02-23 04:10:24 -06:00
|
|
|
views.DataLayerDelete.as_view(),
|
|
|
|
name="datalayer_delete",
|
|
|
|
),
|
2024-02-22 08:08:13 -06:00
|
|
|
path(
|
|
|
|
"map/<int:map_id>/datalayer/permissions/<uuid:pk>/",
|
2023-09-07 03:31:25 -05:00
|
|
|
views.UpdateDataLayerPermissions.as_view(),
|
|
|
|
name="datalayer_permissions",
|
|
|
|
),
|
2023-05-31 10:20:22 -05:00
|
|
|
]
|
2024-02-16 04:49:38 -06:00
|
|
|
if settings.DEFAULT_FROM_EMAIL:
|
2023-05-31 10:20:22 -05:00
|
|
|
map_urls.append(
|
|
|
|
re_path(
|
|
|
|
r"^map/(?P<map_id>[\d]+)/send-edit-link/$",
|
|
|
|
views.SendEditLink.as_view(),
|
|
|
|
name="map_send_edit_link",
|
|
|
|
)
|
|
|
|
)
|
2023-09-08 02:39:28 -05:00
|
|
|
datalayer_urls = [
|
2024-02-22 08:35:18 -06:00
|
|
|
path(
|
|
|
|
"map/<int:map_id>/datalayer/update/<uuid:pk>/",
|
2023-09-08 02:39:28 -05:00
|
|
|
views.DataLayerUpdate.as_view(),
|
|
|
|
name="datalayer_update",
|
|
|
|
),
|
|
|
|
]
|
|
|
|
i18n_urls += decorated_patterns([can_edit_map, never_cache], *map_urls)
|
|
|
|
i18n_urls += decorated_patterns([never_cache], *datalayer_urls)
|
2014-03-06 16:22:37 -06:00
|
|
|
urlpatterns += i18n_patterns(
|
2023-02-23 04:10:24 -06:00
|
|
|
re_path(r"^$", views.home, name="home"),
|
|
|
|
re_path(
|
|
|
|
r"^showcase/$", cache_page(24 * 60 * 60)(views.showcase), name="maps_showcase"
|
|
|
|
),
|
|
|
|
re_path(r"^search/$", views.search, name="search"),
|
|
|
|
re_path(r"^about/$", views.about, name="about"),
|
2023-06-16 07:59:59 -05:00
|
|
|
re_path(r"^user/(?P<identifier>.+)/stars/$", views.user_stars, name="user_stars"),
|
|
|
|
re_path(r"^user/(?P<identifier>.+)/$", views.user_maps, name="user_maps"),
|
2023-02-23 04:10:24 -06:00
|
|
|
re_path(r"", include(i18n_urls)),
|
2012-11-20 03:47:19 -06:00
|
|
|
)
|
2023-11-10 10:26:05 -06:00
|
|
|
urlpatterns += (
|
|
|
|
path("stats/", cache_page(60 * 60)(views.stats), name="stats"),
|
2023-11-14 21:50:25 -06:00
|
|
|
path(
|
|
|
|
"favicon.ico",
|
|
|
|
cache_control(max_age=60 * 60 * 24, immutable=True, public=True)(
|
|
|
|
RedirectView.as_view(
|
|
|
|
url=staticfiles_storage.url("umap/favicons/favicon.ico")
|
|
|
|
)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
path(
|
|
|
|
"manifest.webmanifest",
|
|
|
|
cache_control(max_age=60 * 60 * 24, immutable=True, public=True)(
|
|
|
|
views.webmanifest
|
|
|
|
),
|
|
|
|
),
|
2023-11-10 10:26:05 -06:00
|
|
|
)
|
2012-11-20 03:47:19 -06:00
|
|
|
|
|
|
|
if settings.DEBUG and settings.MEDIA_ROOT:
|
2023-02-23 04:10:24 -06:00
|
|
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
2012-11-20 03:47:19 -06:00
|
|
|
urlpatterns += staticfiles_urlpatterns()
|