From 9bf587a76512c92243f7fddd9905cf5be79fc2ad Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Sat, 19 Apr 2014 12:28:24 +0200 Subject: [PATCH] Use a query string for URL --- fabfile.py | 2 +- umap/settings/base.py | 2 +- umap/urls.py | 2 +- umap/views.py | 6 ++++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/fabfile.py b/fabfile.py index 5be0e740..27936656 100644 --- a/fabfile.py +++ b/fabfile.py @@ -231,7 +231,7 @@ def collect_remote_statics(name=None): 'i18n': 'git://github.com/yohanboniface/Leaflet.i18n.git@master', 'csv2geojson': 'git://github.com/mapbox/csv2geojson.git@gh-pages', 'togeojson': 'git://github.com/mapbox/togeojson.git@gh-pages#v0.4.2', - 'osmtogeojson': 'git://github.com/aaronlidman/osm-and-geojson.git@master', + 'osmtogeojson': 'git://github.com/aaronlidman/osm-and-geojson.git@gh-pages', 'loading': 'git://github.com/ebrelsford/Leaflet.loading.git@master#v0.1.6', 'contextmenu': 'git://github.com/aratcliffe/Leaflet.contextmenu.git@master', 'markercluster': 'git://github.com/Leaflet/Leaflet.markercluster.git@master#0.4', diff --git a/umap/settings/base.py b/umap/settings/base.py index 2a25b430..6347003b 100644 --- a/umap/settings/base.py +++ b/umap/settings/base.py @@ -149,7 +149,7 @@ AUTHENTICATION_BACKENDS += ( LEAFLET_STORAGE_ALLOW_ANONYMOUS = False LEAFLET_STORAGE_EXTRA_URLS = { 'routing': 'http://map.project-osrm.org/?loc={lat},{lng}&hl={locale}', - 'ajax_proxy': '/ajax-proxy/{url}' + 'ajax_proxy': '/ajax-proxy/?url={url}' } SITE_URL = "http://umap.org" UMAP_DEMO_SITE = False diff --git a/umap/urls.py b/umap/urls.py index 3bb27a97..6d9c3c1a 100644 --- a/umap/urls.py +++ b/umap/urls.py @@ -17,7 +17,7 @@ urlpatterns = patterns( (r'^admin/', include(admin.site.urls)), url('', include('social.apps.django_app.urls', namespace='social')), url(r'^m/(?P\d+)/$', MapShortUrl.as_view(), name='umap_short_url'), - url(r'^ajax-proxy/(?P.+)$', cache_page(60)(views.ajax_proxy), name='ajax-proxy'), + url(r'^ajax-proxy/$', cache_page(60)(views.ajax_proxy), name='ajax-proxy'), ) urlpatterns += i18n_patterns( '', diff --git a/umap/views.py b/umap/views.py index ee59e079..5447096f 100644 --- a/umap/views.py +++ b/umap/views.py @@ -9,7 +9,7 @@ from django.db.models import Q from django.contrib.gis.measure import D from django.conf import settings from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger -from django.http import HttpResponse +from django.http import HttpResponse, HttpResponseBadRequest from django.utils.translation import ugettext as _ from django.core.urlresolvers import reverse @@ -181,7 +181,9 @@ class AjaxProxy(View): def get(self, *args, **kwargs): # You should not use this in production (use Nginx or so) - url = kwargs['url'] + url = self.request.GET.get('url') + if not url: + return HttpResponseBadRequest('Missing URL') try: proxied_request = urllib2.urlopen(url) status_code = proxied_request.code