Purpose is to ensure more advanced use cases are still supported in new elearning platform in addition to more public use cases. Fields controlling access are now * enroll: who can enroll on course: public (everyone, simply click on join button), invite (added by already members) and payment (in bridge with website_sale, if SO with product is confirmed); * enroll_group_ids: automatically add members of those groups to the channel to ease having groups for a given subset of users; * visibility: who can see a channel and its slides: public (everyone, it means channel is visible on website for example), members (hidden for non members) * website_published on channels and slides; non publishers cannot see what is not published, whatever other parameters; * upload_group_ids: who can upload on a channel; * download_security on a slide is completely removed as it makes no sense for most slide types; To ensure a better user experience responsible of a channel is added in its members. People uploading a slide are now also allowed to read it to avoid having inconsistency behavior between upload_group_ids and access rules. Some tests are added. This commit is linked to task ID 1942836 and PR #31239. Co-Authored-By: Aurélien Warnon <awa@odoo.com> Co-Authored-By: Thibault Delavallée <tde@odoo.com>
34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, models
|
|
|
|
|
|
class Users(models.Model):
|
|
_inherit = 'res.users'
|
|
|
|
@api.model
|
|
def create(self, values):
|
|
""" Trigger automatic subscription based on user groups """
|
|
user = super(Users, self).create(values)
|
|
self.env['slide.channel'].sudo().search([('enroll_group_ids', 'in', user.groups_id.ids)])._action_add_members(user.partner_id)
|
|
return user
|
|
|
|
@api.multi
|
|
def write(self, vals):
|
|
""" Trigger automatic subscription based on updated user groups """
|
|
res = super(Users, self).write(vals)
|
|
if vals.get('groups_id'):
|
|
added_group_ids = [command[1] for command in vals['groups_id'] if command[0] == 4]
|
|
added_group_ids += [id for command in vals['groups_id'] if command[0] == 6 for id in command[2]]
|
|
self.env['slide.channel'].sudo().search([('enroll_group_ids', 'in', added_group_ids)])._action_add_members(self.mapped('partner_id'))
|
|
return res
|
|
|
|
def get_gamification_redirection_data(self):
|
|
res = super(Users, self).get_gamification_redirection_data()
|
|
res.append({
|
|
'url': '/slides',
|
|
'label': 'See our eLearning'
|
|
})
|
|
return res
|