def endorse_comment(request, course_id, comment_id): """ given a course_id and comment_id, toggle the endorsement of this comment, ajax only """ course_key = CourseKey.from_string(course_id) comment = cc.Comment.find(comment_id) user = request.user comment.endorsed = request.POST.get('endorsed', 'false').lower() == 'true' comment.endorsement_user_id = user.id comment.save() comment_endorsed.send(sender=None, user=user, post=comment) return JsonResponse(prepare_content(comment.to_dict(), course_key))
def endorse_comment(request, course_id, comment_id): """ given a course_id and comment_id, toggle the endorsement of this comment, ajax only """ course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id) comment = cc.Comment.find(comment_id) user = request.user comment.endorsed = request.POST.get('endorsed', 'false').lower() == 'true' comment.endorsement_user_id = user.id comment.save() comment_endorsed.send(sender=None, user=user, post=comment) return JsonResponse(prepare_content(comment.to_dict(), course_key))