def test_node_icon(self): model = BaseNode() model.properties.icon = 'my-icon' self.assertEqual(node_icon(model), 'my-icon') @node_info(name='mynode') class MyNode(BaseNode): pass model = MyNode() self.assertEqual(node_icon(model), 'glyphicon glyphicon-asterisk') @node_info(name='othernode', icon='other-icon') class OtherNode(BaseNode): pass model = OtherNode() self.assertEqual(node_icon(model), 'other-icon')
def fillchildren(self, model, path, tree): """XXX: consider cone.app.interfaces.INavigationLeaf """ curpath = None if path: curpath = path[0] default_child = None if model.properties.default_child: if not curpath or curpath == model.properties.default_child: default_child = model[model.properties.default_child] if default_child and default_child.properties.hide_if_default: model = default_child default_child = None if path: path = path[1:] if path: curpath = path[0] if default_child: if not curpath: curpath = model.properties.default_child for key in model: node = model[key] if not self.request.has_permission('view', node): continue if not node.properties.get('in_navtree'): continue title = node.metadata.title if title: title = safe_decode(title) url = make_url(self.request, node=node) query = make_query( contenttile=node.properties.default_content_tile) target = make_url(self.request, node=node, query=query) curnode = curpath == safe_decode(key) icon = node_icon(node) css = '' if IWorkflowState.providedBy(node): css = 'state-%s' % node.state child = self.navtreeitem(title, url, target, node_path(node), icon, css) child['showchildren'] = curnode if curnode: child['selected'] = True if default_child: self.fillchildren(default_child, path[1:], child) else: self.fillchildren(node, path[1:], child) else: selected_path = node_path(self.model) if default_child: selected_path.append(default_child.name) selected = False # XXX: probably superfluous. keep as of cone.app 1.1 # if selected_path == node_path(node): # selected = True child['selected'] = selected tree['children'].append(child)
def fillchildren(self, model, path, tree): """XXX: consider cone.app.interfaces.INavigationLeaf """ curpath = None if path: curpath = path[0] default_child = None if model.properties.default_child: if not curpath or curpath == model.properties.default_child: default_child = model[model.properties.default_child] if default_child and default_child.properties.hide_if_default: model = default_child default_child = None if path: path = path[1:] if path: curpath = path[0] if default_child: if not curpath: curpath = model.properties.default_child for key in model: node = model[key] if not self.request.has_permission('view', node): continue if not node.properties.get('in_navtree'): continue title = node.metadata.title if title: title = safe_decode(title) url = make_url(self.request, node=node) query = make_query(contenttile=node.properties.default_content_tile) target = make_url(self.request, node=node, query=query) curnode = curpath == safe_decode(key) icon = node_icon(node) css = '' if IWorkflowState.providedBy(node): css = 'state-%s' % node.state child = self.navtreeitem( title, url, target, node_path(node), icon, css) child['showchildren'] = curnode if curnode: child['selected'] = True if default_child: self.fillchildren(default_child, path[1:], child) else: self.fillchildren(node, path[1:], child) else: selected_path = node_path(self.model) if default_child: selected_path.append(default_child.name) selected = False # XXX: probably superfluous. keep as of cone.app 1.1 # if selected_path == node_path(node): # selected = True child['selected'] = selected tree['children'].append(child)
def fillchildren(self, model, path, tree): """XXX: consider cone.app.interfaces.INavigationLeaf """ curpath = None if path: curpath = path[0] default_child = None if model.properties.default_child: if not curpath or curpath == model.properties.default_child: default_child = model[model.properties.default_child] if default_child and default_child.properties.hide_if_default: model = default_child default_child = None if path: path = path[1:] if path: curpath = path[0] if default_child: if not curpath: curpath = model.properties.default_child for key in model: node = model[key] if not has_permission("view", node, self.request): continue if not node.properties.get("in_navtree"): continue title = node.metadata.title if title: title = safe_decode(title) url = make_url(self.request, node=node) query = make_query(contenttile=node.properties.default_content_tile) target = make_url(self.request, node=node, query=query) curnode = curpath == key and True or False icon = node_icon(self.request, node) css = "" if IWorkflowState.providedBy(node): css = "state-%s" % node.state child = self.navtreeitem(title, url, target, nodepath(node), icon, css) child["showchildren"] = curnode if curnode: child["selected"] = True if default_child: self.fillchildren(default_child, path[1:], child) else: self.fillchildren(node, path[1:], child) else: selected_path = nodepath(self.model) if default_child: selected_path.append(default_child.name) selected = False if selected_path == nodepath(node): selected = True child["selected"] = selected tree["children"].append(child)
def test_node_icon(self): model = BaseNode() model.properties.icon = 'my-icon' self.assertEqual(node_icon(model), 'my-icon') @node_info( name='mynode') class MyNode(BaseNode): pass model = MyNode() self.assertEqual( node_icon(model), 'glyphicon glyphicon-asterisk' ) @node_info( name='othernode', icon='other-icon') class OtherNode(BaseNode): pass model = OtherNode() self.assertEqual(node_icon(model), 'other-icon')
def create_item(self, node, props, empty_title, selected): md = node.metadata item = dict() item['id'] = node.name if empty_title: item['title'] = '' item['description'] = md.title else: item['title'] = md.title item['description'] = md.description item['url'] = make_url(self.request, node=node) query = make_query(contenttile=props.default_content_tile) item['target'] = make_url(self.request, node=node, query=query) item['selected'] = selected item['icon'] = node_icon(self.request, node) return item
def create_item(self, node, props, empty_title, selected): md = node.metadata item = dict() item['id'] = node.name if empty_title: item['title'] = '' item['description'] = md.title else: item['title'] = md.title item['description'] = md.description item['url'] = make_url(self.request, node=node) query = make_query(contenttile=props.default_content_tile) item['target'] = make_url(self.request, node=node, query=query) item['selected'] = selected item['icon'] = node_icon(node) return item
def create_item(self, node, props, empty_title, selected): md = node.metadata item = dict() item["id"] = node.name if empty_title: item["title"] = "" item["description"] = md.title else: item["title"] = md.title item["description"] = md.description item["url"] = make_url(self.request, node=node) query = make_query(contenttile=props.default_content_tile) item["target"] = make_url(self.request, node=node, query=query) item["selected"] = selected item["icon"] = node_icon(self.request, node) return item