示例#1
0
 def has_object_permission(self, request, view, obj):
     node_link = NodeRelation.load(request.parser_context['kwargs']['node_link_id'])
     node = AbstractNode.load(request.parser_context['kwargs'][view.node_lookup_url_kwarg])
     auth = get_user_auth(request)
     if request.method == 'DELETE'and node.is_registration:
         raise exceptions.MethodNotAllowed(method=request.method)
     if node.is_collection or node.is_registration:
         raise exceptions.NotFound
     if node != node_link.parent:
         raise exceptions.NotFound
     if request.method == 'DELETE' and not node.can_edit(auth):
         return False
     return True
示例#2
0
 def has_object_permission(self, request, view, obj):
     node_link = NodeRelation.load(request.parser_context['kwargs']['node_link_id'])
     node = AbstractNode.load(request.parser_context['kwargs'][view.node_lookup_url_kwarg])
     auth = get_user_auth(request)
     if request.method == 'DELETE'and node.is_registration:
         raise exceptions.MethodNotAllowed(method=request.method)
     if node.is_collection or node.is_registration:
         raise exceptions.NotFound
     if node != node_link.parent:
         raise exceptions.NotFound
     if request.method == 'DELETE' and not node.can_edit(auth):
         return False
     return True
示例#3
0
 def has_object_permission(self, request, view, obj):
     assert isinstance(obj, (AbstractNode, NodeRelation)), 'obj must be an Node or NodeRelation, got {}'.format(obj)
     auth = get_user_auth(request)
     parent_node = AbstractNode.load(request.parser_context['kwargs']['node_id'])
     pointer_node = NodeRelation.load(request.parser_context['kwargs']['node_link_id']).child
     if request.method in permissions.SAFE_METHODS:
         has_parent_auth = parent_node.can_view(auth)
         has_pointer_auth = pointer_node.can_view(auth)
         public = pointer_node.is_public
         has_auth = public or (has_parent_auth and has_pointer_auth)
         return has_auth
     else:
         has_auth = parent_node.can_edit(auth)
         return has_auth
示例#4
0
 def has_object_permission(self, request, view, obj):
     assert isinstance(obj, (AbstractNode, NodeRelation)), 'obj must be an Node or NodeRelation, got {}'.format(obj)
     auth = get_user_auth(request)
     parent_node = AbstractNode.load(request.parser_context['kwargs']['node_id'])
     pointer_node = NodeRelation.load(request.parser_context['kwargs']['node_link_id']).child
     if request.method in permissions.SAFE_METHODS:
         has_parent_auth = parent_node.can_view(auth)
         has_pointer_auth = pointer_node.can_view(auth)
         public = pointer_node.is_public
         has_auth = public or (has_parent_auth and has_pointer_auth)
         return has_auth
     else:
         has_auth = parent_node.can_edit(auth)
         return has_auth
示例#5
0
 def has_object_permission(self, request, view, obj):
     assert_resource_type(obj, self.acceptable_models)
     auth = get_user_auth(request)
     parent_node = AbstractNode.load(request.parser_context['kwargs']['node_id'])
     pointer_node = NodeRelation.load(request.parser_context['kwargs']['node_link_id']).child
     if request.method in permissions.SAFE_METHODS:
         has_parent_auth = parent_node.can_view(auth)
         has_pointer_auth = pointer_node.can_view(auth)
         public = pointer_node.is_public
         has_auth = public or (has_parent_auth and has_pointer_auth)
         return has_auth
     else:
         has_auth = parent_node.can_edit(auth)
         return has_auth