Exemplo n.º 1
0
def edit_comment(request, comment_id):
    comment = logic.get_comment(comment_id)
    if request.method == 'POST':
        print "going to edit comment by: ", comment.user.nickname
        logic.edit_comment(request, comment)
        return HttpResponseRedirect('/comments/show_comment/' + str(comment.id))
    elif request.method == 'GET':
        comment_form = CommentForm(instance=comment)
        return render(request, 'comments/edit_comment.html',
                      {'form': comment_form, 'comment': comment})
def edit_answer_comment(answ_id):

    cmnt_id = request.form['id']
    answer = logic.get_answer(answ_id)
    comment = logic.get_comment(cmnt_id)
    if answer is None or comment is None:
        abort(404)
    mates = logic.get_users_ids()

    return render_template('cmnt_a_form.html',
                           form_type='edit',
                           comment=comment,
                           answer=answer,
                           mates=mates)
def edit_question_comment(qstn_id):

    cmnt_id = request.form['id']
    question = logic.get_question(qstn_id)
    comment = logic.get_comment(cmnt_id)
    if question is None or comment is None:
        abort(404)
    mates = logic.get_users_ids()

    return render_template('cmnt_q_form.html',
                           form_type='edit',
                           comment=comment,
                           question=question,
                           mates=mates)
Exemplo n.º 4
0
def delete_comment(request, comment_id):
    comment = logic.get_comment(comment_id)
    if not logic.delete_comment(request, comment):
        return HttpResponseRedirect('/comments/show_comment/'+str(comment_id))
    return HttpResponseRedirect('/comments/show_comment/'+str(comment_id))
Exemplo n.º 5
0
def show_comment(request, comment_id):
    comment = logic.get_comment(comment_id)
    return render(request, 'comments/show_comment.html', {'comment':comment})