Beispiel #1
0
def wtp(request, pk):
    context = get_default_context(request)
#    type = SectionType.objects.get(slug='catalog')
    nodes = Section.objects.filter(is_enabled=True).values()
    context['structure'] = build_tree(nodes)
    context['pk'] = pk
    return render_to_response('wtp/index.html', context)
Beispiel #2
0
def article(request, section, article):
    article = get_object_or_404(Article, name=article)
    context = RequestContext(request)
    groups = Group.objects.all().order_by('id').values()
    context['groups'] = build_tree(groups, 'group_id')
    context['section'] = get_object_or_404(Group, name=section)
    context['article'] = article
    return render_to_response('articles/article.html', context)
Beispiel #3
0
def tag(request, tag, page=None):
    context = RequestContext(request)
    groups = Group.objects.all().order_by('id').values()
    context['groups'] = build_tree(groups, 'group_id')
    context['tagview'] = get_object_or_404(Tag, name=tag)
    paginate(
        context, 'articles', 
        query=Article.objects.filter(tags__name__exact=tag).order_by('-date_written'),
        count=ARTICLES_ON_PAGE, page=page, 
        root=request.current_section.path+tag+'/'
    )
    return render_to_response('articles/tag.html', context)
Beispiel #4
0
def section(request, section, page=None):
    context = RequestContext(request)
    groups = Group.objects.all().order_by('id').values()
    context['groups'] = build_tree(groups, 'group_id')
    context['section'] = get_object_or_404(Group, name=section)
    paginate(
        context, 'articles', 
        query=context['section'].article_set.all(), 
        count=ARTICLES_ON_PAGE, page=page, 
        root=request.current_section.path+section+'/'
    )
    return render_to_response('articles/section.html', context)
Beispiel #5
0
def index(request, page=None):
    context = RequestContext(request)
    # create_widgets_context(context, 'articles_index', 1, 1)
    groups = Group.objects.all().order_by('id').values()
    context['groups'] = build_tree(groups, 'group_id')
    paginate(
        context, 'articles', 
        Article.objects.order_by('-date_written'),
        count=ARTICLES_ON_PAGE, page=page, 
        root=request.current_section.path
    )
    return render_to_response('articles/index.html', context)
 def get_structure():
     nodes = Section.objects.filter(is_enabled=True).values()
     return build_tree(nodes)
Beispiel #7
0
def action_index(request, id):
    context = get_default_context(request)
    nodes = Section.objects.filter(is_enabled=True).values()
    context['structure'] = build_tree(nodes)
    context['action_id'] = id
    return render_to_response('change_action/index.html', context)
 def get_parts_tree(self):
     nodes = Part.objects.filter(document=self).values()
     return build_tree(nodes)
Beispiel #9
0
        # calculated new node and distance to connection

        clean_d_m, remaining_nodes = clear_distance_matrix(
            temp_distance_dict,
            node_one=first_node_to_join,
            node_two=second_node_to_join)
        # delete items if key include connected nodes

        new_distances = find_new_distances(d_matrix=temp_distance_dict,
                                           nodes=remaining_nodes,
                                           node_one=first_node_to_join,
                                           node_two=second_node_to_join,
                                           step=backward_step)
        # distance of remaining nodes to connected nodes

        temp_distance_dict = update_distance_matrix(cleaned_d_matrix=clean_d_m,
                                                    alpha=alphabet,
                                                    new_dist=new_distances)
        # update distance matrix. and repeat q matrix so on...

    # result in distance_from_joined_node_to_joint
    # and we need to add last connection that is stored in new_distances

    build_tree(complete_tree=distance_from_joined_node_to_joint,
               remaining_distances=new_distances)
    # DONE result in distance_from_joined_node_to_joint now.

    # construct tree to print easily

    print_tree(distance_from_joined_node_to_joint)