dynamic requests: handle deleted/processing/queued statuses (#3824)
Fix bug where [ta:1234] didn't render if the request's status was 'deleted', 'queued', or 'processing'.
This commit is contained in:
@@ -9,14 +9,18 @@ module ForumTopicsHelper
|
|||||||
|
|
||||||
def tag_request_message(obj)
|
def tag_request_message(obj)
|
||||||
if obj.is_a?(TagRelationship)
|
if obj.is_a?(TagRelationship)
|
||||||
if obj.is_active?
|
if obj.is_approved?
|
||||||
return "The #{obj.relationship} ##{obj.id} [[#{obj.antecedent_name}]] -> [[#{obj.consequent_name}]] is active."
|
return "The #{obj.relationship} ##{obj.id} [[#{obj.antecedent_name}]] -> [[#{obj.consequent_name}]] has been approved."
|
||||||
elsif obj.is_retired?
|
elsif obj.is_retired?
|
||||||
return "The #{obj.relationship} ##{obj.id} [[#{obj.antecedent_name}]] -> [[#{obj.consequent_name}]] has been retired"
|
return "The #{obj.relationship} ##{obj.id} [[#{obj.antecedent_name}]] -> [[#{obj.consequent_name}]] has been retired."
|
||||||
|
elsif obj.is_deleted?
|
||||||
|
return "The #{obj.relationship} ##{obj.id} [[#{obj.antecedent_name}]] -> [[#{obj.consequent_name}]] has been rejected."
|
||||||
elsif obj.is_pending?
|
elsif obj.is_pending?
|
||||||
return "The #{obj.relationship} ##{obj.id} [[#{obj.antecedent_name}]] -> [[#{obj.consequent_name}]] is pending approval."
|
return "The #{obj.relationship} ##{obj.id} [[#{obj.antecedent_name}]] -> [[#{obj.consequent_name}]] is pending approval."
|
||||||
elsif obj.is_errored?
|
elsif obj.is_errored?
|
||||||
return "The #{obj.relationship} ##{obj.id} [[#{obj.antecedent_name}]] -> [[#{obj.consequent_name}]] (#{relationship} failed during processing."
|
return "The #{obj.relationship} ##{obj.id} [[#{obj.antecedent_name}]] -> [[#{obj.consequent_name}]] (#{relationship} failed during processing."
|
||||||
|
else # should never happen
|
||||||
|
return "The #{obj.relationship} ##{obj.id} [[#{obj.antecedent_name}]] -> [[#{obj.consequent_name}]] has an unknown status."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -38,12 +42,7 @@ module ForumTopicsHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def parse_embedded_tag_request_text(text)
|
def parse_embedded_tag_request_text(text)
|
||||||
# for dev mode, prime these
|
[TagAlias, TagImplication, BulkUpdateRequest].each do |tag_request|
|
||||||
if Rails.env.development?
|
|
||||||
[TagAlias, TagImplication]
|
|
||||||
end
|
|
||||||
|
|
||||||
[*TagRelationship.subclasses, BulkUpdateRequest].each do |tag_request|
|
|
||||||
text.gsub!(tag_request.embedded_pattern) do |match|
|
text.gsub!(tag_request.embedded_pattern) do |match|
|
||||||
begin
|
begin
|
||||||
obj = tag_request.find($~[:id])
|
obj = tag_request.find($~[:id])
|
||||||
|
|||||||
@@ -43,10 +43,18 @@ class TagRelationship < ApplicationRecord
|
|||||||
self.consequent_name = consequent_name.mb_chars.downcase.tr(" ", "_")
|
self.consequent_name = consequent_name.mb_chars.downcase.tr(" ", "_")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_approved?
|
||||||
|
status.in?(%w[active processing queued])
|
||||||
|
end
|
||||||
|
|
||||||
def is_retired?
|
def is_retired?
|
||||||
status == "retired"
|
status == "retired"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_deleted?
|
||||||
|
status == "deleted"
|
||||||
|
end
|
||||||
|
|
||||||
def is_pending?
|
def is_pending?
|
||||||
status == "pending"
|
status == "pending"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user