8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-27 07:02:26 +00:00

Correct customs acl list for extensions

This commit is contained in:
chirac 2020-12-31 19:50:41 +01:00 committed by Gabriel Detraz
parent 89cd0ac856
commit 0d57536638

View file

@ -981,6 +981,32 @@ class Extension(RevMixin, AclMixin, models.Model):
("machines.use_all_extension",), ("machines.use_all_extension",),
) )
@classmethod
def can_list(cls, user_request, *_args, **_kwargs):
"""All users can list unprivileged extensions
Only members of privileged groups can list all.
:param user_request: The user who wants to view the list.
:return: True if the user can view the list and an explanation
message.
"""
can, _message, _group = cls.can_use_all(user_request)
if can:
return (
True,
None,
None,
cls.objects.all()
)
else:
return (
False,
_("You don't have the right to list all extensions."),
("machines.use_all_extension",),
cls.objects.filter(need_infra=False),
)
def __str__(self): def __str__(self):
return self.name return self.name