admins can now clear flags inline

This commit is contained in:
Sam Saffron
2013-02-07 15:15:48 +11:00
parent 0f5bef61dc
commit c7461622a9
10 changed files with 86 additions and 10 deletions

View File

@@ -250,6 +250,17 @@ class Post < ActiveRecord::Base
result
end
def is_flagged?
post_actions.where('post_action_type_id in (?) and deleted_at is null', PostActionType.FlagTypes).count != 0
end
def unhide!
self.hidden = false
self.hidden_reason_id = nil
self.topic.update_attributes(visible: true)
self.save
end
# Update the body of a post. Will create a new version when appropriate
def revise(updated_by, new_raw, opts={})

View File

@@ -47,10 +47,14 @@ class PostAction < ActiveRecord::Base
user_actions
end
def self.clear_flags!(post, moderator_id)
def self.clear_flags!(post, moderator_id, action_type_id = nil)
# -1 is the automatic system cleary
actions = moderator_id == -1 ? PostActionType.AutoActionFlagTypes : PostActionType.FlagTypes
actions = if action_type_id
[action_type_id]
else
moderator_id == -1 ? PostActionType.AutoActionFlagTypes : PostActionType.FlagTypes
end
PostAction.exec_sql('update post_actions set deleted_at = ?, deleted_by = ?
where post_id = ? and deleted_at is null and post_action_type_id in (?)',