Commit 2685a3b6 by Rocky Duan

trending tags

parent fddee7de
......@@ -128,6 +128,11 @@ def forum_form_discussion(request, course_id, discussion_id):
'commentable_id': discussion_id},
)
trending_tags = comment_client.search_trending_tags(
course_id,
query_params={'commentable_id': discussion_id},
)
if request.is_ajax():
return utils.HtmlResponse(content)
else:
......@@ -137,6 +142,7 @@ def forum_form_discussion(request, course_id, discussion_id):
'content': content,
'accordion': render_accordion(request, course, discussion_id),
'recent_active_threads': recent_active_threads,
'trending_tags': trending_tags,
}
return render_to_response('discussion/index.html', context)
......
......@@ -39,6 +39,11 @@ def search_recent_active_threads(course_id, recursive=False, query_params={}, *a
attributes = dict(default_params.items() + query_params.items())
return _perform_request('get', _url_for_search_recent_active_threads(), attributes, *args, **kwargs)
def search_trending_tags(course_id, query_params={}, *args, **kwargs):
default_params = {'course_id': course_id}
attributes = dict(default_params.items() + query_params.items())
return _perform_request('get', _url_for_search_trending_tags(), attributes, *args, **kwargs)
def create_user(attributes, *args, **kwargs):
return _perform_request('post', _url_for_users(), attributes, *args, **kwargs)
......@@ -175,6 +180,9 @@ def _url_for_search_similar_threads():
def _url_for_search_recent_active_threads():
return "{prefix}/search/threads/recent_active".format(prefix=PREFIX)
def _url_for_search_trending_tags():
return "{prefix}/search/tags/trending".format(prefix=PREFIX)
def _url_for_threads_tags():
return "{prefix}/threads/tags".format(prefix=PREFIX)
......
Trending tags:
<div class="trending-tags">
% for tag in ['artificial-intelligence', 'java-sucks', '2012']:
% for tag, count in trending_tags:
<div class="trending-tag">
<a class="trending-tag-link" href="javascript:void(0)">${tag}</a>
&times;
<span class="trending-tag-count">100</span>
<span class="trending-tag-count">${count}</span>
</div>
% endfor
</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment