From 77900bd76115bcaff6ebf2560b2eb3ce016afc61 Mon Sep 17 00:00:00 2001 From: Rocky Duan Date: Mon, 6 Aug 2012 23:17:38 -0400 Subject: [PATCH] simple blank slate --- .../django_comment_client/forum/views.py | 8 +++++++- lms/templates/discussion/_blank_slate.html | 7 +++++++ lms/templates/discussion/_forum.html | 15 ++++++++++----- lms/templates/discussion/_inline.html | 15 ++++++++++----- 4 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 lms/templates/discussion/_blank_slate.html diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index 69f426055f..2a4c419314 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -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: diff --git a/lms/templates/discussion/_blank_slate.html b/lms/templates/discussion/_blank_slate.html new file mode 100644 index 0000000000..e08a45cc70 --- /dev/null +++ b/lms/templates/discussion/_blank_slate.html @@ -0,0 +1,7 @@ +
+ % 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 +
diff --git a/lms/templates/discussion/_forum.html b/lms/templates/discussion/_forum.html index 62ae3adb67..b7d72b631c 100644 --- a/lms/templates/discussion/_forum.html +++ b/lms/templates/discussion/_forum.html @@ -15,11 +15,16 @@
New Post
<%include file="_sort.html" /> -
- % for thread in threads: - ${renderer.render_thread(course_id, thread, show_comments=False)} - % endfor -
+ % if len(threads) == 0: + <%include file="_blank_slate.html" /> +
+ % else: +
+ % for thread in threads: + ${renderer.render_thread(course_id, thread, show_comments=False)} + % endfor +
+ % endif <%include file="_paginator.html" /> diff --git a/lms/templates/discussion/_inline.html b/lms/templates/discussion/_inline.html index 97573a91c1..362523f7fc 100644 --- a/lms/templates/discussion/_inline.html +++ b/lms/templates/discussion/_inline.html @@ -8,11 +8,16 @@
New Post
<%include file="_sort.html" /> -
- % for thread in threads: - ${renderer.render_thread(course_id, thread, show_comments=False)} - % endfor -
+ % if len(threads) == 0: + <%include file="_blank_slate.html" /> +
+ % else: +
+ % for thread in threads: + ${renderer.render_thread(course_id, thread, show_comments=False)} + % endfor +
+ % endif <%include file="_paginator.html" />