Python CreateNodeForm Beispiele

Python CreateNodeForm - 3 Beispiele gefunden. Dies sind die am besten bewerteten Python Beispiele für die mainforms.CreateNodeForm, die aus Open Source-Projekten extrahiert wurden. Sie können Beispiele bewerten, um die Qualität der Beispiele zu verbessern.
Häufig verwendete Methoden
Beispiel #1
0
def add_arg(request, node_id, arg_type):
    parent = get_object_or_404(TruthNode, pk=int(node_id))
    if request.method == "POST":
        form = CreateNodeForm(request.POST)
        if form.is_valid():
            node = TruthNode()
            node.title = form.cleaned_data.get("title")
            node.content = form.cleaned_data.get("content")
            node.save()

            relate = createRelationship(node, parent, arg_type)

            change = ChangeNotification()
            change.change_type = ChangeNotification.ADD
            change.user = users.get_current_user().nickname()
            change.node = relate.child_node
            change.node_title = relate.child_node.title
            change.pin_type = relate.relationship
            change.parent_node = relate.parent_node
            change.parent_node_title = relate.parent_node.title
            change.save()

            return HttpResponseRedirect(reverse("node", args=[parent.id]))
    else:
        form = CreateNodeForm()

    context = {
        "parent": parent,
        "arg_type": arg_type,
        "arg_type_text": node_relationship_choices[arg_type],
        "form": form,
    }
    return render_to_response("arg.html", context, context_instance=RequestContext(request))
Beispiel #2
0
def add_node(request):
    if request.method == "POST":
        form = CreateNodeForm(request.POST)
        if form.is_valid():
            node = TruthNode()
            node.title = form.cleaned_data.get("title")
            node.content = form.cleaned_data.get("content")
            node.save()

            createRelationship(
                child=node,
                parent=TruthNode.objects.get(pk=settings.ORPHANS_ID),
                rel_type=NodeRelationship.PRO,
                discuss=False,
            )

            change = ChangeNotification()
            change.change_type = ChangeNotification.CREATE
            change.user = users.get_current_user().nickname()
            change.node = node
            change.node_title = node.title
            change.save()

            return HttpResponseRedirect(reverse("node", args=[node.id]))
    else:
        form = CreateNodeForm()

    return render_to_response("add.html", {"form": form}, context_instance=RequestContext(request))
Beispiel #3
0
def edit_node(request, node_id):
    node = get_object_or_404(TruthNode, pk=int(node_id))
    if request.method == "POST":
        form = CreateNodeForm(request.POST)
        if form.is_valid():
            change = ChangeNotification()
            change.change_type = ChangeNotification.EDIT
            change.user = users.get_current_user().nickname()
            change.node = node
            change.node_title = node.title
            change.save()

            node.title = form.cleaned_data.get("title")
            node.content = form.cleaned_data.get("content")
            node.save()

            return HttpResponseRedirect(reverse("node", args=[node.id]))
    else:
        form = CreateNodeForm(initial={"title": node.title, "content": node.content})

    return render_to_response("add.html", {"form": form}, context_instance=RequestContext(request))