From 57693b4170b9e58dd8508d09cb0c82b575381f08 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 2 Jul 2012 18:06:56 +0200 Subject: Fix access to RSS feeds (refs #367) - Improve URLs --- chimere/feeds.py | 8 ++++---- chimere/urls.py | 36 ++++++++++++++++++------------------ chimere/views.py | 2 ++ 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/chimere/feeds.py b/chimere/feeds.py index 4fcef1e..36364ad 100644 --- a/chimere/feeds.py +++ b/chimere/feeds.py @@ -58,7 +58,7 @@ class LatestPOIsByCategory(BaseFeed): title_template = "rss_title.html" description_template = "rss_descr.html" - def get_object(self, request, category_id): + def get_object(self, request, category_id, area_name=''): return get_object_or_404(Category, id=category_id) def title(self, obj): @@ -93,7 +93,7 @@ class LatestPOIsBySubCategory(BaseFeed): title_template = "rss_title.html" description_template = "rss_descr.html" - def get_object(self, request, category_id): + def get_object(self, request, category_id, area_name=''): return get_object_or_404(SubCategory, id=category_id) def title(self, obj): @@ -143,7 +143,7 @@ class LatestPOIsByZone(BaseFeed): lower_right_lat = 0 lower_right_lon = 0 - def get_object(self, request, area): + def get_object(self, request, area, area_name=''): """ Get the extra url. Parameters are the coordinates of the zone (the upper left and lower right points) @@ -201,7 +201,7 @@ class LatestPOIsByZoneID(BaseFeed): title_template = "rss_title.html" description_template = "rss_descr.html" - def get_object(self, request, area_id): + def get_object(self, request, area_id, area_name=''): return get_object_or_404(Area, id=area_id) def title(self, obj): diff --git a/chimere/urls.py b/chimere/urls.py index 5e3b30b..d7596c0 100644 --- a/chimere/urls.py +++ b/chimere/urls.py @@ -37,43 +37,43 @@ urlpatterns = patterns('chimere.views', if settings.CHIMERE_FEEDS: urlpatterns += patterns('', - url(r'^feeds$', 'chimere.views.rss', name='feeds-form'), - url(r'^feeds/category/(?P\d+)$', LatestPOIsByCategory(), + url(r'^(?P\w+/)?feeds$', 'chimere.views.rss', name='feeds-form'), + url(r'^(?P\w+/)?feeds/category/(?P\d+)$', LatestPOIsByCategory(), name='feeds-cat'), - url(r'^feeds/subcategory/(?P\d+)$', + url(r'^(?P\w+/)?feeds/subcategory/(?P\d+)$', LatestPOIsBySubCategory(), name='feeds-subcat'), - url(r'^feeds/global/$', LatestPOIs(), name='feeds-global'), - url(r'^feeds/area/(?P[0-9-_.]+)$', LatestPOIs(), + url(r'^(?P\w+/)?feeds/global/$', LatestPOIs(), name='feeds-global'), + url(r'^(?P\w+/)?feeds/area/(?P[0-9-_.]+)$', LatestPOIs(), name='feeds-area'), - url(r'^feeds/areaid/(?P\d+)$', LatestPOIsByZoneID(), + url(r'^(?P\w+/)?feeds/areaid/(?P\d+)$', LatestPOIsByZoneID(), name='feeds-areaid'), ) urlpatterns += patterns('chimere.views', url(r'^charte/?$', 'charte', name="charte"), - url(r'^(?P\w+)?/?contact/?$', 'contactus', name="contact"), - url(r'^(?P\w+)?/?edit/$', 'edit', + url(r'^(?P\w+/)?contact/?$', 'contactus', name="contact"), + url(r'^(?P\w+/)?edit/$', 'edit', name="edit"), - url(r'^(?P\w+)?/?edit/(?P\w+)/(?P\w+)?$', + url(r'^(?P\w+/)?edit/(?P\w+)/(?P\w+)?$', 'edit', name="edit-item"), - url(r'^(?P\w+)?/?edit-route/$', 'editRoute', + url(r'^(?P\w+/)?edit-route/$', 'editRoute', name="editroute"), - url(r'^(?P\w+)?/?edit-route/(?P\w+)/(?P\w+)?$', + url(r'^(?P\w+/)?edit-route/(?P\w+)/(?P\w+)?$', 'editRoute', name="editroute-item"), - url(r'^(?P\w+)?/?getDetail/(?P\d+)/?$', 'getDetail', + url(r'^(?P\w+/)?getDetail/(?P\d+)/?$', 'getDetail', name="get_detail"), - url(r'^(?P\w+)?/?getDescriptionDetail/?(?P\d+)/?$', + url(r'^(?P\w+/)?getDescriptionDetail/?(?P\d+)/?$', 'getDescriptionDetail', name="get_description_detail"), - url(r'^(?:(?P\w+)?/)?getGeoObjects/'\ + url(r'^(?P\w+/)?getGeoObjects/'\ r'(?P\w+)(/(?P\w+))?$', 'getGeoObjects', name="getgeoobjects"), - url(r'^(?P\w+)?/?getAvailableCategories/$', + url(r'^(?P\w+/)?getAvailableCategories/$', 'get_available_categories', name="get_categories"), - url(r'^(?P\w+)?/?ty/(?P\w+)$', + url(r'^(?P\w+/)?ty/(?P\w+)$', 'redirectFromTinyURN', name="tiny"), - url(r'^(?P\w+)?/?upload_file/((?P\w+)/)?$', + url(r'^(?P\w+/)?upload_file/((?P\w+)/)?$', 'uploadFile', name='upload_file'), - url(r'^(?P\w+)?/?process_route_file/(?P\d+)/$', + url(r'^(?P\w+/)?process_route_file/(?P\d+)/$', 'processRouteFile', name='process_route_file'), # At the end, because it catches large url(r'^(?P\w+)?(/(?P\w+))?', 'index', name="index"), diff --git a/chimere/views.py b/chimere/views.py index 891078e..188a5b7 100644 --- a/chimere/views.py +++ b/chimere/views.py @@ -58,6 +58,8 @@ def get_base_response(area_name=""): base_url = reverse("chimere:index") if not base_url.startswith('/'): base_url = '/' + base_url + if area_name and area_name.endswith('/'): + area_name = area_name[:-1] if area_name: if base_url[-1] != '/': base_url += '/' -- cgit v1.2.3