forked from e621ng/e621ng
[Posts] Allow guidelines flag in more cases for priv+
This commit is contained in:
parent
6155acad90
commit
690750d020
@ -1750,4 +1750,10 @@ class Post < ApplicationRecord
|
||||
linked_artists ||= tags.select { |t| t.category == Tag.categories.artist }.filter_map(&:artist)
|
||||
linked_artists.select { |artist| artist.linked_user_id == uploader_id }
|
||||
end
|
||||
|
||||
def flaggable_for_guidelines?
|
||||
return true if is_pending?
|
||||
return true if CurrentUser.is_privileged? && !has_tag?("grandfathered_content") && created_at.after?("2015-01-01")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
@ -188,7 +188,7 @@ class PostFlag < ApplicationRecord
|
||||
end
|
||||
errors.add(:parent_id, "cannot be set to the post being flagged") if parent_post.id == post.id
|
||||
when 'uploading_guidelines'
|
||||
errors.add(:reason, "can only be used on pending posts") unless post.is_pending
|
||||
errors.add(:reason, "cannot be used. The post is either not pending, or grandfathered") unless post.flaggable_for_guidelines?
|
||||
else
|
||||
errors.add(:reason, "is not one of the available choices") unless MAPPED_REASONS.key?(reason_name)
|
||||
end
|
||||
|
@ -19,7 +19,7 @@
|
||||
<%= f.hidden_field :post_id %>
|
||||
|
||||
<% Danbooru.config.flag_reasons.each do |flag_reason| %>
|
||||
<% if flag_reason[:name] == "uploading_guidelines" && !@post.is_pending %>
|
||||
<% if flag_reason[:name] == "uploading_guidelines" && !@post.flaggable_for_guidelines? %>
|
||||
<% next %>
|
||||
<% end %>
|
||||
|
||||
|
@ -43,7 +43,7 @@ class PostFlagTest < ActiveSupport::TestCase
|
||||
@post_flag = create(:post_flag, post: @post, reason_name: "uploading_guidelines")
|
||||
end
|
||||
end
|
||||
assert_match(/can only be used on pending posts/, error.message)
|
||||
assert_match(/not pending/, error.message)
|
||||
|
||||
@post = create(:post, is_pending: true)
|
||||
as(@bob) do
|
||||
|
Loading…
Reference in New Issue
Block a user