Rewrite the ACL queryset filtering to move most of the computation to the database manager view the ORM. Add support for cascading access control checking. Update the .check_access() method to work as a front end of the new .restrict_queryset method. The workflow for access control now follow Django convention of first generating a queryset and then attempt to .get() the desired element of the queryset. This update also allows restricting a queryset by related fields which can be Generic Foreign Keys. Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
from __future__ import unicode_literals
|
|
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
from mayan.apps.common import MayanAppConfig, menu_object, menu_sidebar
|
|
from mayan.apps.navigation import SourceColumn
|
|
|
|
from .classes import ModelPermission
|
|
from .links import link_acl_create, link_acl_delete, link_acl_permissions
|
|
|
|
|
|
class ACLsApp(MayanAppConfig):
|
|
app_namespace = 'acls'
|
|
app_url = 'acls'
|
|
has_rest_api = True
|
|
has_tests = True
|
|
name = 'mayan.apps.acls'
|
|
verbose_name = _('ACLs')
|
|
|
|
def ready(self):
|
|
super(ACLsApp, self).ready()
|
|
|
|
AccessControlList = self.get_model(model_name='AccessControlList')
|
|
|
|
ModelPermission.register_inheritance(
|
|
model=AccessControlList, related='content_object',
|
|
)
|
|
SourceColumn(
|
|
attribute='role', is_identifier=True, is_sortable=True,
|
|
source=AccessControlList
|
|
)
|
|
SourceColumn(
|
|
attribute='get_permission_titles', include_label=True,
|
|
source=AccessControlList
|
|
)
|
|
|
|
menu_object.bind_links(
|
|
links=(link_acl_permissions, link_acl_delete),
|
|
sources=(AccessControlList,)
|
|
)
|
|
menu_sidebar.bind_links(
|
|
links=(link_acl_create,), sources=('acls:acl_list',)
|
|
)
|