Skip to content

Commit

Permalink
specify what is missing if tag assignment failed
Browse files Browse the repository at this point in the history
  • Loading branch information
yrudman committed May 22, 2020
1 parent 786b234 commit b5a086b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/models/classification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,14 @@ def ns

def self.classify(obj, category_name, entry_name, is_request = true)
cat = Classification.lookup_by_name(category_name, obj.region_id)
unless cat.nil?
ent = cat.find_entry_by_name(entry_name, obj.region_id)
ent.assign_entry_to(obj, is_request) unless ent.nil? || obj.is_tagged_with?(ent.to_tag, :ns => "none")
end
raise "Tag category '#{category_name}' not found in region #{obj.region_id}" if cat.nil?

ent = cat.find_entry_by_name(entry_name, obj.region_id)
raise "Tag name '#{entry_name}' not found in region #{obj.region_id}" if ent.nil?

raise " Object already tagged with ':ns' set to 'none'" unless obj.is_tagged_with?(ent.to_tag, :ns => "none")

ent.assign_entry_to(obj, is_request)
end

def self.unclassify(obj, category_name, entry_name, is_request = true)
Expand Down

0 comments on commit b5a086b

Please sign in to comment.