fixes to post flag logic
This commit is contained in:
@@ -208,7 +208,7 @@ class Post < ActiveRecord::Base
|
|||||||
raise PostFlag::Error.new(flag.errors.full_messages.join("; "))
|
raise PostFlag::Error.new(flag.errors.full_messages.join("; "))
|
||||||
end
|
end
|
||||||
|
|
||||||
update_column(:is_flagged, true)
|
update_column(:is_flagged, true) unless is_flagged?
|
||||||
end
|
end
|
||||||
|
|
||||||
def appeal!(reason)
|
def appeal!(reason)
|
||||||
@@ -740,6 +740,7 @@ class Post < ActiveRecord::Base
|
|||||||
Post.transaction do
|
Post.transaction do
|
||||||
update_column(:is_deleted, true)
|
update_column(:is_deleted, true)
|
||||||
update_column(:is_pending, false)
|
update_column(:is_pending, false)
|
||||||
|
update_column(:is_flagged, false)
|
||||||
give_favorites_to_parent
|
give_favorites_to_parent
|
||||||
update_children_on_destroy
|
update_children_on_destroy
|
||||||
update_parent_on_destroy
|
update_parent_on_destroy
|
||||||
@@ -865,8 +866,12 @@ class Post < ActiveRecord::Base
|
|||||||
where("is_pending = ?", true)
|
where("is_pending = ?", true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def flagged
|
||||||
|
where("is_flagged = ?", true)
|
||||||
|
end
|
||||||
|
|
||||||
def pending_or_flagged
|
def pending_or_flagged
|
||||||
where("(is_pending = true OR (is_flagged = true and is_deleted = false))")
|
where("(is_pending = ? or is_flagged = ?)", true, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def undeleted
|
def undeleted
|
||||||
@@ -895,9 +900,9 @@ class Post < ActiveRecord::Base
|
|||||||
|
|
||||||
def available_for_moderation(hidden)
|
def available_for_moderation(hidden)
|
||||||
if hidden.present?
|
if hidden.present?
|
||||||
where("id IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id)
|
where("posts.id IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id)
|
||||||
else
|
else
|
||||||
where("id NOT IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id)
|
where("posts.id NOT IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class PostFlag < ActiveRecord::Base
|
|||||||
extend SearchMethods
|
extend SearchMethods
|
||||||
|
|
||||||
def update_post
|
def update_post
|
||||||
post.update_column(:is_flagged, true)
|
post.update_column(:is_flagged, true) unless post.is_flagged?
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_creator_is_not_limited
|
def validate_creator_is_not_limited
|
||||||
|
|||||||
2
script/fixes/002.sql
Normal file
2
script/fixes/002.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
set statement_timeout = 0;
|
||||||
|
update posts set is_flagged = false where is_deleted = true and is_flagged = true;
|
||||||
Reference in New Issue
Block a user