Esempio n. 1
0
def comment_reply_add(request, com_id):    
    user = request.user 
    error = None
    if request.method == 'POST':
        add_form = ReplyAddForm(False, request.POST )
        if add_form.is_valid():
            post_info = add_form.cleaned_data
            resp, error  = _add_new_reply(request, post_info, user, com_id)
            if not error:
                return resp
    else:
        add_form = ReplyAddForm(edit=False)

    comment = Comment.objects.get(pk=com_id)
    reply = None
    context = {'username':user, 'comment':comment,
               'reply':reply, 'form':add_form, 'error':error}
    return render(request, 'tracking/reply_add.html', context)
Esempio n. 2
0
def reply_edit(request, com_id, rep_no):
    user = request.user

    error = None
    reply = None
    comment = None
    if request.method == 'POST':
        edit_form = ReplyAddForm(True, request.POST)
        if edit_form.is_valid():
            post_info = edit_form.cleaned_data
            reply, comment, error = _update_reply_info(com_id, rep_no,
                                               post_info, user)
    else:
        edit_form = ReplyAddForm(edit=True)

    if not comment:
        comment = Comment.objects.get(pk=com_id)

    if not reply:
        reply = Reply.objects.filter(comment=comment, number=rep_no).first()

    context = {'username':user, 'comment':comment, 'reply':reply,
               'is_edit':True, 'form':edit_form, 'error':error}
    return render(request, 'tracking/reply_add.html', context)