2009-08-31 17:36:21 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
# coding: utf-8
|
|
|
|
|
|
|
|
# maposmatic, the web front-end of the MapOSMatic city map generation system
|
|
|
|
# Copyright (C) 2009 David Decotigny
|
|
|
|
# Copyright (C) 2009 Frédéric Lehobey
|
|
|
|
# Copyright (C) 2009 David Mentré
|
|
|
|
# Copyright (C) 2009 Maxime Petazzoni
|
|
|
|
# Copyright (C) 2009 Thomas Petazzoni
|
|
|
|
# Copyright (C) 2009 Gaël Utard
|
2019-04-12 22:35:37 +00:00
|
|
|
# Copyright (C) 2018 Hartmut Holzgraefe
|
2009-08-31 17:36:21 +00:00
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or any later version.
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2012-04-26 21:50:42 +00:00
|
|
|
import django
|
2018-04-04 06:55:47 +00:00
|
|
|
from django.conf.urls import url, include
|
|
|
|
from django.views.static import serve
|
2009-08-28 13:36:10 +00:00
|
|
|
|
|
|
|
# Uncomment the next two lines to enable the admin:
|
|
|
|
# from django.contrib import admin
|
|
|
|
# admin.autodiscover()
|
|
|
|
|
2017-09-17 19:58:58 +00:00
|
|
|
from .maposmatic import feeds
|
|
|
|
from .maposmatic import views
|
2018-09-10 21:27:56 +00:00
|
|
|
from .maposmatic import apis
|
|
|
|
|
2017-09-17 19:58:58 +00:00
|
|
|
from . import settings
|
2009-08-28 13:36:10 +00:00
|
|
|
|
2018-04-04 06:55:47 +00:00
|
|
|
urlpatterns = [
|
2012-12-13 05:56:10 +00:00
|
|
|
url(r'^$',
|
2017-09-17 19:58:58 +00:00
|
|
|
views.index,
|
2010-01-10 14:53:57 +00:00
|
|
|
name='main'),
|
|
|
|
|
2012-12-13 05:56:10 +00:00
|
|
|
url(r'^new/$',
|
2017-09-17 19:58:58 +00:00
|
|
|
views.new,
|
2010-01-10 14:54:10 +00:00
|
|
|
name='new'),
|
2012-12-13 05:56:10 +00:00
|
|
|
url(r'^recreate/$',
|
2017-09-17 19:58:58 +00:00
|
|
|
views.recreate,
|
2010-05-14 09:51:24 +00:00
|
|
|
name='recreate'),
|
2012-12-13 05:56:10 +00:00
|
|
|
url(r'^cancel/$',
|
2017-09-17 19:58:58 +00:00
|
|
|
views.cancel,
|
Job cancel feature
This change introduces the job cancel feature as requested in bug #28488
(https://savannah.nongnu.org/bugs/?28488).
To do so, a new field called 'nonce' is added to the MapRenderingJob
model object (which results in a new column in the database, see below
how to recreate/update a current database). A random string, called the
nonce, is generated when the job is created and stored alongside the
other information on this job. The user is then redirected to the
/jobs/ID/NONCE page, instead of simply /jobs/ID.
As long as the user provides the correct nonce at the end of the URL, he
will have the ability, if the job is still in the queue, to cancel the
job request. The button to cancel the request is shown if and only if
the user provides the matching nonce string in the URL, which is only
displayed when the job is created.
A new job state is also created (4, Cancelled) to match this new
cancelled state.
As far as the database change goes, the easiest if you are only doing
development is to drop your database and recreate it with syncdb. If you
need to keep your data, you can simply add the column to the
maposmatic_maprenderingjob table using the following statement:
ALTER TABLE maposmatic_maprenderingjob ADD COLUMN
nonce varchar(16) NOT NULL;
Signed-off-by: Maxime Petazzoni <maxime.petazzoni@bulix.org>
Acked-by: Thomas Petazzoni <thomas.petazzoni@enix.org>
2010-06-20 17:40:11 +00:00
|
|
|
name='cancel'),
|
|
|
|
|
2012-12-13 05:56:10 +00:00
|
|
|
url(r'^maps/(?P<id>\d+)/(?P<nonce>[A-Za-z]{16})$',
|
2017-09-17 19:58:58 +00:00
|
|
|
views.map_full,
|
2012-12-13 05:56:10 +00:00
|
|
|
name='map-by-id-and-nonce'),
|
|
|
|
url(r'^maps/(?P<id>\d+)$',
|
2017-09-17 19:58:58 +00:00
|
|
|
views.map_full,
|
2012-12-13 05:56:10 +00:00
|
|
|
name='map-by-id'),
|
|
|
|
url(r'^maps/$',
|
2017-09-17 19:58:58 +00:00
|
|
|
views.maps,
|
2012-12-13 05:56:10 +00:00
|
|
|
name='maps'),
|
2010-01-10 14:53:57 +00:00
|
|
|
|
2018-11-24 14:02:38 +00:00
|
|
|
url(r'^about/api/$',
|
|
|
|
views.documentation_api,
|
|
|
|
name='documentation_api'),
|
|
|
|
url(r'^about/user-guide/$',
|
|
|
|
views.documentation_user_guide,
|
|
|
|
name='documentation_user_guide'),
|
2012-12-13 05:56:10 +00:00
|
|
|
url(r'^about/$',
|
2017-09-17 19:58:58 +00:00
|
|
|
views.about,
|
2012-12-13 05:56:10 +00:00
|
|
|
name='about'),
|
2018-11-24 14:02:38 +00:00
|
|
|
|
2012-12-13 05:56:10 +00:00
|
|
|
url(r'^donate/$',
|
2017-09-17 19:58:58 +00:00
|
|
|
views.donate,
|
2012-12-13 05:56:10 +00:00
|
|
|
name='donate'),
|
|
|
|
url(r'^donate-thanks/$',
|
2017-09-17 19:58:58 +00:00
|
|
|
views.donate_thanks,
|
2012-12-13 05:56:10 +00:00
|
|
|
name='donate-thanks'),
|
2010-08-06 16:50:20 +00:00
|
|
|
|
2018-05-13 22:13:25 +00:00
|
|
|
# API calls used by the web frontend
|
2018-09-23 20:17:42 +00:00
|
|
|
# url(r'^apis/nominatim/$', views.api_nominatim),
|
|
|
|
url(r'^apis/nominatim/$', views.api_geosearch),
|
2018-08-21 21:02:37 +00:00
|
|
|
url(r'^apis/reversegeo/([^/]*)/([^/]*)/$', views.api_postgis_reverse),
|
2018-04-04 06:55:47 +00:00
|
|
|
url(r'^apis/papersize', views.api_papersize),
|
|
|
|
url(r'^apis/boundingbox/([^/]*)/$', views.api_bbox),
|
2018-05-13 22:13:25 +00:00
|
|
|
url(r'^apis/polygon/([^/]*)/$', views.api_polygon),
|
2018-10-14 13:14:50 +00:00
|
|
|
url(r'^apis/rendering-status/([^/]*)$', views.api_rendering_status),
|
2018-05-13 22:13:25 +00:00
|
|
|
|
|
|
|
# API calls for direct clients
|
2018-09-15 07:51:35 +00:00
|
|
|
|
|
|
|
# unversioned
|
2018-09-10 21:27:56 +00:00
|
|
|
url(r'^apis/paper_formats', apis.paper_formats),
|
|
|
|
url(r'^apis/layouts', apis.layouts),
|
|
|
|
url(r'^apis/styles', apis.styles),
|
|
|
|
url(r'^apis/overlays', apis.overlays),
|
|
|
|
url(r'^apis/job-stati', apis.job_stati),
|
2018-09-16 09:26:49 +00:00
|
|
|
url(r'^apis/jobs$', apis.jobs),
|
2018-09-10 21:27:56 +00:00
|
|
|
url(r'^apis/jobs/(\d*)$', apis.jobs),
|
2018-03-19 08:45:30 +00:00
|
|
|
|
2018-09-15 07:51:35 +00:00
|
|
|
# versioned
|
|
|
|
url(r'^apis/v1/paper_formats', apis.paper_formats),
|
|
|
|
url(r'^apis/v1/layouts', apis.layouts),
|
|
|
|
url(r'^apis/v1/styles', apis.styles),
|
|
|
|
url(r'^apis/v1/overlays', apis.overlays),
|
|
|
|
url(r'^apis/v1/job-stati', apis.job_stati),
|
2018-09-16 09:26:49 +00:00
|
|
|
url(r'^apis/v1/jobs$', apis.jobs),
|
2018-09-15 07:51:35 +00:00
|
|
|
url(r'^apis/v1/jobs/(\d*)$', apis.jobs),
|
|
|
|
|
2012-04-26 21:50:42 +00:00
|
|
|
# Feeds
|
|
|
|
django.VERSION[1] >= 4 and \
|
2018-04-04 06:55:47 +00:00
|
|
|
url(r'^feeds/maps/', feeds.MapsFeed(),
|
|
|
|
name='rss-feed') or \
|
|
|
|
url(r'^feeds/(?P<url>.*)/$',
|
|
|
|
'django.contrib.syndication.views.feed',
|
|
|
|
{'feed_dict': {'maps': feeds.MapsFeed}},
|
|
|
|
name='rss-feed'),
|
2012-04-26 21:50:42 +00:00
|
|
|
|
2010-01-10 14:53:57 +00:00
|
|
|
# Internationalization
|
2018-04-04 06:55:47 +00:00
|
|
|
url(r'^i18n/', include('django.conf.urls.i18n')),
|
|
|
|
]
|
2010-08-06 08:58:24 +00:00
|
|
|
|
|
|
|
if settings.DEBUG:
|
2018-04-04 06:55:47 +00:00
|
|
|
urlpatterns.append(
|
|
|
|
url(r'^results/(?P<path>.*)$', serve,
|
|
|
|
{'document_root': settings.RENDERING_RESULT_PATH}))
|
2010-08-06 08:58:24 +00:00
|
|
|
|
2018-04-04 06:55:47 +00:00
|
|
|
urlpatterns.append(
|
|
|
|
url(r'^media/(?P<path>.*)$', serve,
|
|
|
|
{'document_root': settings.LOCAL_MEDIA_PATH}))
|