コード例 #1
0
ファイル: views.py プロジェクト: udayanshevade/nanoproblems
def edit_comment_from_problem(request, problem_id, comment_id):
    problem = logic.get_problem(problem_id)
    comment = comments_logic.get_comment(comment_id)
    if request.method == 'POST':
        comment = logic.edit_comment_problem(request, problem, comment_id)
        return HttpResponseRedirect('/problems/' + str(problem_id))
    else:
        comment_form = CommentForm()
    return render(request, 'problems/edit_comment.html',
                  {'form': comment_form, 'problem_id': problem_id, 'comment':comment})
コード例 #2
0
ファイル: views.py プロジェクト: udayanshevade/nanoproblems
def edit_comment_from_solution(request, problem_id, solution_id, comment_id):
    solution = logic.get_solution(solution_id)
    comment = comments_logic.get_comment(comment_id)
    if request.method == 'POST':
        comment = logic.edit_comment_solution(request, solution, comment_id)
        return HttpResponseRedirect('/problems/' + str(problem_id) + '/show_solution/' + str(solution_id))
    else:
        comment_form = CommentForm()
    return render(request, 'problems/edit_comment_solution.html',
                  {'form': comment_form, 'problem_id':problem_id, 'solution_id': solution_id, 'comment':comment})
コード例 #3
0
ファイル: logic.py プロジェクト: udayanshevade/nanoproblems
def delete_comment_solution(request, solution, comment_id):
    comment = comments_logic.get_comment(comment_id)
    if comment:
        if comment in solution.comments.all():
            solution.comments.remove(comment)
        else:
            return False
        comments_logic.delete_comment(request, comment)
        return True
    else:
        print "something went wrong, couldn't find comment"
        return False
コード例 #4
0
ファイル: logic.py プロジェクト: udayanshevade/nanoproblems
def edit_comment_solution(request, solution, comment_id):
    """ Edit comment.
    """
    comment = comments_logic.get_comment(comment_id)
    # Return false if comment is not in this problem!
    if comment:
        if comment not in solution.comments.all():
            return False
        comments_logic.edit_comment(request, comment)
        return comment
    else:
        print "something went wrong, couldn't find comment"
        return False
コード例 #5
0
ファイル: logic.py プロジェクト: udayanshevade/nanoproblems
def delete_comment_problem(request, problem, comment_id):
    print "inside logic deletecommentproblem"
    comment = comments_logic.get_comment(comment_id)
    if comment:
        if comment in problem.comments.all():
            problem.comments.remove(comment)
        else:
            return False
        comments_logic.delete_comment(request, comment)
        return True
    else:
        print "something went wrong, couldn't find comment"
        return False
コード例 #6
0
ファイル: logic.py プロジェクト: pshevade/nanoproblems
def delete_comment_problem(request, problem, comment_id):
    print "inside logic deletecommentproblem"
    comment = comments_logic.get_comment(comment_id)
    if comment and is_authorized(comment, request.session["email"]):
        if comment in problem.comments.all():
            problem.comments.remove(comment)
        else:
            return False
        problem.save()
        comments_logic.delete_comment(request, comment)
        return True
    else:
        print "something went wrong, couldn't find comment"
        return False
コード例 #7
0
ファイル: logic.py プロジェクト: pshevade/nanoproblems
def delete_comment_solution(request, solution, comment_id):
    comment = comments_logic.get_comment(comment_id)
    if comment and is_authorized(comment, request.session["email"]):
        if comment in solution.comments.all():
            print "Removing solution's comment. ", comment.content
            solution.comments.remove(comment)

        else:
            return False
        solution.save()
        comments_logic.delete_comment(request, comment)
        return True
    else:
        print "something went wrong, couldn't find comment"
        return False