diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2012-07-02 18:06:56 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2012-07-02 18:06:56 +0200 |
commit | 57693b4170b9e58dd8508d09cb0c82b575381f08 (patch) | |
tree | ab61d710d58745e04de39f68cdc296428739086a | |
parent | 677cd9b02e50de2a43d30130f40b60d93e5c2f2a (diff) | |
download | Chimère-57693b4170b9e58dd8508d09cb0c82b575381f08.tar.bz2 Chimère-57693b4170b9e58dd8508d09cb0c82b575381f08.zip |
Fix access to RSS feeds (refs #367) - Improve URLs
-rw-r--r-- | chimere/feeds.py | 8 | ||||
-rw-r--r-- | chimere/urls.py | 36 | ||||
-rw-r--r-- | 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<category_id>\d+)$', LatestPOIsByCategory(), + url(r'^(?P<area_name>\w+/)?feeds$', 'chimere.views.rss', name='feeds-form'), + url(r'^(?P<area_name>\w+/)?feeds/category/(?P<category_id>\d+)$', LatestPOIsByCategory(), name='feeds-cat'), - url(r'^feeds/subcategory/(?P<category_id>\d+)$', + url(r'^(?P<area_name>\w+/)?feeds/subcategory/(?P<category_id>\d+)$', LatestPOIsBySubCategory(), name='feeds-subcat'), - url(r'^feeds/global/$', LatestPOIs(), name='feeds-global'), - url(r'^feeds/area/(?P<area>[0-9-_.]+)$', LatestPOIs(), + url(r'^(?P<area_name>\w+/)?feeds/global/$', LatestPOIs(), name='feeds-global'), + url(r'^(?P<area_name>\w+/)?feeds/area/(?P<area>[0-9-_.]+)$', LatestPOIs(), name='feeds-area'), - url(r'^feeds/areaid/(?P<area_id>\d+)$', LatestPOIsByZoneID(), + url(r'^(?P<area_name>\w+/)?feeds/areaid/(?P<area_id>\d+)$', LatestPOIsByZoneID(), name='feeds-areaid'), ) urlpatterns += patterns('chimere.views', url(r'^charte/?$', 'charte', name="charte"), - url(r'^(?P<area_name>\w+)?/?contact/?$', 'contactus', name="contact"), - url(r'^(?P<area_name>\w+)?/?edit/$', 'edit', + url(r'^(?P<area_name>\w+/)?contact/?$', 'contactus', name="contact"), + url(r'^(?P<area_name>\w+/)?edit/$', 'edit', name="edit"), - url(r'^(?P<area_name>\w+)?/?edit/(?P<item_id>\w+)/(?P<submited>\w+)?$', + url(r'^(?P<area_name>\w+/)?edit/(?P<item_id>\w+)/(?P<submited>\w+)?$', 'edit', name="edit-item"), - url(r'^(?P<area_name>\w+)?/?edit-route/$', 'editRoute', + url(r'^(?P<area_name>\w+/)?edit-route/$', 'editRoute', name="editroute"), - url(r'^(?P<area_name>\w+)?/?edit-route/(?P<item_id>\w+)/(?P<submited>\w+)?$', + url(r'^(?P<area_name>\w+/)?edit-route/(?P<item_id>\w+)/(?P<submited>\w+)?$', 'editRoute', name="editroute-item"), - url(r'^(?P<area_name>\w+)?/?getDetail/(?P<marker_id>\d+)/?$', 'getDetail', + url(r'^(?P<area_name>\w+/)?getDetail/(?P<marker_id>\d+)/?$', 'getDetail', name="get_detail"), - url(r'^(?P<area_name>\w+)?/?getDescriptionDetail/?(?P<category_id>\d+)/?$', + url(r'^(?P<area_name>\w+/)?getDescriptionDetail/?(?P<category_id>\d+)/?$', 'getDescriptionDetail', name="get_description_detail"), - url(r'^(?:(?P<area_name>\w+)?/)?getGeoObjects/'\ + url(r'^(?P<area_name>\w+/)?getGeoObjects/'\ r'(?P<category_ids>\w+)(/(?P<status>\w+))?$', 'getGeoObjects', name="getgeoobjects"), - url(r'^(?P<area_name>\w+)?/?getAvailableCategories/$', + url(r'^(?P<area_name>\w+/)?getAvailableCategories/$', 'get_available_categories', name="get_categories"), - url(r'^(?P<area_name>\w+)?/?ty/(?P<tiny_urn>\w+)$', + url(r'^(?P<area_name>\w+/)?ty/(?P<tiny_urn>\w+)$', 'redirectFromTinyURN', name="tiny"), - url(r'^(?P<area_name>\w+)?/?upload_file/((?P<category_id>\w+)/)?$', + url(r'^(?P<area_name>\w+/)?upload_file/((?P<category_id>\w+)/)?$', 'uploadFile', name='upload_file'), - url(r'^(?P<area_name>\w+)?/?process_route_file/(?P<file_id>\d+)/$', + url(r'^(?P<area_name>\w+/)?process_route_file/(?P<file_id>\d+)/$', 'processRouteFile', name='process_route_file'), # At the end, because it catches large url(r'^(?P<area_name>\w+)?(/(?P<zoomout>\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 += '/' |