Remove single alias/implication requests.

* Remove the single alias and implication request forms. From now
  on, bulk update requests are the only way to request aliases or
  implications.

* Remove the forum topic ID field from the bulk update request form.
  Instead, to attach a BUR to an existing topic you go to the topic then
  you click "Request alias/implication" at the top of the page.

* Update the bulk update request form to give better examples for the
  script format and to explain the difference between aliases and
  implications.
This commit is contained in:
evazion
2019-10-28 00:38:58 -05:00
parent b5a40aa233
commit dfbf4f3f0a
20 changed files with 48 additions and 418 deletions

View File

@@ -1,15 +1,4 @@
class TagAliasRequest
include ActiveModel::Validations
attr_reader :antecedent_name, :consequent_name, :reason, :skip_secondary_validations, :tag_alias, :forum_topic
validate :validate_tag_alias
validate :validate_forum_topic
def self.topic_title(antecedent_name, consequent_name)
"Tag alias: #{antecedent_name} -> #{consequent_name}"
end
def self.command_string(antecedent_name, consequent_name, id=nil)
if id
return "[ta:#{id}]"
@@ -17,68 +6,4 @@ class TagAliasRequest
"create alias [[#{antecedent_name}]] -> [[#{consequent_name}]]"
end
def initialize(attributes)
@antecedent_name = attributes[:antecedent_name].strip.tr(" ", "_")
@consequent_name = attributes[:consequent_name].strip.tr(" ", "_")
@reason = attributes[:reason]
self.skip_secondary_validations = attributes[:skip_secondary_validations]
end
def create
return false if invalid?
TagAlias.transaction do
@tag_alias = build_tag_alias
@tag_alias.save
@forum_topic = build_forum_topic(@tag_alias.id)
@forum_topic.save
@tag_alias.forum_topic_id = @forum_topic.id
@tag_alias.forum_post_id = @forum_topic.posts.first.id
@tag_alias.save
end
end
def build_tag_alias
x = TagAlias.new(
:antecedent_name => antecedent_name,
:consequent_name => consequent_name,
:skip_secondary_validations => skip_secondary_validations
)
x.status = "pending"
x
end
def build_forum_topic(tag_alias_id)
ForumTopic.new(
:title => TagAliasRequest.topic_title(antecedent_name, consequent_name),
:original_post_attributes => {
:body => TagAliasRequest.command_string(antecedent_name, consequent_name, tag_alias_id) + "\n\nReason: #{reason}"
},
:category_id => 1
)
end
def validate_tag_alias
ta = @tag_alias || build_tag_alias
if ta.invalid?
self.errors.add(:base, ta.errors.full_messages.join("; "))
return false
end
end
def validate_forum_topic
ft = @forum_topic || build_forum_topic(nil)
if ft.invalid?
self.errors.add(:base, ft.errors.full_messages.join("; "))
return false
end
end
def skip_secondary_validations=(v)
@skip_secondary_validations = v.to_s.truthy?
end
end

View File

@@ -1,15 +1,4 @@
class TagImplicationRequest
include ActiveModel::Validations
attr_reader :antecedent_name, :consequent_name, :reason, :tag_implication, :forum_topic, :skip_secondary_validations
validate :validate_tag_implication
validate :validate_forum_topic
def self.topic_title(antecedent_name, consequent_name)
"Tag implication: #{antecedent_name} -> #{consequent_name}"
end
def self.command_string(antecedent_name, consequent_name, id=nil)
if id
return "[ti:#{id}]"
@@ -17,68 +6,4 @@ class TagImplicationRequest
"create implication [[#{antecedent_name}]] -> [[#{consequent_name}]]"
end
def initialize(attributes)
@antecedent_name = attributes[:antecedent_name].strip.tr(" ", "_")
@consequent_name = attributes[:consequent_name].strip.tr(" ", "_")
@reason = attributes[:reason]
self.skip_secondary_validations = attributes[:skip_secondary_validations]
end
def create
return false if invalid?
TagImplication.transaction do
@tag_implication = build_tag_implication
@tag_implication.save
@forum_topic = build_forum_topic(@tag_implication.id)
@forum_topic.save
@tag_implication.forum_topic_id = @forum_topic.id
@tag_implication.forum_post_id = @forum_topic.posts.first.id
@tag_implication.save
end
end
def build_tag_implication
x = TagImplication.new(
:antecedent_name => antecedent_name,
:consequent_name => consequent_name,
:skip_secondary_validations => skip_secondary_validations
)
x.status = "pending"
x
end
def build_forum_topic(tag_implication_id)
ForumTopic.new(
:title => TagImplicationRequest.topic_title(antecedent_name, consequent_name),
:original_post_attributes => {
:body => TagImplicationRequest.command_string(antecedent_name, consequent_name, tag_implication_id) + "\n\nReason: #{reason}"
},
:category_id => 1
)
end
def validate_tag_implication
ti = @tag_implication || build_tag_implication
if ti.invalid?
self.errors.add(:base, ti.errors.full_messages.join("; "))
return false
end
end
def validate_forum_topic
ft = @forum_topic || build_forum_topic(nil)
if ft.invalid?
self.errors.add(:base, ft.errors.full_messages.join("; "))
return false
end
end
def skip_secondary_validations=(v)
@skip_secondary_validations = v.to_s.truthy?
end
end