Skip to content

Commit

Permalink
Merge pull request #748 from datacite/issue-1260
Browse files Browse the repository at this point in the history
Issue #1260 - Fabrica is not showing assigned Roles to contac…
  • Loading branch information
svogt0511 authored Jul 16, 2021
2 parents 5408ea1 + 8947d6e commit b9add4b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions app/controllers/contacts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,16 @@ def set_provider_contacts
# Make sure no other contact with this provider claims these roles.
@contact.provider.contacts.each do | contact |
if !@contact.is_me?(contact)
if contact.remove_roles!(@contact.role_name)
if contact.remove_roles!(Array.wrap(@contact.role_name))
contact.update_attribute("role_name", contact.role_name)
end
end
end

end
end

def remove_provider_contacts
@contact.role_name.each do | role |
Array.wrap(@contact.role_name).each do | role |
if @contact.has_provider_role?(role)
@contact.set_provider_role(role, nil)
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/contact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,12 @@ def self.roles
end

def has_role?(role = "")
role_name.include?(role)
Array.wrap(role_name).include?(role)
end

def remove_roles!(roles = [])
roles.each do | role |
role_name.delete(role)
Array.wrap(role_name).delete(role)
end
self.changed?
end
Expand Down

0 comments on commit b9add4b

Please sign in to comment.