Commit 77900bd7 by Rocky Duan

simple blank slate

parent 42cab659
......@@ -22,6 +22,11 @@ import dateutil
THREADS_PER_PAGE = 5
PAGES_NEARBY_DELTA = 2
def _should_perform_search(request):
return bool(request.GET.get('text', False) or \
request.GET.get('tags', False))
def render_accordion(request, course, discussion_id):
discussion_info = utils.get_categorized_discussion_info(request, course)
......@@ -56,6 +61,7 @@ def render_discussion(request, course_id, threads, discussion_id=None, \
'user_info': comment_client.get_user_info(request.user.id, raw=True),
'course_id': course_id,
'request': request,
'performed_search': _should_perform_search(request),
'pages_nearby_delta': PAGES_NEARBY_DELTA,
'discussion_type': discussion_type,
'base_url': base_url,
......@@ -81,7 +87,7 @@ def get_threads(request, course_id, discussion_id):
'tags': request.GET.get('tags', ''),
}
if query_params['text'] or query_params['tags']: #TODO do tags search without sunspot
if _should_perform_search(request):
query_params['commentable_id'] = discussion_id
threads, page, num_pages = comment_client.search_threads(course_id, recursive=False, query_params=utils.strip_none(query_params))
else:
......
<div class="blank-state">
% if performed_search:
There is no result matching your search parameters.
% else:
There is no post here yet. Be the first one to post!
% endif
</div>
......@@ -15,11 +15,16 @@
<div class="discussion-new-post control-button" href="javascript:void(0)">New Post</div>
</div>
<%include file="_sort.html" />
<div class="threads">
% for thread in threads:
${renderer.render_thread(course_id, thread, show_comments=False)}
% endfor
</div>
% if len(threads) == 0:
<%include file="_blank_slate.html" />
<div class="threads"></div>
% else:
<div class="threads">
% for thread in threads:
${renderer.render_thread(course_id, thread, show_comments=False)}
% endfor
</div>
% endif
<%include file="_paginator.html" />
</section>
......
......@@ -8,11 +8,16 @@
<div class="discussion-new-post control-button" href="javascript:void(0)">New Post</div>
<%include file="_sort.html" />
</div>
<div class="threads">
% for thread in threads:
${renderer.render_thread(course_id, thread, show_comments=False)}
% endfor
</div>
% if len(threads) == 0:
<%include file="_blank_slate.html" />
<div class="threads"></div>
% else:
<div class="threads">
% for thread in threads:
${renderer.render_thread(course_id, thread, show_comments=False)}
% endfor
</div>
% endif
<%include file="_paginator.html" />
</section>
......
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