def get(self, request, *args, **kwargs): node = DynatreeNode() node.node_attrs["title"] = "Disks" node.node_attrs["isFolder"] = True node.node_attrs["key"] = "disks_root_node" node.node_attrs["url"] = AllDisksDetailsView.get_permalink() node.node_attrs["isLazy"] = True node.node_attrs["lazyLoadingUrl"] = DiskNodesJSONView.get_permalink() return self.render_to_response(node.node_attrs)
def _set_disk_node_attrs(self, disk, parent_node): node_child = DynatreeNode() node_child.node_attrs['title'] = disk.name node_child.node_attrs['icon'] = 'hard_disk_32x32.png' node_child.node_attrs['url'] = disk.get_absolute_url() node_child.node_attrs['isFolder'] = True node_child.node_attrs['isLazy'] = True, node_child.node_attrs['lazyLoadingUrl'] = disk.get_children_lazy_loading_url() if parent_node.node_attrs['children'] is None: parent_node.node_attrs['children'] = [] parent_node.node_attrs['children'].append(node_child.node_attrs)
def get(self, request, disk_id, *args, **kwargs): objects = self.model.objects.filter(parent=disk_id) if len(objects) > 0: children = [] #if not request.user.is_anonymous(): node = DynatreeNode() node.node_attrs['title'] = self.model.get_node_title() node.node_attrs['isFolder'] = True node.node_attrs['isLazy'] = False node.node_attrs['url'] = objects[0].get_list_url() node.node_attrs['children'] = [] for obj in objects: node_child = DynatreeNode() node_child.node_attrs['title'] = obj.name node_child.node_attrs['url'] = obj.get_absolute_url() node_child.node_attrs['isFolder'] = False node.node_attrs['children'].append(node_child.node_attrs) children.append(node.node_attrs) else: #Node has no children children = None return self.render_to_response(children)