[FIX] website_slides: remove old code + fix xml and key error tb

Before this commit, the aria-current was the name of the search_X
instead of value 'page'.
Code was strange since `'page' and X`  == `X`, while we expect 'page' as
value.

In case of unknown 'search_slide_category' value, use '-' instead to
raise a KeyError Exception.
We still have some links that point to old url with slide category of
type 'presentation' that doesn't exist anymore since the v16.

Remove outdate code following the comment:
 > I swear though, don't be afraid, remove it!

From this way, the wrong slide_type of type 'presentation' will be
ignored in all case and link from google will show the slide instead
of an error 500.

closes odoo/odoo#158002

Signed-off-by: Jérémy Kersten <jke@odoo.com>
This commit is contained in:
Jeremy Kersten
2024-03-19 14:00:58 +00:00
parent fc3e1b2df5
commit 3932c46f91
2 changed files with 15 additions and 19 deletions
@@ -562,10 +562,6 @@ class WebsiteSlides(WebsiteProfile):
if category_id and not category:
category = channel.slide_category_ids.filtered(lambda category: category.id == category_id)
# retro-compatibility for older links, 'slide_category' field was previously named 'slide_type'
# can be safely removed after 15.3 (I swear though, don't be afraid, remove it!)
slide_category = slide_category or kw.get('slide_type')
domain = self._get_channel_slides_base_domain(channel)
pager_url = "/slides/%s" % (channel.id)
pager_args = valid_invite_values.get('pager_args', {})
@@ -17,19 +17,19 @@
<a t-if="invite_preview" t-attf-href="/slides/#{channel.id}?#{keep_query('invite_hash', 'invite_partner_id')}" class="text-truncate d-block"><span t-esc="channel.name"/></a>
<a t-else="" t-att-href="'/slides/%s' % slug(channel)" class="text-truncate d-block"><span t-esc="channel.name"/></a>
</li>
<li t-att-class="breadcrumb_class" t-att-aria-current="'page' and search_category" t-if="search_category">
<a t-if="invite_preview" t-attf-href="/slides/#{channel.id}/category/#{search_category.id}?#{keep_query('invite_hash', 'invite_partner_id')}"><span t-esc="search_category.name"/></a>
<a t-else="" t-attf-href="/slides/#{slug(channel)}/category/#{slug(search_category)}"><span t-esc="search_category.name"/></a>
<li t-att-class="breadcrumb_class" t-if="search_category">
<a t-if="invite_preview" t-attf-href="/slides/#{channel.id}/category/#{search_category.id}?#{keep_query('invite_hash', 'invite_partner_id')}" aria-current='page'><span t-esc="search_category.name"/></a>
<a t-else="" t-attf-href="/slides/#{slug(channel)}/category/#{slug(search_category)}" aria-current='page'><span t-esc="search_category.name"/></a>
</li>
<li t-att-class="breadcrumb_class" t-att-aria-current="'page' and search_tag" t-if="search_tag">
<a t-att-href="'/slides/%s/tag/%s' % (slug(channel), slug(search_tag))"><span t-esc="search_tag.name"/></a>
<li t-att-class="breadcrumb_class" t-if="search_tag">
<a t-att-href="'/slides/%s/tag/%s' % (slug(channel), slug(search_tag))" aria-current='page'><span t-esc="search_tag.name"/></a>
</li>
<li t-att-class="breadcrumb_class" t-att-aria-current="'page' and search_uncategorized" t-if="search_uncategorized">
<a t-if="invite_preview" t-attf-href="/slides/#{channel.id}?uncategorized=1&amp;#{keep_query('invite_hash', 'invite_partner_id')}">Uncategorized</a>
<a t-else="" t-attf-href="/slides/#{slug(channel)}?uncategorized=1">Uncategorized</a>
<li t-att-class="breadcrumb_class" t-if="search_uncategorized">
<a t-if="invite_preview" t-attf-href="/slides/#{channel.id}?uncategorized=1&amp;#{keep_query('invite_hash', 'invite_partner_id')}" aria-current='page'>Uncategorized</a>
<a t-else="" t-attf-href="/slides/#{slug(channel)}?uncategorized=1" aria-current='page'>Uncategorized</a>
</li>
<li t-att-class="breadcrumb_class" t-att-aria-current="'page' and search_slide_category" t-if="search_slide_category">
<a t-att-href="'/slides/%s?slide_category=%s' % (slug(channel), search_slide_category)"><span t-esc="slide_categories[search_slide_category]"/></a>
<li t-att-class="breadcrumb_class" t-if="search_slide_category">
<a t-att-href="'/slides/%s?slide_category=%s' % (slug(channel), search_slide_category)" aria-current='page'><span t-esc="slide_categories.get('search_slide_category', '-')"/></a>
</li>
<li t-if="slide" class="breadcrumb-item fw-bold">
<a t-att-href="'/slides/slide/%s' % slug(slide)"><span t-esc="slide.name"/></a>
@@ -65,19 +65,19 @@
t-attf-href="/slides/#{channel.id if invite_preview else slug(channel)}?#{keep_query('invite_hash', 'invite_partner_id') if invite_preview else ''}">
&#9492;<span class="ms-1" t-esc="channel.name"/>
</a>
<a t-att-class="dropdown_class" t-att-aria-current="'page' and search_category" t-if="search_category"
<a t-att-class="dropdown_class" aria-current="page" t-if="search_category"
t-attf-href="/slides/#{channel.id if invite_preview else slug(channel)}/category/#{search_category.id if invite_preview else slug(search_category)}?#{keep_query('invite_hash', 'invite_partner_id') if invite_preview else ''}">
&#9492;<span class="ms-1" t-esc="search_category.name"/>
</a>
<a t-att-class="dropdown_class" t-att-aria-current="'page' and search_tag" t-if="search_tag" t-att-href="'/slides/%s/tag/%s' % (slug(channel), slug(search_tag))">
<a t-att-class="dropdown_class" aria-current="page" t-if="search_tag" t-att-href="'/slides/%s/tag/%s' % (slug(channel), slug(search_tag))">
&#9492;<span class="ms-1" t-esc="search_tag.name"/>
</a>
<a t-att-class="dropdown_class" t-att-aria-current="'page' and search_uncategorized" t-if="search_uncategorized"
<a t-att-class="dropdown_class" aria-current="page" t-if="search_uncategorized"
t-attf-href="/slides/#{channel.id if invite_preview else slug(channel)}?uncategorized=1&amp;#{keep_query('invite_hash', 'invite_partner_id') if invite_preview else ''}">
&#9492;<span class="ms-1">Uncategorized</span>
</a>
<a t-att-class="dropdown_class" t-att-aria-current="'page' and search_slide_category" t-if="search_slide_category" t-att-href="'/slides/%s?slide_category=%s' % (slug(channel), search_slide_category)">
&#9492;<span class="ms-1" t-esc="slide_categories[search_slide_category]"/>
<a t-att-class="dropdown_class" aria-current="page" t-if="search_slide_category" t-att-href="'/slides/%s?slide_category=%s' % (slug(channel), search_slide_category)">
&#9492;<span class="ms-1" t-esc="slide_categories.get('search_slide_category', '-')"/>
</a>
<a t-if="slide" class="dropdown-item active" t-att-href="'/slides/slide/%s' % (slug(slide))">
&#9492;<span class="ms-1" t-esc="slide.name"/>