Skip to content

Commit

Permalink
Merge pull request #5542 from camptocamp/oldapi-redirect
Browse files Browse the repository at this point in the history
Add a redirect from the old URL (pre 2.3)
  • Loading branch information
sbrunner authored Nov 19, 2019
2 parents d872a71 + 28eb57b commit f7b3995
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 4 additions & 1 deletion geoportal/c2cgeoportal_geoportal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,9 @@ def handle(event: InvalidateCacheEvent): # pylint: disable=unused-variable
config.add_route("oldxapijs", "/xapi.js", request_method="GET")
config.add_route("oldapihelp", "/oldapihelp.html", request_method="GET")
config.add_route("oldxapihelp", "/oldxapihelp.html", request_method="GET")
c2cgeoportal_geoportal.views.add_redirect(
config, 'oldapijs_redirect', '/wsgi/api.js', 'apijs'
)

# Cannot be at the header to do not load the model too early
from c2cgeoportal_geoportal.views.entry import Entry
Expand All @@ -510,7 +513,7 @@ def add_api_route(name: str, attr: str, path: str, renderer: str):
add_api_route('apicss', 'apicss', '/api.css', "build/api.css")
add_api_route('apihelp', 'apihelp', '/apihelp/index.html', "api/apihelp/index.html")
c2cgeoportal_geoportal.views.add_redirect(
config, 'apihelp_redirect', '/apihelp.html', '/apihelp/index.html'
config, 'apihelp_redirect', '/apihelp.html', 'apihelp'
)

config.add_route(
Expand Down
3 changes: 1 addition & 2 deletions geoportal/c2cgeoportal_geoportal/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def add_ending_slash(request):

def add_redirect(config, name, from_, to):
def redirect_view(request):
del request # unused
return HTTPFound(location=to)
return HTTPFound(location=request.route_url(to))

config.add_route(name, from_, request_method='GET')
config.add_view(redirect_view, route_name=name)

0 comments on commit f7b3995

Please sign in to comment.