Commit ab7c869b by Rocky Duan

random fixes

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