Add user permissions for flagging and for giving user feedback

This commit is contained in:
Albert Yi
2018-12-11 16:41:20 -08:00
parent c34df49f0f
commit 4706cae114
10 changed files with 96 additions and 6 deletions

View File

@@ -146,6 +146,10 @@ class PostFlag < ApplicationRecord
def validate_creator_is_not_limited
return if is_deletion
if creator.no_flagging?
errors[:creator] << "cannot flag posts"
end
if creator_id != User.system.id && PostFlag.for_creator(creator_id).where("created_at > ?", 30.days.ago).count >= CREATION_THRESHOLD
report = Reports::PostFlags.new(user_id: post.uploader_id, date_range: 90.days.ago)

View File

@@ -61,6 +61,8 @@ class User < ApplicationRecord
disable_post_tooltips
enable_recommended_posts
opt_out_mixpanel
no_flagging
no_feedback
)
include Danbooru::HasBitFlags

View File

@@ -101,6 +101,9 @@ class UserFeedback < ApplicationRecord
if !creator.is_gold?
errors[:creator] << "must be gold"
return false
elsif creator.no_feedback?
errors[:creator] << "cannot submit feedback"
return false
else
return true
end