Exemplo n.º 1
0
def delete_problem(request, problem):
    if is_authorized(problem, request.session["email"]):
        for comment in problem.comments.all():
            delete_comment_problem(request, problem, comment.id)
        try:
            problem.delete()
            return True
        except Exception, e:
            print e
Exemplo n.º 2
0
def delete_solution(request, solution):
    if is_authorized(solution, request.session["email"]):
        for comment in solution.comments.all():
            delete_comment_solution(request, solution, comment.id)
        try:
            solution.delete()
            return True
        except Exception, e:
            print e
            return False
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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