Commit 45a8fdda by Arjun Singh

fix search

parent 3f8b533a
...@@ -162,22 +162,22 @@ def forum_form_discussion(request, course_id): ...@@ -162,22 +162,22 @@ def forum_form_discussion(request, course_id):
'discussion_data': map(utils.safe_content, threads), 'discussion_data': map(utils.safe_content, threads),
}) })
else: else:
recent_active_threads = cc.search_recent_active_threads( #recent_active_threads = cc.search_recent_active_threads(
course_id, # course_id,
recursive=False, # recursive=False,
query_params={'follower_id': request.user.id}, # query_params={'follower_id': request.user.id},
) #)
trending_tags = cc.search_trending_tags( #trending_tags = cc.search_trending_tags(
course_id, # course_id,
) #)
escapedict = {'"': '"'} escapedict = {'"': '"'}
context = { context = {
'csrf': csrf(request)['csrf_token'], 'csrf': csrf(request)['csrf_token'],
'course': course, 'course': course,
'content': content, 'content': content,
'recent_active_threads': recent_active_threads, #'recent_active_threads': recent_active_threads,
'trending_tags': trending_tags, #'trending_tags': trending_tags,
'staff_access' : has_access(request.user, course, 'staff'), 'staff_access' : has_access(request.user, course, 'staff'),
'threads': saxutils.escape(json.dumps(threads),escapedict), 'threads': saxutils.escape(json.dumps(threads),escapedict),
'user_info': saxutils.escape(json.dumps(user_info),escapedict), 'user_info': saxutils.escape(json.dumps(user_info),escapedict),
......
...@@ -3,7 +3,7 @@ class @DiscussionThreadListView extends Backbone.View ...@@ -3,7 +3,7 @@ class @DiscussionThreadListView extends Backbone.View
events: events:
"click .search": "showSearch" "click .search": "showSearch"
"click .browse": "toggleTopicDrop" "click .browse": "toggleTopicDrop"
"keyup .post-search-field": "performSearch" "keydown .post-search-field": "performSearch"
"click .sort-bar a": "sortThreads" "click .sort-bar a": "sortThreads"
"click .browse-topic-drop-menu": "filterTopic" "click .browse-topic-drop-menu": "filterTopic"
"click .browse-topic-drop-search-input": "ignoreClick" "click .browse-topic-drop-search-input": "ignoreClick"
...@@ -100,8 +100,9 @@ class @DiscussionThreadListView extends Backbone.View ...@@ -100,8 +100,9 @@ class @DiscussionThreadListView extends Backbone.View
clearTimeout(@timer) clearTimeout(@timer)
@timer = setTimeout(callback, ms) @timer = setTimeout(callback, ms)
performSearch: -> performSearch: (event) ->
callback = => if event.which == 13
event.preventDefault()
url = DiscussionUtil.urlFor("search") url = DiscussionUtil.urlFor("search")
text = @$(".post-search-field").val() text = @$(".post-search-field").val()
DiscussionUtil.safeAjax DiscussionUtil.safeAjax
...@@ -112,6 +113,4 @@ class @DiscussionThreadListView extends Backbone.View ...@@ -112,6 +113,4 @@ class @DiscussionThreadListView extends Backbone.View
success: (response, textStatus) => success: (response, textStatus) =>
if textStatus == 'success' if textStatus == 'success'
@collection.reset(response.discussion_data) @collection.reset(response.discussion_data)
@displayedCollection.reset(@collection) @displayedCollection.reset(@collection.models)
@delay(callback, 300)
...@@ -8,8 +8,6 @@ class @ThreadResponseView extends DiscussionContentView ...@@ -8,8 +8,6 @@ class @ThreadResponseView extends DiscussionContentView
"click .action-endorse": "toggleEndorse" "click .action-endorse": "toggleEndorse"
render: -> render: ->
console.log @model
console.log @model.toJSON()
@$el.html(@template(@model.toJSON())) @$el.html(@template(@model.toJSON()))
if window.user.voted(@model) if window.user.voted(@model)
@$(".vote-btn").addClass("is-cast") @$(".vote-btn").addClass("is-cast")
......
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