added approval step for aliases/implications
This commit is contained in:
@@ -11,7 +11,7 @@ class TagAlias < ActiveRecord::Base
|
||||
def self.to_aliased(names)
|
||||
alias_hash = Cache.get_multi(names.flatten, "ta") do |name|
|
||||
ta = TagAlias.find_by_antecedent_name(name)
|
||||
if ta
|
||||
if ta && ta.is_active?
|
||||
ta.consequent_name
|
||||
else
|
||||
name
|
||||
@@ -29,6 +29,14 @@ class TagAlias < ActiveRecord::Base
|
||||
update_column(:status, "error: #{e}")
|
||||
end
|
||||
|
||||
def is_pending?
|
||||
status == "pending"
|
||||
end
|
||||
|
||||
def is_active?
|
||||
status == "active"
|
||||
end
|
||||
|
||||
def initialize_creator
|
||||
self.creator_id = CurrentUser.user.id
|
||||
self.creator_ip_addr = CurrentUser.ip_addr
|
||||
|
||||
@@ -13,7 +13,7 @@ class TagImplication < ActiveRecord::Base
|
||||
module ClassMethods
|
||||
# assumes names are normalized
|
||||
def with_descendants(names)
|
||||
(names + where("antecedent_name in (?)", names).map(&:descendant_names_array)).flatten.uniq
|
||||
(names + where("antecedent_name in (?) and status = ?", names, "active").map(&:descendant_names_array)).flatten.uniq
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,7 +24,7 @@ class TagImplication < ActiveRecord::Base
|
||||
|
||||
until children.empty?
|
||||
all.concat(children)
|
||||
children = self.class.where(["antecedent_name IN (?)", children]).all.map(&:consequent_name)
|
||||
children = self.class.where(["antecedent_name IN (?) and status = ?", children, "active"]).all.map(&:consequent_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -103,6 +103,14 @@ class TagImplication < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def is_pending?
|
||||
status == "pending"
|
||||
end
|
||||
|
||||
def is_active?
|
||||
status == "active"
|
||||
end
|
||||
|
||||
def reload(options = {})
|
||||
super
|
||||
clear_parent_cache
|
||||
|
||||
Reference in New Issue
Block a user