[19.0][MIG] website_sale_slides_survey_multi_qty: Migration to version 19.0 - #28
Conversation
cristina-hidalgo-tecnativa
left a comment
There was a problem hiding this comment.
Code reviewed and tested locally
| expr="//div[a[contains(@t-att-href, '/survey/%s/get_certification')]]" | ||
| position="attributes" | ||
| > | ||
| <attribute name="t-if">not website.is_public_user()</attribute> |
There was a problem hiding this comment.
| <attribute name="t-if">not website.is_public_user()</attribute> | |
| <attribute name="t-if">survey.certification and not website.is_public_user()</attribute> | |
position="attributes" here replaces the existing t-if="survey.certification" instead of extending it, so the "Download certification" button ends up showing for any passed scored survey, not just certifications. Should be t-if="survey.certification and not website.is_public_user()" to keep the original guard.
| <templates> | ||
| <t | ||
| t-name="website.slides.fullscreen.certification" | ||
| t-inherit="website_slides_survey.website.slides.fullscreen.certification" |
There was a problem hiding this comment.
| t-inherit="website_slides_survey.website.slides.fullscreen.certification" | |
| t-inherit="website.slides.fullscreen.certification" | |
t-inherit references a template name that doesn't exist (website_slides_survey.website.slides.fullscreen.certification) — the base template registers as website.slides.fullscreen.certification (no module prefix). As a result the whole extension silently fails to apply (console: Missing (extension) parent templates: ...), so the d-none never takes effect and the "Download certification" button stays visible.
| def slide_get_certification_url(self, slide_id, **kw): | ||
| slide = request.env["slide.slide"].browse(int(slide_id)) | ||
| res = super().slide_get_certification_url(slide_id=slide_id, **kw) | ||
| if request.env.user._is_public() and not slide.channel_id._has_key_session(): | ||
| return request.redirect("/web/login") | ||
| return res |
There was a problem hiding this comment.
| def slide_get_certification_url(self, slide_id, **kw): | |
| slide = request.env["slide.slide"].browse(int(slide_id)) | |
| res = super().slide_get_certification_url(slide_id=slide_id, **kw) | |
| if request.env.user._is_public() and not slide.channel_id._has_key_session(): | |
| return request.redirect("/web/login") | |
| return res | |
| def slide_get_certification_url(self, slide_id, **kw): | |
| slide = request.env["slide.slide"].sudo().browse(int(slide_id)) | |
| if request.env.user._is_public() and not slide.channel_id._has_key_session(): | |
| return request.redirect("/web/login") | |
| return super().slide_get_certification_url(slide_id=slide_id, **kw) | |
The redirect-to-login check for a public user without a valid key session runs after calling super(), which already fetched the slide, marked it viewed and called _generate_certification_url() (a DB write). Before this PR (auth='user'), an anonymous visitor never reached this code at all; now they do, and the extra un-sudo'd browse() blows up with an AccessError (403) instead of a clean redirect.
Depends on:
@Tecnativa TT64035
@cristina-hidalgo-tecnativa @eduezerouali-tecnativa please review