Add a way to flag a topic

This commit is contained in:
Neil Lalonde
2014-02-12 12:57:55 -05:00
parent 11ee4e7328
commit 6bbc3ec3e0
23 changed files with 251 additions and 26 deletions
+13 -1
View File
@@ -12,6 +12,7 @@ class PostActionsController < ApplicationController
args = {}
args[:message] = params[:message] if params[:message].present?
args[:take_action] = true if guardian.is_staff? and params[:take_action] == 'true'
args[:flag_topic] = true if params[:flag_topic]
post_action = PostAction.act(current_user, @post, @post_action_type_id, args)
@@ -63,7 +64,18 @@ class PostActionsController < ApplicationController
def fetch_post_from_params
params.require(:id)
finder = Post.where(id: params[:id])
post_id = if params[:flag_topic]
begin
Topic.find(params[:id]).posts.first.id
rescue
raise Discourse::NotFound
end
else
params[:id]
end
finder = Post.where(id: post_id)
# Include deleted posts if the user is a moderator (to guardian ?)
finder = finder.with_deleted if current_user.try(:moderator?)