Commit ab7c869b by Rocky Duan

random fixes

parent 45e9a3aa
...@@ -80,17 +80,17 @@ def get_threads(request, course_id, discussion_id): ...@@ -80,17 +80,17 @@ def get_threads(request, course_id, discussion_id):
query_params = { query_params = {
'page': request.GET.get('page', 1), 'page': request.GET.get('page', 1),
'per_page': THREADS_PER_PAGE, #TODO maybe change this later 'per_page': THREADS_PER_PAGE, #TODO maybe change this later
'sort_key': request.GET.get('sort_key', None), 'sort_key': request.GET.get('sort_key', ''),
'sort_order': request.GET.get('sort_order', None), 'sort_order': request.GET.get('sort_order', ''),
'text': request.GET.get('text', None), 'text': request.GET.get('text', ''),
'tags': request.GET.get('tags', None), 'tags': request.GET.get('tags', ''),
} }
if query_params['text'] or query_params['tags']: #TODO do tags search without sunspot if query_params['text'] or query_params['tags']: #TODO do tags search without sunspot
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=query_params) threads, page, num_pages = comment_client.search_threads(course_id, recursive=False, query_params=strip_none(query_params))
else: else:
threads, page, num_pages = comment_client.get_threads(discussion_id, recursive=False, query_params=query_params) threads, page, num_pages = comment_client.get_threads(discussion_id, recursive=False, query_params=strip_none(query_params))
query_params['page'] = page query_params['page'] = page
query_params['num_pages'] = num_pages query_params['num_pages'] = num_pages
......
...@@ -17,7 +17,9 @@ def extract(dic, keys): ...@@ -17,7 +17,9 @@ def extract(dic, keys):
return {k: dic[k] for k in keys} return {k: dic[k] for k in keys}
def strip_none(dic): def strip_none(dic):
return dict([(k, v) for k, v in dic.iteritems() if v is not None]) def _is_none(v):
return v is None or (isinstance(v, str) and len(v.strip()) == 0)
return dict([(k, v) for k, v in dic.iteritems() if not _is_none(v)])
def get_full_modules(): def get_full_modules():
global _FULLMODULES global _FULLMODULES
......
...@@ -423,6 +423,7 @@ Discussion = ...@@ -423,6 +423,7 @@ Discussion =
handleShowSingleThread(this) handleShowSingleThread(this)
$local(".discussion-reply").click -> $local(".discussion-reply").click ->
handleShowSingleThread($local(".thread-title"))
handleReply(this) handleReply(this)
$local(".discussion-cancel-reply").click -> $local(".discussion-cancel-reply").click ->
......
<%namespace name="renderer" file="_thread.html"/>
${renderer.render_comments(thread['children'])}
...@@ -70,17 +70,17 @@ ...@@ -70,17 +70,17 @@
<%def name="render_bottom_bar(content, type, **kwargs)"> <%def name="render_bottom_bar(content, type, **kwargs)">
<div class="info"> <div class="info">
${render_info(content)} ${render_info(content)}
${render_link("discussion-link discussion-reply", "Reply")}
% if type == "thread" and kwargs['edit_thread'] or type == "comment": % if type == "thread" and kwargs['edit_thread'] or type == "comment":
${render_link("discussion-link discussion-reply", "Reply")}
${render_link("discussion-link discussion-edit", "Edit")} ${render_link("discussion-link discussion-edit", "Edit")}
% if type == "comment" and request.user.is_staff: % endif
% if content['endorsed']: % if type == "comment" and request.user.is_staff:
<input type="checkbox" checked="checked" class="discussion-link discussion-endorse" id="discussion-endorse-${content['id']}"> % if content['endorsed']:
% else: <input type="checkbox" checked="checked" class="discussion-link discussion-endorse" id="discussion-endorse-${content['id']}">
<input type="checkbox" class="discussion-link discussion-endorse" id="discussion-endorse-${content['id']}"> % else:
% endif <input type="checkbox" class="discussion-link discussion-endorse" id="discussion-endorse-${content['id']}">
<label class="discussion-link" for="discussion-endorse-${content['id']}">Endorsed</label>
% endif % endif
<label class="discussion-link" for="discussion-endorse-${content['id']}">Endorsed</label>
% endif % endif
</div> </div>
</%def> </%def>
......
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