Пример #1
0
def configure(request):
    """
    Process the configuration form for a Stage 1 Process.
    """

    auth = ContributorProfile.auth_status(request.user)
    if auth != 'staff' or request.method != 'POST':
        raise PermissionDenied

    form = Stage1Configure(request.POST)
    if form.is_valid():

        # If there is an old root, make it no longer the master.
        old_master = CITreeInfo.get_master_tree_root()
        if old_master is not None:
            old_master.is_master = False
            old_master.save()

        #Create the initial stage1 hierarchy from the submission
        #form. We need the CI Tree Info as well as one root node
        #to begin
        master_tree_info = CITreeInfo(is_master=True)
        master_tree_info.save()

        root_node = ConceptNode(
            ci_tree_info=master_tree_info,
            content=form.cleaned_data['root_name'],
            max_children=form.cleaned_data['max_children'],
            child_typename=form.cleaned_data['child_typename'])
        root_node.save()

        return redirect('stage1 dispatch')
    else:
        raise SuspiciousOperation
Пример #2
0
def configure(request):
    """
    Process the configuration form for a Stage 1 Process.
    """

    auth = ContributorProfile.auth_status(request.user)
    if auth != 'staff' or request.method != 'POST':
        raise PermissionDenied

    form = Stage1Configure(request.POST)
    if form.is_valid():

        # If there is an old root, make it no longer the master.
        old_master = CITreeInfo.get_master_tree_root()
        if old_master is not None:
            old_master.is_master = False
            old_master.save()

        #Create the initial stage1 hierarchy from the submission
        #form. We need the CI Tree Info as well as one root node
        #to begin
        master_tree_info = CITreeInfo(is_master=True)
        master_tree_info.save()

        root_node = ConceptNode(
            ci_tree_info = master_tree_info,
            content = form.cleaned_data['root_name'],
            max_children = form.cleaned_data['max_children'],
            child_typename = form.cleaned_data['child_typename']
        )
        root_node.save()

        return redirect('stage1 dispatch')
    else:
        raise SuspiciousOperation
Пример #3
0
def add_child(request):
    root = CITreeInfo.get_master_tree_root()
    if not root:
        return redirect('stage1 setup')
    info = root.ci_tree_info

    parent = get_object_or_404(ConceptNode,pk=request.POST['node_id'])
    node = ConceptNode(ci_tree_info=info,
                       parent=parent,
                       content=request.POST['node_addchild_content'],
                       child_typename=request.POST['node_addchild_childtype'])
    node.save()

    # Refresh handle to the root, in case adding our node changed it.
    root = CITreeInfo.get_master_tree_root()

    tree = root.get_descendants(include_self=True)
    context = {'tree': tree,
               'user': request.user,
               'open_ids': request.POST['openids']}

    return render(request, 'cistage1/edit_tree.html', context)
Пример #4
0
def add_child(request):
    root = CITreeInfo.get_master_tree_root()
    if not root:
        return redirect('stage1 setup')
    info = root.ci_tree_info

    parent = get_object_or_404(ConceptNode, pk=request.POST['node_id'])
    node = ConceptNode(ci_tree_info=info,
                       parent=parent,
                       content=request.POST['node_addchild_content'],
                       child_typename=request.POST['node_addchild_childtype'])
    node.save()

    # Refresh handle to the root, in case adding our node changed it.
    root = CITreeInfo.get_master_tree_root()

    tree = root.get_descendants(include_self=True)
    context = {
        'tree': tree,
        'user': request.user,
        'open_ids': request.POST['openids']
    }

    return render(request, 'cistage1/edit_tree.html', context)
Пример #5
0
def close_rank_export_choices(ranking_process):

    choices = ranking_process.get_ranked_items_in_order()
    parent_node = ranking_process.parent
    parent_info = parent_node.ci_tree_info

    for choice in choices:  #choice is a ConceptAtom here

        new_child = ConceptNode(
            ci_tree_info=parent_info,
            parent=parent_node,
            content=choice.text,
        )
        new_child.save()

    #once we have created the new nodes we close the ranking process
    ranking_process.status = ranking_process.closed
    ranking_process.save()

    #and advance the state of the parent node
    parent_node.transition_node_state()
    parent_node.save()

    return
Пример #6
0
def close_rank_export_choices(ranking_process):
    
    choices = ranking_process.get_ranked_items_in_order()
    parent_node = ranking_process.parent
    parent_info = parent_node.ci_tree_info
        
    for choice in choices: #choice is a ConceptAtom here

        new_child = ConceptNode(
            ci_tree_info = parent_info,
            parent = parent_node,
            content = choice.text,
        )
        new_child.save()

    #once we have created the new nodes we close the ranking process
    ranking_process.status = ranking_process.closed
    ranking_process.save()

    #and advance the state of the parent node
    parent_node.transition_node_state()
    parent_node.save()
    
    return