BURs: remove ability to skip secondary validations.

Remove the ability to skip secondary validations when creating a BUR.
The only skippable validation that still existed was the requirement
that both tags in an implication must have wiki pages. It's now
mandatory to write wiki pages for tags before you can request an
implication. This doesn't apply to empty tags.
This commit is contained in:
evazion
2020-11-12 20:08:13 -06:00
parent 25cba710bf
commit 7f90bc4216
13 changed files with 38 additions and 65 deletions

View File

@@ -192,7 +192,7 @@ class Artist < ApplicationRecord
# potential race condition but unlikely
unless TagImplication.where(:antecedent_name => name, :consequent_name => "banned_artist").exists?
tag_implication = TagImplication.create!(antecedent_name: name, consequent_name: "banned_artist", skip_secondary_validations: true, creator: banner)
tag_implication = TagImplication.create!(antecedent_name: name, consequent_name: "banned_artist", creator: banner)
tag_implication.approve!(banner)
end

View File

@@ -1,7 +1,6 @@
class BulkUpdateRequest < ApplicationRecord
attr_accessor :title
attr_accessor :reason
attr_reader :skip_secondary_validations
belongs_to :user
belongs_to :forum_topic, optional: true
@@ -75,7 +74,7 @@ class BulkUpdateRequest < ApplicationRecord
transaction do
CurrentUser.scoped(approver) do
processor.process!(approver)
update!(status: "approved", approver: approver, skip_secondary_validations: true)
update!(status: "approved", approver: approver)
forum_updater.update("The #{bulk_update_request_link} (forum ##{forum_post.id}) has been approved by @#{approver.name}.")
end
end
@@ -120,10 +119,6 @@ class BulkUpdateRequest < ApplicationRecord
self.tags = processor.affected_tags
end
def skip_secondary_validations=(v)
@skip_secondary_validations = v.to_s.truthy?
end
def processor
@processor ||= BulkUpdateRequestProcessor.new(self)
end

View File

@@ -8,7 +8,6 @@ class TagImplication < TagRelationship
validate :absence_of_transitive_relation
validate :antecedent_is_not_aliased
validate :consequent_is_not_aliased
validate :wiki_pages_present, on: :create, unless: :skip_secondary_validations
module DescendantMethods
extend ActiveSupport::Concern
@@ -107,16 +106,6 @@ class TagImplication < TagRelationship
errors[:base] << "Consequent tag must not be aliased to another tag"
end
end
def wiki_pages_present
if consequent_wiki.blank?
errors[:base] << "The #{consequent_name} tag needs a corresponding wiki page"
end
if antecedent_wiki.blank?
errors[:base] << "The #{antecedent_name} tag needs a corresponding wiki page"
end
end
end
module ApprovalMethods

View File

@@ -4,8 +4,6 @@ class TagRelationship < ApplicationRecord
EXPIRY = 60
EXPIRY_WARNING = 55
attr_accessor :skip_secondary_validations
belongs_to :creator, class_name: "User"
belongs_to :approver, class_name: "User", optional: true
belongs_to :forum_post, optional: true