fixes #3824: render tag requests dynamically in the forum post

refactoring
This commit is contained in:
Albert Yi
2019-01-02 17:27:01 -08:00
parent 5c54c61d65
commit 8b0af19f7f
18 changed files with 171 additions and 25 deletions

View File

@@ -5,6 +5,7 @@ class ForumUpdater
@forum_topic = forum_topic
@forum_post = options[:forum_post]
@expected_title = options[:expected_title]
@skip_update = options[:skip_update]
end
def update(message, title_tag = nil)
@@ -31,6 +32,7 @@ class ForumUpdater
end
def update_post(body)
return if @skip_update
forum_post.update(body: "#{forum_post.body}\n\nEDIT: #{body}", skip_mention_notifications: true)
end
end

View File

@@ -10,7 +10,11 @@ class TagAliasRequest
"Tag alias: #{antecedent_name} -> #{consequent_name}"
end
def self.command_string(antecedent_name, consequent_name)
def self.command_string(antecedent_name, consequent_name, id=nil)
if id
return "[ta:#{id}]"
end
"create alias [[#{antecedent_name}]] -> [[#{consequent_name}]]"
end
@@ -51,7 +55,7 @@ class TagAliasRequest
ForumTopic.new(
:title => TagAliasRequest.topic_title(antecedent_name, consequent_name),
:original_post_attributes => {
:body => TagAliasRequest.command_string(antecedent_name, consequent_name) + "\n\n\"Link to alias\":/tag_aliases?search[id]=#{tag_alias_id}\n\n#{reason}"
:body => TagAliasRequest.command_string(antecedent_name, consequent_name, tag_alias_id) + "\n\nReason: #{reason}"
},
:category_id => 1
)

View File

@@ -10,7 +10,11 @@ class TagImplicationRequest
"Tag implication: #{antecedent_name} -> #{consequent_name}"
end
def self.command_string(antecedent_name, consequent_name)
def self.command_string(antecedent_name, consequent_name, id=nil)
if id
return "[ti:#{id}]"
end
"create implication [[#{antecedent_name}]] -> [[#{consequent_name}]]"
end
@@ -51,7 +55,7 @@ class TagImplicationRequest
ForumTopic.new(
:title => TagImplicationRequest.topic_title(antecedent_name, consequent_name),
:original_post_attributes => {
:body => TagImplicationRequest.command_string(antecedent_name, consequent_name) + "\n\n\"Link to implication\":/tag_implications?search[id]=#{tag_implication_id}\n\n#{reason}"
:body => TagImplicationRequest.command_string(antecedent_name, consequent_name, tag_implication_id) + "\n\nReason: #{reason}"
},
:category_id => 1
)