[IMP] website_sale_slides: ensure login after purchase

Purpose
=======
If we buy a course without being logged in, we are redirected to a page
with a button "Start Learning". That button redirects to the course we
just purchased. Instead, we want to redirect the users to the login page,
and after that to the course page.

Task-3544591

closes odoo/odoo#143899

X-original-commit: cbe570e107e9a27e43d35f40071323f5443c1999
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
Signed-off-by: Stéphane Debauche (std) <std@odoo.com>
This commit is contained in:
std-odoo
2023-12-06 11:22:04 +00:00
parent 1be6866b15
commit b046f21b59
3 changed files with 25 additions and 2 deletions
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import sale
from . import slides
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.http import request
from odoo.addons.website_sale.controllers.main import WebsiteSale
class WebsiteSaleSlides(WebsiteSale):
def _prepare_shop_payment_confirmation_values(self, order):
values = super()._prepare_shop_payment_confirmation_values(order)
if order.order_line.product_id.channel_ids:
channel_partners = request.env['slide.channel.partner'].sudo().search([
('partner_id', '=', order.partner_id.id),
('channel_id', 'in', order.order_line.product_id.channel_ids.ids),
])
values['course_memberships'] = {
channel_partner.channel_id: channel_partner
for channel_partner in channel_partners
}
return values
@@ -21,8 +21,9 @@
<span t-if="course.image_1920" t-field="course.image_1920" t-options="{'widget': 'image', 'class': 'my-2'}"/>
<img t-else="" class="img img-fluid my-2" src="/website_slides/static/src/img/channel-training-default.jpg"/>
</div>
<t t-set="invitation_link" t-value="course_memberships[course].invitation_link"/>
<div class="col-7">
<a t-attf-href="/slides/#{slug(course)}"><h3 t-out="course.name" class="m-2"/></a>
<a t-att-href="invitation_link"><h3 t-out="course.name" class="m-2"/></a>
<div t-out="course.description_short" class="fw-light o_wslides_desc_truncate_2 ms-2"/>
<div class="fw-light ms-2 mt-2">
<t t-out="course.total_time" t-options="{'widget': 'duration', 'unit': 'hour', 'round': 'minute'}"/>
@@ -30,7 +31,7 @@
<t t-if="course.total_time"> - </t><t t-out="course.total_slides"/> step(s)
</t>
</div>
<a role="button" class="btn btn-primary ms-2 my-2" t-attf-href="/slides/#{slug(course)}">
<a role="button" class="btn btn-primary ms-2 my-2" t-att-href="invitation_link">
Start Learning
</a>
</div>