def check_perms(self, obj, perm_type, resource_hashkey): from app import db from core.database.models import ResourceData authed = False if self.req_user is not None: authed = self.check_user_perms(obj, perm_type) elif self.req_group is not None: authed = self.check_group_perms(obj, perm_type) if not authed and resource_hashkey is not None: context = ExecutionContext(plugin=self.plugin, user=current_user) resource_permissions = ResourcePermissionsManager(context) resource = db.session.query(ResourceData).filter_by(hashkey=resource_hashkey).first() authed = resource_permissions.check_perms(resource, perm_type) return authed
def check_permissions(self, obj, perm_type): context = ExecutionContext(user=current_user) permissions = ResourcePermissionsManager(context) return permissions.check_perms(obj, perm_type)