Skip to content

Commit

Permalink
Merge pull request #13963 from abellotti/api_reinstating_needed_taggi…
Browse files Browse the repository at this point in the history
…ng_code

Reverting PR# 13684
  • Loading branch information
abellotti authored Feb 17, 2017
2 parents e464984 + ece7d53 commit ee3e7b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/controllers/api/subcollections/policies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def parse_policy(data, collection, klass)
guid = data["guid"]
return klass.find_by(:guid => guid) if guid.present?

{}
href = data["href"]
href =~ %r{^.*/#{collection}/#{BaseController::CID_OR_ID_MATCHER}$} ? klass.find(from_cid(href.split('/').last)) : {}
end

def policy_subcollection_action(ctype, policy)
Expand Down
11 changes: 10 additions & 1 deletion app/controllers/api/subcollections/tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,16 @@ def parse_tag(data)
return {:category => category, :name => name} if category && name
return tag_path_to_spec(name) if name && name[0] == '/'

{}
parse_tag_from_href(data)
end

def parse_tag_from_href(data)
href = data["href"]
tag = if href && href.match(%r{^.*/tags/#{BaseController::CID_OR_ID_MATCHER}$})
klass = collection_class(:tags)
klass.find(from_cid(href.split('/').last))
end
tag.present? ? tag_path_to_spec(tag.name).merge(:id => tag.id) : {}
end

def tag_path_to_spec(path)
Expand Down

0 comments on commit ee3e7b9

Please sign in to comment.