コード例 #1
0
ファイル: views.py プロジェクト: gc2gh/django-newsroom
def topic_path_edit(request, id):
    """
    Edit an existing topic path.
    """
    topic_path = TopicPath.objects.get(pk=id)
    if request.method == "POST":
        form = TopicPathForm(request.POST, instance=topic_path)
        if form.is_valid():
            form.save()
            request.user.message_set.create(message="Your topic has been edited.  Thank you.")
            return HttpResponseRedirect(reverse("topics_topic_path_list"))

    else:
        form = TopicPathForm(instance=topic_path)
    return render_to_response("topics/topic_path_edit.html", {"form": form}, context_instance=RequestContext(request))
コード例 #2
0
ファイル: views.py プロジェクト: gc2gh/django-newsroom
def topic_path_add(request):
    """
    Process a new topic path.
    """
    if request.method == "POST":
        form = TopicPathForm(request.POST)
        if form.is_valid():
            form.save()
            request.user.message_set.create(message="Your topic path has been added.  Thank you.")
            return HttpResponseRedirect(reverse("topics_topic_path_list"))

    else:
        # form = TopicForm(user=request.user)
        form = TopicPathForm()

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