Skip to content

Commit

Permalink
[FIX] website_blog: see blog post even if tag doesn't exist anymore
Browse files Browse the repository at this point in the history
If you delete a tag, but still have some link to this one, you arrive on
a 404 /blog/tag/.
We decide to redirect to the blog post without tag instead.
What is probably the expected behaviour for most customers.

closes odoo#97759

X-original-commit: 041ad20
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Jérémy Kersten <jke@odoo.com>
  • Loading branch information
JKE-be committed Aug 12, 2022
1 parent b95473e commit 02409e7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions addons/website_blog/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ def _prepare_blog_values(self, blogs, blog=False, date_begin=False, date_end=Fal
active_tags = BlogTag.browse(active_tag_ids).exists()
fixed_tag_slug = ",".join(slug(t) for t in active_tags)
if fixed_tag_slug != tags:
new_url = request.httprequest.full_path.replace("/tag/%s" % tags, "/tag/%s" % fixed_tag_slug, 1)
if new_url != request.httprequest.full_path: # check that really replaced and avoid loop
path = request.httprequest.full_path
new_url = path.replace("/tag/%s" % tags, fixed_tag_slug and "/tag/%s" % fixed_tag_slug or "", 1)
if new_url != path: # check that really replaced and avoid loop
return request.redirect(new_url, 301)
domain += [('tag_ids', 'in', active_tags.ids)]

Expand Down

0 comments on commit 02409e7

Please sign in to comment.