def openclose_thread(request, course_id, thread_id): """ given a course_id and thread_id, toggle the status of this thread ajax only """ thread = cc.Thread.find(thread_id) thread.closed = request.POST.get("closed", "false").lower() == "true" thread.save() thread = thread.to_dict() return JsonResponse( {"content": utils.safe_content(thread), "ability": utils.get_ability(course_id, thread, request.user)} )
def openclose_thread(request, course_id, thread_id): """ given a course_id and thread_id, toggle the status of this thread ajax only """ thread = cc.Thread.find(thread_id) thread.closed = request.POST.get('closed', 'false').lower() == 'true' thread.save() thread = thread.to_dict() return JsonResponse({ 'content': safe_content(thread), 'ability': get_ability(SlashSeparatedCourseKey.from_deprecated_string(course_id), thread, request.user), })
def openclose_thread(request, course_id, thread_id): """ given a course_id and thread_id, toggle the status of this thread ajax only """ thread = cc.Thread.find(thread_id) thread.closed = request.POST.get('closed', 'false').lower() == 'true' thread.save() thread = thread.to_dict() return JsonResponse({ 'content': utils.safe_content(thread), 'ability': utils.get_ability(course_id, thread, request.user), })
def openclose_thread(request, course_id, thread_id): """ given a course_id and thread_id, toggle the status of this thread ajax only """ course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id) thread = cc.Thread.find(thread_id) thread.closed = request.POST.get("closed", "false").lower() == "true" thread.save() thread = thread.to_dict() return JsonResponse( {"content": safe_content(thread, course_key), "ability": get_ability(course_key, thread, request.user)} )
def openclose_thread(request, course_id, thread_id): """ given a course_id and thread_id, toggle the status of this thread ajax only """ course_key = CourseKey.from_string(course_id) thread = cc.Thread.find(thread_id) thread.closed = request.POST.get('closed', 'false').lower() == 'true' thread.save() return JsonResponse({ 'content': prepare_content(thread.to_dict(), course_key), 'ability': get_ability(course_key, thread.to_dict(), request.user), })