Commit 0d575366 authored by chirac's avatar chirac Committed by Gabriel Detraz
Browse files

Correct customs acl list for extensions

parent 89cd0ac8
......@@ -981,6 +981,32 @@ class Extension(RevMixin, AclMixin, models.Model):
("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):
return self.name
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment