from __future__ import unicode_literals from django.template.loader import render_to_string from django.utils.html import escape, mark_safe from .icons import ( icon_index, icon_index_level_up, icon_index_instance_node_with_documents ) class IndexInstanceNodeWidget(object): def render(self, name, value): return render_to_string( template_name='document_indexing/index_instance_node.html', context={ 'index_instance_node': value, } ) class IndexTemplateNodeIndentationWidget(object): def render(self, name, value): return render_to_string( template_name='document_indexing/index_template_node_indentation.html', context={ 'index_template_node': value, 'index_template_node_level': range(value.get_level()), } ) def get_instance_link(index_instance_node): """ Return an HTML anchor to an index node instance """ return mark_safe( s='{text}'.format( url=index_instance_node.get_absolute_url(), text=escape(index_instance_node.get_full_path()) ) ) def node_tree(node, user): #TODO: Replace with a file template result = [] result.append('