--- a/src/pyams_content/skin/routes.py Fri Jun 22 12:52:10 2018 +0200
+++ b/src/pyams_content/skin/routes.py Fri Jun 22 13:01:30 2018 +0200
@@ -26,7 +26,7 @@
from pyams_catalog.query import CatalogResultSet
from pyams_content.workflow import VISIBLE_STATES
from pyams_utils.registry import get_utility
-from pyams_utils.url import absolute_url
+from pyams_utils.url import absolute_url, canonical_url
from pyramid.exceptions import NotFound
from pyramid.response import Response
from pyramid.view import view_config
@@ -51,12 +51,13 @@
params &= Any(catalog['workflow_state'], VISIBLE_STATES)
results = list(CatalogResultSet(CatalogQuery(catalog).query(params)))
if results:
+ response = Response()
+ response.status_code = 302
if view_name: # back-office access => last version
version = IWorkflowVersions(results[0]).get_last_versions()[0]
+ response.location = absolute_url(version, request, '/'.join(view_name))
else:
version = results[0]
- response = Response()
- response.status_code = 302
- response.location = absolute_url(version, request, '/'.join(view_name))
+ response.location = canonical_url(version, request)
return response
raise NotFound()