def nodeadmin_required(user, errormsg, *nodeids):
    if user.is_superuser:
        return
    for nodeid in nodeids:
        if nodeid == None:
            raise NodeAdminRequiredError(errormsg)
        if Node.where_is_admin(user).filter(id=nodeid).count() == 0:
            raise NodeAdminRequiredError(errormsg)
Ejemplo n.º 2
0
 def create(self, user, short_name, long_name, parentnode_id=None):
     nodeadmin_required(user, "Must be admin on the parentnode to create a Node.", parentnode_id)
     node = Node(short_name=short_name, long_name=long_name, parentnode_id=parentnode_id)
     node.save()
     return self._todict(node)