aliases/implications: refactor to share approve/reject messages.
This commit is contained in:
@@ -43,25 +43,9 @@ class TagAlias < TagRelationship
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def approval_message
|
|
||||||
"The tag alias [[#{antecedent_name}]] -> [[#{consequent_name}]] (alias ##{id}) has been approved."
|
|
||||||
end
|
|
||||||
|
|
||||||
def failure_message(e = nil)
|
|
||||||
"The tag alias [[#{antecedent_name}]] -> [[#{consequent_name}]] (alias ##{id}) failed during processing. Reason: #{e}"
|
|
||||||
end
|
|
||||||
|
|
||||||
def reject_message
|
|
||||||
"The tag alias [[#{antecedent_name}]] -> [[#{consequent_name}]] (alias ##{id}) has been rejected."
|
|
||||||
end
|
|
||||||
|
|
||||||
def conflict_message
|
def conflict_message
|
||||||
"The tag alias [[#{antecedent_name}]] -> [[#{consequent_name}]] (alias ##{id}) has conflicting wiki pages. [[#{consequent_name}]] should be updated to include information from [[#{antecedent_name}]] if necessary."
|
"The tag alias [[#{antecedent_name}]] -> [[#{consequent_name}]] (alias ##{id}) has conflicting wiki pages. [[#{consequent_name}]] should be updated to include information from [[#{antecedent_name}]] if necessary."
|
||||||
end
|
end
|
||||||
|
|
||||||
def date_timestamp
|
|
||||||
Time.now.strftime("%Y-%m-%d")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module ForumMethods
|
module ForumMethods
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ class TagImplication < TagRelationship
|
|||||||
update_posts
|
update_posts
|
||||||
update({ :status => "active" }, :as => CurrentUser.role)
|
update({ :status => "active" }, :as => CurrentUser.role)
|
||||||
update_descendant_names_for_parents
|
update_descendant_names_for_parents
|
||||||
forum_updater.update("The tag implication #{antecedent_name} -> #{consequent_name} has been approved.", "APPROVED") if update_topic
|
forum_updater.update(approval_message, "APPROVED") if update_topic
|
||||||
end
|
end
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
if tries < 5
|
if tries < 5
|
||||||
@@ -157,7 +157,7 @@ class TagImplication < TagRelationship
|
|||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
|
|
||||||
forum_updater.update("The tag implication #{antecedent_name} -> #{consequent_name} failed during processing. Reason: #{e}", "FAILED") if update_topic
|
forum_updater.update(failure_message(e), "FAILED") if update_topic
|
||||||
update({ :status => "error: #{e}" }, :as => CurrentUser.role)
|
update({ :status => "error: #{e}" }, :as => CurrentUser.role)
|
||||||
|
|
||||||
if Rails.env.production?
|
if Rails.env.production?
|
||||||
@@ -186,7 +186,7 @@ class TagImplication < TagRelationship
|
|||||||
|
|
||||||
def reject!
|
def reject!
|
||||||
update({ :status => "deleted", }, :as => CurrentUser.role)
|
update({ :status => "deleted", }, :as => CurrentUser.role)
|
||||||
forum_updater.update("The tag implication #{antecedent_name} -> #{consequent_name} has been rejected.", "REJECTED")
|
forum_updater.update(reject_message, "REJECTED")
|
||||||
destroy
|
destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -210,10 +210,6 @@ class TagImplication < TagRelationship
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def date_timestamp
|
|
||||||
Time.now.strftime("%Y-%m-%d")
|
|
||||||
end
|
|
||||||
|
|
||||||
def forum_updater
|
def forum_updater
|
||||||
@forum_updater ||= begin
|
@forum_updater ||= begin
|
||||||
post = if forum_topic
|
post = if forum_topic
|
||||||
|
|||||||
@@ -117,5 +117,29 @@ class TagRelationship < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module MessageMethods
|
||||||
|
def relationship
|
||||||
|
# "TagAlias" -> "tag alias", "TagImplication" -> "tag implication"
|
||||||
|
self.class.name.underscore.tr("_", " ")
|
||||||
|
end
|
||||||
|
|
||||||
|
def approval_message
|
||||||
|
"The #{relationship} [[#{antecedent_name}]] -> [[#{consequent_name}]] has been approved."
|
||||||
|
end
|
||||||
|
|
||||||
|
def failure_message(e = nil)
|
||||||
|
"The #{relationship} [[#{antecedent_name}]] -> [[#{consequent_name}]] failed during processing. Reason: #{e}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def reject_message
|
||||||
|
"The #{relationship} [[#{antecedent_name}]] -> [[#{consequent_name}]] has been rejected."
|
||||||
|
end
|
||||||
|
|
||||||
|
def date_timestamp
|
||||||
|
Time.now.strftime("%Y-%m-%d")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
extend SearchMethods
|
extend SearchMethods
|
||||||
|
include MessageMethods
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user