[Cleanup] Remove no_feedback

This commit is contained in:
Earlopain 2022-03-16 15:32:24 +01:00
parent aa9739e961
commit 55443873a3
No known key found for this signature in database
GPG Key ID: 6CFB948E15246897
6 changed files with 6 additions and 41 deletions

View File

@ -1,6 +1,5 @@
class UserFeedbacksController < ApplicationController
before_action :moderator_only, :only => [:new, :edit, :create, :update, :destroy]
before_action :check_no_feedback, only: [:new, :edit, :create, :update, :destroy]
respond_to :html, :json
def new
@ -50,12 +49,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)
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, :old_replacements_beta
attr_reader :user, :promoter, :new_level, :options, :old_can_approve_posts, :old_can_upload_free, :old_no_flagging, :old_replacements_beta
def initialize(user, promoter, new_level, options = {})
@user = user
@ -14,7 +14,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?
@old_replacements_beta = user.replacements_beta?
user.level = new_level
@ -27,10 +26,6 @@ class UserPromotion
user.can_upload_free = options[:can_upload_free]
end
if options.has_key?(:no_feedback)
user.no_feedback = options[:no_feedback]
end
if options.has_key?(:no_flagging)
user.no_flagging = options[:no_flagging]
end
@ -66,7 +61,6 @@ class UserPromotion
flag_check(added, removed, "can_approve_posts", "approve posts")
flag_check(added, removed, "can_upload_free", "unlimited upload slots")
flag_check(added, removed, "no_flagging", "flag ban")
flag_check(added, removed, "no_feedback", "feedback_ban")
flag_check(added, removed, "replacements_beta", "replacements beta")
unless added.empty? && removed.empty?
@ -112,12 +106,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

View File

@ -29,6 +29,11 @@ class User < ApplicationRecord
# candidates for removal:
# - disable_cropped_thumbnails (enabled by 22)
# - has_saved_searches (removed in removal of saved searches)
# - no_feedback
# - show_avatars
# - blacklist_avatars
# - disable_mobile_gestures
# - disable_post_tooltips
BOOLEAN_ATTRIBUTES = %w(
show_avatars
blacklist_avatars

View File

@ -88,9 +88,6 @@ class UserFeedback < ApplicationRecord
if !creator.is_moderator?
errors.add(:creator, "must be moderator")
return false
elsif creator.no_feedback?
errors.add(:creator, "cannot submit feedback")
return false
else
return true
end

View File

@ -58,11 +58,6 @@
<%= select(:user, :no_flagging, [["Yes", true], ["No", false]]) %>
</div>
<div class="input">
<label for="user_no_feedback" class="optional">Banned From Giving Feedback</label>
<%= select(:user, :no_feedback, [["Yes", true], ["No", false]]) %>
</div>
<div class="input">
<label for="user_replacements_beta" class="optional">Replacements Beta</label>
<%= select(:user, :replacements_beta, [["Yes", true], ["No", false]]) %>

View File

@ -32,19 +32,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
@mod2 = FactoryBot.create(:moderator_user, no_feedback: true)
CurrentUser.user = @mod2
end
should "not validate" do
feedback = FactoryBot.build(:user_feedback, user: @mod)
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 has no permissions" do
privileged = FactoryBot.create(:privileged_user)