added approval step for aliases/implications

This commit is contained in:
albert
2011-10-23 18:50:18 -04:00
parent 34ae712be0
commit f94b65f5d5
11 changed files with 69 additions and 18 deletions

View File

@@ -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

View File

@@ -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