Skip to content

Commit

Permalink
[FIX] website: Fix some pages URLs
Browse files Browse the repository at this point in the history
Links starting with `/page/website.` will no longer work. Remove the `website.` prefix.

Also `/page/homepage` and `/page/contactus` have changed their controllers, so I added some 301 redirections to handle those cases.
  • Loading branch information
yajo authored and OCA-git-bot committed Aug 18, 2019
1 parent e2f463f commit 19c0c5e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions addons/website/migrations/11.0.1.0/post-migration.py
Expand Up @@ -51,6 +51,20 @@ def link_websites_with_pages(env):
)


def add_redirections(env):
"""Redirect controllers that have been moved."""
redirections = (
("/page/contactus", "/contactus"),
("/page/homepage", "/"),
)
for from_, to in redirections:
env["website.redirect"].create({
"type": "301",
"url_from": from_,
"url_to": to,
})


def add_website_homepages(env):
# Add homepage for websites
openupgrade.logged_query(
Expand All @@ -68,6 +82,16 @@ def add_website_homepages(env):
)


def update_menu_urls(env):
"""Update some menu URLs that must change."""
# Fix menus that include the "website." prefix
menus = env["website.menu"].search([
("url", "=like", "/page/website.%"),
])
for menu in menus:
menu.url = menu.url.replace("website.", "", 1)


def delete_noupdate_records(env):
"""Clean data for website.menu_website deleted from noupdate data."""
env.ref('website.menu_website').unlink()
Expand Down Expand Up @@ -127,10 +151,12 @@ def update_social_media(env):
def migrate(env, version):
fill_website_pages(env)
link_websites_with_pages(env)
add_redirections(env)
add_website_homepages(env)
delete_noupdate_records(env)
update_social_media(env)
import_website_seo_redirection_data(env)
update_menu_urls(env)
openupgrade.load_data(
env.cr, 'website', 'migrations/11.0.1.0/noupdate_changes.xml',
)

0 comments on commit 19c0c5e

Please sign in to comment.