Commit 4f8bd316 by arjun810

Merge pull request #9 from rll/fix_followed_scope

Make sure to scope followed threads by course.
parents f2e491e7 81dca823
...@@ -30,7 +30,7 @@ post "#{APIPREFIX}/threads/:thread_id/comments" do |thread_id| ...@@ -30,7 +30,7 @@ post "#{APIPREFIX}/threads/:thread_id/comments" do |thread_id|
comment = Comment.new(params.slice(*%w[body course_id])) comment = Comment.new(params.slice(*%w[body course_id]))
comment.anonymous = bool_anonymous || false comment.anonymous = bool_anonymous || false
comment.anonymous_to_peers = bool_anonymous_to_peers || false comment.anonymous_to_peers = bool_anonymous_to_peers || false
comment.author = user comment.author = user
comment.comment_thread = thread comment.comment_thread = thread
comment.save comment.save
if comment.errors.any? if comment.errors.any?
......
...@@ -76,7 +76,7 @@ helpers do ...@@ -76,7 +76,7 @@ helpers do
end end
def handle_threads_query(comment_threads) def handle_threads_query(comment_threads)
comment_threads = comment_threads.where(:course_id=>params[:course_id])
if CommentService.config[:cache_enabled] if CommentService.config[:cache_enabled]
query_params = params.slice(*%w[course_id commentable_id sort_key sort_order page per_page user_id]) query_params = params.slice(*%w[course_id commentable_id sort_key sort_order page per_page user_id])
memcached_key = "threads_query_#{query_params.hash}" memcached_key = "threads_query_#{query_params.hash}"
...@@ -105,6 +105,7 @@ helpers do ...@@ -105,6 +105,7 @@ helpers do
sort_key = sort_key_mapper[params["sort_key"]] sort_key = sort_key_mapper[params["sort_key"]]
sort_order = sort_order_mapper[params["sort_order"]] sort_order = sort_order_mapper[params["sort_order"]]
sort_keyword_valid = (!params["sort_key"] && !params["sort_order"] || sort_key && sort_order) sort_keyword_valid = (!params["sort_key"] && !params["sort_order"] || sort_key && sort_order)
if not sort_keyword_valid if not sort_keyword_valid
{}.to_json {}.to_json
else else
......
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