X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FAddNodeTag.py;h=089dcfa6dfdaf38f3e41686a8314052adab7e0a4;hb=b5780972105512f088c235b1538e6cbbb1ee1ae4;hp=fc64d1e5a29bcce140593aa62b288cfded767666;hpb=02fbeb3d8ae6da8ed1ce4c83ec64fa174906c5f7;p=plcapi.git diff --git a/PLC/Methods/AddNodeTag.py b/PLC/Methods/AddNodeTag.py index fc64d1e..089dcfa 100644 --- a/PLC/Methods/AddNodeTag.py +++ b/PLC/Methods/AddNodeTag.py @@ -11,6 +11,7 @@ from PLC.Nodes import Node, Nodes from PLC.TagTypes import TagType, TagTypes from PLC.NodeTags import NodeTag, NodeTags +# need to import so the core classes get decorated with caller_may_write_tag from PLC.AuthorizeHelpers import AuthorizeHelpers class AddNodeTag(Method): @@ -43,12 +44,12 @@ class AddNodeTag(Method): def call(self, auth, node_id, tag_type_id_or_name, value): nodes = Nodes(self.api, [node_id]) if not nodes: - raise PLCInvalidArgument, "No such node %r"%node_id + raise PLCInvalidArgument("No such node %r"%node_id) node = nodes[0] tag_types = TagTypes(self.api, [tag_type_id_or_name]) if not tag_types: - raise PLCInvalidArgument, "No such node tag type %r"%tag_type_id_or_name + raise PLCInvalidArgument("No such node tag type %r"%tag_type_id_or_name) tag_type = tag_types[0] # checks for existence - does not allow several different tags @@ -57,20 +58,11 @@ class AddNodeTag(Method): 'tag_type_id':tag_type['tag_type_id']}) if len(conflicts) : - raise PLCInvalidArgument, "Node %d already has tag %d"%(node['node_id'], - tag_type['tag_type_id']) - + raise PLCInvalidArgument("Node %d already has tag %d"%(node['node_id'], + tag_type['tag_type_id'])) # check authorizations - if 'admin' in self.caller['roles']: - pass - elif not AuthorizeHelpers.caller_may_access_tag_type (self.api, self.caller, tag_type): - raise PLCPermissionDenied, "%s, forbidden tag %s"%(self.name,tag_type['tagname']) - elif AuthorizeHelpers.node_belongs_to_person (self.api, node, self.caller): - pass - else: - raise PLCPermissionDenied, "%s: you must belong in the same site as subject node"%self.name - + node.caller_may_write_tag(self.api,self.caller,tag_type) node_tag = NodeTag(self.api) node_tag['node_id'] = node['node_id']