"""Compute the read access of the forums' posts for the current user."""
if self.env.user._is_admin():
self.can_access = True
return
if self.env.user.has_group('base.group_public'):
public_forum = self.filtered(lambda f: f.privacy == 'public')
public_forum.can_access = True
(self - public_forum).can_access = False
return
accessible = self.filtered(lambda f: (
f.privacy in {'public', 'connected'}
or (
f.privacy == 'private'
and f.authorized_group_id in self.env.user.all_group_ids
)
))
accessible.can_access = True
(self - accessible).can_access = False
|