Ejemplo n.º 1
0
def add_comment(request, post_parent):
    current_user = get_current_user(request=request)
    if request.method == "POST":
        print "add comment"
        #Create post
        new_post = Post()
        new_post.autor = current_user
        new_post.text = request.POST["comment_text"]
        new_post.mainPost = Post.objects.get(id=post_parent)
        new_post.save()
        #Post has been created
        urlForRedirect = "/show_discussion_id=%s" % post_parent
        return redirect("/all_discussion")
Ejemplo n.º 2
0
def add_answer(request, post_parent):
    current_user = get_current_user(request=request)
    sub_main_post = Post.objects.get(pk=post_parent)
    main_post = sub_main_post.mainPost
    if request.method == "POST":
        #Create post
        new_post = Post()
        new_post.autor = current_user
        new_post.text = request.POST["comment_text"]
        new_post.mainPost = main_post
        new_post.subMainPost = sub_main_post
        new_post.save()
        #Post has been created
        urlForRedirect = "/show_discussion_id=%s" % main_post.id
        return redirect("/all_discussion")
Ejemplo n.º 3
0
def new_discussion(request):
    if request.method == "POST":
        current_user = get_current_user(request=request)
        #Create post
        new_post = Post()
        new_post.autor = current_user
        new_post.text = request.POST["post_text"]
        new_post.save()
        #Create discussion
        new_discussion = Discussion()
        new_discussion.theme = request.POST["discussion_theme"]
        new_discussion.bodyText = new_post
        new_discussion.master = current_user
        new_discussion.save()
        return redirect("/all_discussion")
    return render(request, "new_discussion.html", {"current_user": get_current_user(request=request)})
Ejemplo n.º 4
0
def create_group_discussion(request, group_id):
    current_user = get_current_user(request=request)
    current_group = Group.objects.get(id=group_id)
    if request.method == "POST":
        #Create post
        new_post = Post()
        new_post.autor = current_user
        new_post.text = request.POST["post_text"]
        new_post.save()
        #Create discussion
        new_discussion = Discussion()
        new_discussion.theme = request.POST["discussion_theme"]
        new_discussion.bodyText = new_post
        new_discussion.master = current_user
        new_discussion.save()
        #Add discussion to group
        current_group.discussionList.add(new_discussion)
        current_group.save()
        urlForRedirect = "/show_group_id=%s" % group_id
        return redirect(urlForRedirect)