[FIX] website_slides: propose to signup instead of login
When joining a course of liking a slide if the user is not logged there is a popover asking him to login. If auth signup allows user creation link instead redirects to signup instead of login to save a click and improve onboarding. closes odoo/odoo#33755 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
@@ -460,7 +460,7 @@ class WebsiteSlides(WebsiteProfile):
|
||||
@http.route(['/slides/channel/join'], type='json', auth='public', website=True)
|
||||
def slide_channel_join(self, channel_id):
|
||||
if request.website.is_public_user():
|
||||
return {'error': 'public_user'}
|
||||
return {'error': 'public_user', 'error_signup_allowed': request.env['res.users'].sudo()._get_signup_invitation_scope() == 'b2c'}
|
||||
success = request.env['slide.channel'].browse(channel_id).action_add_member()
|
||||
if not success:
|
||||
return {'error': 'join_done'}
|
||||
@@ -586,7 +586,7 @@ class WebsiteSlides(WebsiteProfile):
|
||||
@http.route('/slides/slide/like', type='json', auth="public", website=True)
|
||||
def slide_like(self, slide_id, upvote):
|
||||
if request.website.is_public_user():
|
||||
return {'error': 'public_user'}
|
||||
return {'error': 'public_user', 'error_signup_allowed': request.env['res.users'].sudo()._get_signup_invitation_scope() == 'b2c'}
|
||||
slide_partners = request.env['slide.slide.partner'].sudo().search([
|
||||
('slide_id', '=', slide_id),
|
||||
('partner_id', '=', request.env.user.partner_id.id)
|
||||
|
||||
@@ -54,7 +54,12 @@ var CourseJoinWidget = Widget.extend({
|
||||
location.reload();
|
||||
} else {
|
||||
if (data.error === 'public_user') {
|
||||
self._popoverAlert(self.$el, _.str.sprintf(_t('Please <a href="/web/login?redirect=%s">login</a> to join this course.'), (document.URL)));
|
||||
var message = _t('Please <a href="/web/login?redirect=%s">login</a> to join this course');
|
||||
var signupAllowed = data.error_signup_allowed || false;
|
||||
if (signupAllowed) {
|
||||
message = _t('Please <a href="/web/signup?redirect=%s">create an account</a> to join this course');
|
||||
}
|
||||
self._popoverAlert(self.$el, _.str.sprintf(message, (document.URL)));
|
||||
} else if (data.error === 'join_done') {
|
||||
self._popoverAlert(self.$el, _t('You have already joined this channel'));
|
||||
} else {
|
||||
|
||||
@@ -56,7 +56,12 @@ var SlideLikeWidget = Widget.extend({
|
||||
self.$el.find('span.o_wslides_js_slide_like_down span').text(data.dislikes);
|
||||
} else {
|
||||
if (data.error === 'public_user') {
|
||||
self._popoverAlert(self.$el, _.str.sprintf(_t('Please <a href="/web/login?redirect=%s">login</a> to vote this lesson'), (document.URL)));
|
||||
var message = _t('Please <a href="/web/login?redirect=%s">login</a> to vote this lesson');
|
||||
var signupAllowed = data.error_signup_allowed || false;
|
||||
if (signupAllowed) {
|
||||
message = _t('Please <a href="/web/signup?redirect=%s">create an account</a> to vote this lesson');
|
||||
}
|
||||
self._popoverAlert(self.$el, _.str.sprintf(message, (document.URL)));
|
||||
} else if (data.error === 'vote_done') {
|
||||
self._popoverAlert(self.$el, _t('You have already voted for this lesson'));
|
||||
} else if (data.error === 'slide_access') {
|
||||
|
||||
Reference in New Issue
Block a user