def osfstorage_add_tag(file_node, **kwargs): data = request.get_json() print data tag = data['tag'] if tag not in file_node.tags and not file_node.node.is_registration: new_tag = Tag.load(tag) if not new_tag: new_tag = Tag(_id=tag) new_tag.save() file_node.tags.append(new_tag) file_node.save() return {'status': 'success'}, httplib.OK return {'status': 'failure'}, httplib.BAD_REQUEST
def osfstorage_remove_tag(file_node, **kwargs): data = request.get_json() tag = data['tag'] tag = Tag.load(tag) if tag and tag in file_node.tags and not file_node.node.is_registration: file_node.tags.remove(tag) file_node.save() return {'status': 'success'}, httplib.OK return {'status': 'failure'}, httplib.BAD_REQUEST
def project_tag(tag, auth, **kwargs): tag_obj = Tag.load(tag) if tag_obj: nodes = Node.find(Q("tags", "eq", tag_obj._id)) else: nodes = [] visible_nodes = [obj for obj in nodes if obj.can_view(auth)] return {"nodes": [{"title": node.title, "url": node.url} for node in visible_nodes], "tag": tag}
def project_tag(tag, auth, **kwargs): tag_obj = Tag.load(tag) nodes = tag_obj.node__tagged if tag_obj else [] visible_nodes = [obj for obj in nodes if obj.can_view(auth)] return { 'nodes': [{ 'title': node.title, 'url': node.url, } for node in visible_nodes], 'tag': tag, }
def project_tag(tag, auth, **kwargs): tag_obj = Tag.load(tag) nodes = tag_obj.node__tagged if tag_obj else [] visible_nodes = [obj for obj in nodes if obj.can_view(auth)] return { 'nodes': [ { 'title': node.title, 'url': node.url, } for node in visible_nodes ], 'tag': tag, }
def project_tag(tag, auth, **kwargs): tag_obj = Tag.load(tag) if tag_obj: nodes = Node.find(Q('tags', 'eq', tag_obj._id)) else: nodes = [] visible_nodes = [obj for obj in nodes if obj.can_view(auth)] return { 'nodes': [{ 'title': node.title, 'url': node.url, } for node in visible_nodes], 'tag': tag, }
def project_tag(tag, auth, **kwargs): tag_obj = Tag.load(tag) if tag_obj: nodes = Node.find(Q('tags', 'eq', tag_obj._id)) else: nodes = [] visible_nodes = [obj for obj in nodes if obj.can_view(auth)] return { 'nodes': [ { 'title': node.title, 'url': node.url, } for node in visible_nodes ], 'tag': tag, }