diff --git a/app/controllers/user_feedbacks_controller.rb b/app/controllers/user_feedbacks_controller.rb index da811f23e..dfd9b94c9 100644 --- a/app/controllers/user_feedbacks_controller.rb +++ b/app/controllers/user_feedbacks_controller.rb @@ -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 diff --git a/app/logical/user_promotion.rb b/app/logical/user_promotion.rb index f5fe9a95f..06695fa6a 100644 --- a/app/logical/user_promotion.rb +++ b/app/logical/user_promotion.rb @@ -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 diff --git a/app/models/post_flag.rb b/app/models/post_flag.rb index 55395244b..e99affea4 100644 --- a/app/models/post_flag.rb +++ b/app/models/post_flag.rb @@ -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) diff --git a/app/models/user_feedback.rb b/app/models/user_feedback.rb index 2f2e859cd..f90a99fe7 100644 --- a/app/models/user_feedback.rb +++ b/app/models/user_feedback.rb @@ -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 diff --git a/app/views/admin/users/edit.html.erb b/app/views/admin/users/edit.html.erb index 6e5ce9595..caad5eef8 100644 --- a/app/views/admin/users/edit.html.erb +++ b/app/views/admin/users/edit.html.erb @@ -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 %> diff --git a/app/views/posts/partials/show/_options.html.erb b/app/views/posts/partials/show/_options.html.erb index 00a87637f..23187f262 100644 --- a/app/views/posts/partials/show/_options.html.erb +++ b/app/views/posts/partials/show/_options.html.erb @@ -34,12 +34,10 @@ <% if post.is_status_locked? %>
  • Status locked
  • <% else %> - <% unless CurrentUser.no_flagging? %> - <% if !post.is_deleted? && !post.is_pending? && !post.is_flagged? %> -
  • <%= link_to "Flag", new_post_flag_path(post_flag: { post_id: post.id }), remote: true %>
  • - <% elsif post.is_flagged? || post.is_deleted? %> -
  • <%= link_to "Appeal", new_post_appeal_path(post_appeal: { post_id: post.id }), remote: true %>
  • - <% end %> + <% if !post.is_deleted? && !post.is_pending? && !post.is_flagged? %> +
  • <%= link_to "Flag", new_post_flag_path(post_flag: { post_id: post.id }), remote: true %>
  • + <% elsif post.is_flagged? || post.is_deleted? %> +
  • <%= link_to "Appeal", new_post_appeal_path(post_appeal: { post_id: post.id }), remote: true %>
  • <% end %> <% if CurrentUser.can_approve_posts? %> diff --git a/test/unit/post_flag_test.rb b/test/unit/post_flag_test.rb index 090597e1a..b4878e2cc 100644 --- a/test/unit/post_flag_test.rb +++ b/test/unit/post_flag_test.rb @@ -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 diff --git a/test/unit/user_feedback_test.rb b/test/unit/user_feedback_test.rb index fe06b0920..86463f3a4 100644 --- a/test/unit/user_feedback_test.rb +++ b/test/unit/user_feedback_test.rb @@ -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)