users: remove no_flagging and no_feedback permissions.

This commit is contained in:
evazion
2019-12-24 10:24:15 -06:00
parent 939c168fe9
commit 7694be9cb3
8 changed files with 5 additions and 82 deletions

View File

@@ -1,6 +1,5 @@
class UserFeedbacksController < ApplicationController
before_action :gold_only, :only => [:new, :edit, :create, :update]
before_action :check_no_feedback, only: [:new, :edit, :create, :update]
respond_to :html, :xml, :json, :js
def new
@@ -42,12 +41,6 @@ class UserFeedbacksController < ApplicationController
raise User::PrivilegeError unless user_feedback.editable_by?(CurrentUser.user)
end
def check_no_feedback
if CurrentUser.no_feedback?
raise User::PrivilegeError
end
end
def user_feedback_params(context, user_feedback = nil)
permitted_params = %i[body category]
permitted_params += %i[user_id user_name] if context == :create

View File

@@ -1,5 +1,5 @@
class UserPromotion
attr_reader :user, :promoter, :new_level, :options, :old_can_approve_posts, :old_can_upload_free, :old_no_flagging, :old_no_feedback
attr_reader :user, :promoter, :new_level, :options, :old_can_approve_posts, :old_can_upload_free
def initialize(user, promoter, new_level, options = {})
@user = user
@@ -13,8 +13,6 @@ class UserPromotion
@old_can_approve_posts = user.can_approve_posts?
@old_can_upload_free = user.can_upload_free?
@old_no_flagging = user.no_flagging?
@old_no_feedback = user.no_feedback?
user.level = new_level
@@ -26,14 +24,6 @@ class UserPromotion
user.can_upload_free = options[:can_upload_free]
end
if options.key?(:no_feedback)
user.no_feedback = options[:no_feedback]
end
if options.key?(:no_flagging)
user.no_flagging = options[:no_flagging]
end
user.inviter_id = promoter.id
create_user_feedback unless options[:is_upgrade]
@@ -54,14 +44,6 @@ class UserPromotion
ModAction.log("\"#{promoter.name}\":/users/#{promoter.id} changed unlimited upload privileges for \"#{user.name}\":/users/#{user.id} from #{old_can_upload_free} to [b]#{user.can_upload_free?}[/b]", :user_upload_privilege)
end
if old_no_flagging != user.no_flagging?
ModAction.log("\"#{promoter.name}\":/users/#{promoter.id} changed banned from flagging for \"#{user.name}\":/users/#{user.id} from #{old_no_flagging} to [b]#{user.no_flagging?}[/b]", :user_approval_privilege)
end
if old_no_feedback != user.no_feedback?
ModAction.log("\"#{promoter.name}\":/users/#{promoter.id} changed banned from feedback for \"#{user.name}\":/users/#{user.id} from #{old_no_feedback} to [b]#{user.no_feedback?}[/b]", :user_approval_privilege)
end
if user.level_changed?
category = options[:is_upgrade] ? :user_account_upgrade : :user_level_change
ModAction.log(%{"#{user.name}":/users/#{user.id} level changed #{user.level_string_was} -> #{user.level_string}}, category)
@@ -102,18 +84,6 @@ class UserPromotion
messages << "You lost the ability to upload posts without limit."
end
if user.no_feedback? && !old_no_feedback
messages << "You lost the ability to give user feedback."
elsif !user.no_feedback? && old_no_feedback
messages << "You gained the ability to give user feedback."
end
if user.no_flagging? && !old_no_flagging
messages << "You lost the ability to flag posts."
elsif !user.no_flagging? && old_no_flagging
messages << "You gained the ability to flag posts."
end
messages.join("\n")
end

View File

@@ -122,10 +122,6 @@ 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 && creator.post_flags.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

@@ -62,8 +62,6 @@ class UserFeedback < ApplicationRecord
def creator_is_gold
if !creator.is_gold?
errors[:creator] << "must be gold"
elsif creator.no_feedback?
errors[:creator] << "cannot submit feedback"
end
end

View File

@@ -6,8 +6,6 @@
<%= f.input :level, collection: User.level_hash.to_a, selected: @user.level %>
<%= f.input :can_upload_free, label: "Unrestricted Uploads", as: :boolean, selected: @user.can_upload_free %>
<%= f.input :can_approve_posts, label: "Approve Posts", as: :boolean, selected: @user.can_approve_posts %>
<%= f.input :no_flagging, label: "Banned From Flagging", as: :boolean, selected: @user.no_flagging %>
<%= f.input :no_feedback, label: "Banned From Giving Feedback", as: :boolean, selected: @user.no_feedback %>
<%= f.submit "Update" %>
<% end %>
</div>

View File

@@ -34,12 +34,10 @@
<% if post.is_status_locked? %>
<li id="post-option-status-locked">Status locked</li>
<% else %>
<% unless CurrentUser.no_flagging? %>
<% if !post.is_deleted? && !post.is_pending? && !post.is_flagged? %>
<li id="post-option-flag"><%= link_to "Flag", new_post_flag_path(post_flag: { post_id: post.id }), remote: true %></li>
<% elsif post.is_flagged? || post.is_deleted? %>
<li id="post-option-appeal"><%= link_to "Appeal", new_post_appeal_path(post_appeal: { post_id: post.id }), remote: true %></li>
<% end %>
<% if !post.is_deleted? && !post.is_pending? && !post.is_flagged? %>
<li id="post-option-flag"><%= link_to "Flag", new_post_flag_path(post_flag: { post_id: post.id }), remote: true %></li>
<% elsif post.is_flagged? || post.is_deleted? %>
<li id="post-option-appeal"><%= link_to "Appeal", new_post_appeal_path(post_appeal: { post_id: post.id }), remote: true %></li>
<% end %>
<% if CurrentUser.can_approve_posts? %>

View File

@@ -166,22 +166,5 @@ class PostFlagTest < ActiveSupport::TestCase
end
end
end
context "a user with no_flag=true" do
setup do
travel_to(2.weeks.ago) do
@bob = create(:user, no_flagging: true)
end
end
should "not be able to flag more than 1 post in 24 hours" do
@post_flag = PostFlag.new(post: @post, reason: "aaa", is_resolved: false)
@post_flag.expects(:flag_count_for_creator).returns(1)
assert_difference("PostFlag.count", 0) do
as(@bob) { @post_flag.save }
end
assert_equal(["You cannot flag posts"], @post_flag.errors.full_messages.grep(/cannot flag posts/))
end
end
end
end

View File

@@ -37,19 +37,6 @@ class UserFeedbackTest < ActiveSupport::TestCase
assert_equal(["You cannot submit feedback for yourself"], feedback.errors.full_messages)
end
context "with a no_feedback user" do
setup do
@gold_user = FactoryBot.create(:gold_user, no_feedback: true)
CurrentUser.user = @gold_user
end
should "not validate" do
feedback = FactoryBot.build(:user_feedback, :user => @gold_user)
feedback.save
assert_equal(["You cannot submit feedback"], feedback.errors.full_messages.grep(/^You cannot submit feedback$/))
end
end
should "not validate if the creator is not gold" do
user = FactoryBot.create(:user)
gold = FactoryBot.create(:gold_user)