Skip to content

Commit

Permalink
[FIX] typo ; [REF] use web.base.url instead of local_redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
legalsylvain committed Apr 25, 2019
1 parent 7665d7f commit 71844a0
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions server_environment/controllers/main.py
Expand Up @@ -3,11 +3,15 @@
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import openerp.http as http
from werkzeug.utils import redirect
from urlparse import urljoin

from openerp.tools.config import config
from openerp import http
from openerp.http import request, Controller


class ServerEnvironmentController(http.Controller):
class ServerEnvironmentController(Controller):

@http.route(
'/server_environment_<module_extension>'
Expand All @@ -16,9 +20,12 @@ class ServerEnvironmentController(http.Controller):
def environment_redirect(self, module_extension, local_path, **kw):
# Note: module_extension is present to make working
# the module in normal configuration, with the folder
# server_environment_files and in demo configuration, withe the
# server_environment_files and in demo configuration, with the
# module  server_environment_files_sample
running_env = config.get('running_env', "default")
return http.local_redirect(
'/server_environment_%s/static/%s/%s' % (
module_extension, running_env, local_path))
IrConfigParameter = request.env['ir.config_parameter']
base_url = IrConfigParameter.get_param('web.base.url', '')
new_path = "/server_environment_%s/static/%s/%s" % (
module_extension, running_env, local_path)
url = urljoin(base_url, new_path)
return redirect(url, 303)

0 comments on commit 71844a0

Please sign in to comment.