def delete_comment(request, course_id, comment_id): """ given a course_id and comment_id delete this comment ajax only """ course_key = CourseKey.from_string(course_id) comment = cc.Comment.find(comment_id) comment.delete() comment_deleted.send(sender=None, user=request.user, post=comment) return JsonResponse(prepare_content(comment.to_dict(), course_key))
def delete_comment(request, course_id, comment_id): """ given a course_id and comment_id delete this comment ajax only """ course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id) comment = cc.Comment.find(comment_id) comment.delete() comment_deleted.send(sender=None, user=request.user, post=comment) return JsonResponse(prepare_content(comment.to_dict(), course_key))
def delete_comment(request, course_id, comment_id): """ given a course_id and comment_id delete this comment ajax only """ course_key = CourseKey.from_string(course_id) comment = cc.Comment.find(comment_id) involved_users = get_involved_users_in_comment(request, comment) comment.delete() comment_deleted.send(sender=None, user=request.user, post=comment, involved_users=involved_users) return JsonResponse(prepare_content(comment.to_dict(), course_key))
def delete_comment(request, comment_id): """ Delete a comment. Arguments: request: The django request object used for build_absolute_uri and determining the requesting user. comment_id: The id of the comment to delete Raises: PermissionDenied: if user does not have permission to delete thread """ cc_comment, context = _get_comment_and_context(request, comment_id) if can_delete(cc_comment, context): cc_comment.delete() comment_deleted.send(sender=None, user=request.user, post=cc_comment) else: raise PermissionDenied