Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] website: language prefixed URL on website #31792

Closed
wants to merge 1 commit into from

Conversation

nle-odoo
Copy link
Contributor

@nle-odoo nle-odoo commented Mar 12, 2019

In 10.0 and before, if we were eg. on website page /fr_FR/contact, if
fr_FR language (french) is installed and not the default website
language we would have all URL towards translated content (route with
multilang=True) prefixed with /fr_FR/ (the language code).

With 9cd982b some improvments were done to CDN but this also breaks
language prefixing, so this cause an unecessary redirect:

  • we are on /fr_FR/contact and click on "Shop"
  • we go to /shop
  • odoo redirects US /fr_FR/shop

With this PR, URLs are prefixed with language once again.

note: the added test is hackish but the function tested depends on a lot
of odoo.http things that are hard to use for test (request.render,
request.context, request.httpreqest).

opw-1922051

@nle-odoo nle-odoo added the OE the report is linked to a support ticket (opw-...) label Mar 12, 2019
@nle-odoo nle-odoo force-pushed the 11.0-website-opw-1922051-nle branch from caa428d to 75b72e8 Compare March 12, 2019 14:25
@nle-odoo nle-odoo force-pushed the 11.0-website-opw-1922051-nle branch from 75b72e8 to bb9100f Compare March 13, 2019 16:27
@robodoo robodoo added the CI 🤖 Robodoo has seen passing statuses label Mar 13, 2019
@nle-odoo nle-odoo force-pushed the 11.0-website-opw-1922051-nle branch from bb9100f to 0abad90 Compare March 22, 2019 11:43
@robodoo robodoo added CI 🤖 Robodoo has seen passing statuses and removed CI 🤖 Robodoo has seen passing statuses labels Mar 22, 2019
@nle-odoo nle-odoo force-pushed the 11.0-website-opw-1922051-nle branch from 0abad90 to 10e1b98 Compare March 22, 2019 12:29
@nle-odoo nle-odoo changed the title [FIX] website: language in url like in 10.0 WIP [FIX] website: language prefixed URL on website Mar 22, 2019
@robodoo robodoo added CI 🤖 Robodoo has seen passing statuses and removed CI 🤖 Robodoo has seen passing statuses labels Mar 22, 2019
@nle-odoo nle-odoo requested a review from KangOl March 22, 2019 13:34
@nle-odoo
Copy link
Contributor Author

Hi @KangOl

Do you think the test is okay for this PR, it is a lot hackish since I test low-level function and in is_multilang_url this is called and so should work for the test:

def is_multilang_url(local_url, langs=None):
        # ...
        router = request.httprequest.app.get_db_router(request.db).bind('')
        # Force to check method to POST. Odoo uses methods : ['POST'] and ['GET', 'POST']
        func = router.match(path, method='POST', query_args=query_string)[0]
        return (func.routing.get('website', False) and
                func.routing.get('multilang', func.routing['type'] == 'http'))

@KangOl
Copy link
Contributor

KangOl commented Mar 22, 2019

I would put the test(s) in its own class, set the initialization in setUp and create differents functions for each different cases (no request, not website, lang in context, monolang routes)

@nle-odoo nle-odoo force-pushed the 11.0-website-opw-1922051-nle branch from 10e1b98 to e67f4fd Compare March 22, 2019 16:13
In 10.0 and before, if we were eg. on website page /fr_FR/contact, if
`fr_FR` language (french) is installed and not the default website
language we would have all URL towards translated content (route with
multilang=True) prefixed with /fr_FR/ (the language code).

With 9cd982b some improvments were done to CDN but this also breaks
language prefixing, so this cause an unecessary redirect:

- we are on /fr_FR/contact and click on "Shop"
- we go to /shop
- odoo redirects US /fr_FR/shop

With this PR, URLs are prefixed with language once again.

note: the added test is hackish but the function tested depends on a lot
of odoo.http things that are hard to use for test (request.render,
request.context, request.httpreqest).

opw-1922051
closes odoo#31792
@nle-odoo nle-odoo force-pushed the 11.0-website-opw-1922051-nle branch from e67f4fd to dcd114e Compare March 22, 2019 16:14
@robodoo robodoo removed the CI 🤖 Robodoo has seen passing statuses label Mar 22, 2019
@nle-odoo
Copy link
Contributor Author

nle-odoo commented Mar 22, 2019

@KangOl ok, it is done

I will merge on monday if there is no other comment

@KangOl
Copy link
Contributor

KangOl commented Mar 22, 2019

Actually, trust robodoo
@robodoo r+

@robodoo robodoo added CI 🤖 Robodoo has seen passing statuses r+ 👌 labels Mar 22, 2019
robodoo pushed a commit that referenced this pull request Mar 22, 2019
In 10.0 and before, if we were eg. on website page /fr_FR/contact, if
`fr_FR` language (french) is installed and not the default website
language we would have all URL towards translated content (route with
multilang=True) prefixed with /fr_FR/ (the language code).

With 9cd982b some improvments were done to CDN but this also breaks
language prefixing, so this cause an unecessary redirect:

- we are on /fr_FR/contact and click on "Shop"
- we go to /shop
- odoo redirects US /fr_FR/shop

With this PR, URLs are prefixed with language once again.

note: the added test is hackish but the function tested depends on a lot
of odoo.http things that are hard to use for test (request.render,
request.context, request.httpreqest).

opw-1922051
closes #31792

Signed-off-by: Christophe Simonis <chs@odoo.com>
nle-odoo added a commit to odoo-dev/odoo that referenced this pull request Mar 22, 2019
With 953a693 when a route is not found we assume it is a website.page
that can be multilang.

But with odoo#31792 we should once again prefix URL by the language if
necessary.

The combination of the two cause issue when an url like `/web#home` is
tested since we do not take `#` into account, we check if the route is
multilang but no route `/web#home` is found => so we get
`/fr_FR/web#home`.

With this fix, `#fragment` is not taken into account when searching
route.

related to odoo#31792
related to opw-1922051
closes odoo#32059
robodoo pushed a commit that referenced this pull request Mar 22, 2019
With 953a693 when a route is not found we assume it is a website.page
that can be multilang.

But with #31792 we should once again prefix URL by the language if
necessary.

The combination of the two cause issue when an url like `/web#home` is
tested since we do not take `#` into account, we check if the route is
multilang but no route `/web#home` is found => so we get
`/fr_FR/web#home`.

With this fix, `#fragment` is not taken into account when searching
route.

related to #31792
related to opw-1922051
closes #32059

Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
@robodoo
Copy link
Contributor

robodoo commented Mar 22, 2019

Merged, thanks!

@robodoo robodoo closed this Mar 22, 2019
@nle-odoo nle-odoo deleted the 11.0-website-opw-1922051-nle branch March 25, 2019 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI 🤖 Robodoo has seen passing statuses OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants