Exemplo n.º 1
0
        def require_obj_permissions_wrapper(obj, *args, **kw):
            """
            Wrapper for the called method that checks the permissions before
            calling the method.
            """
            # check if the permittee exists in the request
            permittee = get_permittee_from_threadlocals(self.permittee_kw)

            missing = ExpedientPermission.objects.get_missing_for_target(
                permittee, self.perm_names, obj)

            if missing:
                raise exceptions.PermissionDenied(missing.name, obj, permittee)
            
            # All is good. Call the function
            return f(obj, *args, **kw)
Exemplo n.º 2
0
    def stop_slice(self, slice):
        """Take out the resource reservation from the aggregates.

        Subclasses overriding this method should call the parent class
        to ensure permission checks.
        """
        user = get_permittee_from_threadlocals("user")
        can_use = has_permission(user, self.as_leaf_class(),
                                 "can_use_aggregate")
        can_edit = has_permission(user, self.as_leaf_class(),
                                  "can_edit_aggregate")
        if not can_use and not can_edit:
            raise PermissionDenied("can_use_aggregate",
                                   self.as_leaf_class(),
                                   user,
                                   allow_redirect=False)
        pass
Exemplo n.º 3
0
    def stop_slice(self, slice):
        """Take out the resource reservation from the aggregates.

        Subclasses overriding this method should call the parent class
        to ensure permission checks.
        """
        user = get_permittee_from_threadlocals("user")
        can_use = has_permission(
            user, self.as_leaf_class(), "can_use_aggregate")
        can_edit = has_permission(
            user, self.as_leaf_class(), "can_edit_aggregate")
        if not can_use and not can_edit:
            raise PermissionDenied(
                "can_use_aggregate",
                self.as_leaf_class(),
                user, allow_redirect=False)
        pass