def search_similar_threads(request, course_id, commentable_id): """ given a course id and commentable id, run query given in text get param of request """ text = request.GET.get('text', None) if text: query_params = { 'text': text, 'commentable_id': commentable_id, } threads = cc.search_similar_threads(course_id, recursive=False, query_params=query_params) else: theads = [] context = {'threads': map(utils.extend_content, threads)} return JsonResponse({ 'html': render_to_string('discussion/_similar_posts.html', context) })