Commit 77900bd7 by Rocky Duan

simple blank slate

parent 42cab659
...@@ -22,6 +22,11 @@ import dateutil ...@@ -22,6 +22,11 @@ import dateutil
THREADS_PER_PAGE = 5 THREADS_PER_PAGE = 5
PAGES_NEARBY_DELTA = 2 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): def render_accordion(request, course, discussion_id):
discussion_info = utils.get_categorized_discussion_info(request, course) discussion_info = utils.get_categorized_discussion_info(request, course)
...@@ -56,6 +61,7 @@ def render_discussion(request, course_id, threads, discussion_id=None, \ ...@@ -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), 'user_info': comment_client.get_user_info(request.user.id, raw=True),
'course_id': course_id, 'course_id': course_id,
'request': request, 'request': request,
'performed_search': _should_perform_search(request),
'pages_nearby_delta': PAGES_NEARBY_DELTA, 'pages_nearby_delta': PAGES_NEARBY_DELTA,
'discussion_type': discussion_type, 'discussion_type': discussion_type,
'base_url': base_url, 'base_url': base_url,
...@@ -81,7 +87,7 @@ def get_threads(request, course_id, discussion_id): ...@@ -81,7 +87,7 @@ def get_threads(request, course_id, discussion_id):
'tags': request.GET.get('tags', ''), '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 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)) threads, page, num_pages = comment_client.search_threads(course_id, recursive=False, query_params=utils.strip_none(query_params))
else: 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 @@ ...@@ -15,11 +15,16 @@
<div class="discussion-new-post control-button" href="javascript:void(0)">New Post</div> <div class="discussion-new-post control-button" href="javascript:void(0)">New Post</div>
</div> </div>
<%include file="_sort.html" /> <%include file="_sort.html" />
<div class="threads"> % if len(threads) == 0:
% for thread in threads: <%include file="_blank_slate.html" />
${renderer.render_thread(course_id, thread, show_comments=False)} <div class="threads"></div>
% endfor % else:
</div> <div class="threads">
% for thread in threads:
${renderer.render_thread(course_id, thread, show_comments=False)}
% endfor
</div>
% endif
<%include file="_paginator.html" /> <%include file="_paginator.html" />
</section> </section>
......
...@@ -8,11 +8,16 @@ ...@@ -8,11 +8,16 @@
<div class="discussion-new-post control-button" href="javascript:void(0)">New Post</div> <div class="discussion-new-post control-button" href="javascript:void(0)">New Post</div>
<%include file="_sort.html" /> <%include file="_sort.html" />
</div> </div>
<div class="threads"> % if len(threads) == 0:
% for thread in threads: <%include file="_blank_slate.html" />
${renderer.render_thread(course_id, thread, show_comments=False)} <div class="threads"></div>
% endfor % else:
</div> <div class="threads">
% for thread in threads:
${renderer.render_thread(course_id, thread, show_comments=False)}
% endfor
</div>
% endif
<%include file="_paginator.html" /> <%include file="_paginator.html" />
</section> </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