diff --git a/app/repositories/orient_db/collection_repository.rb b/app/repositories/orient_db/collection_repository.rb index 13a5200fe1c2ce7c07611d45834de3c747049f21..073877d3680d69b83f4ac01de07da5736be28e37 100644 --- a/app/repositories/orient_db/collection_repository.rb +++ b/app/repositories/orient_db/collection_repository.rb @@ -81,9 +81,11 @@ module OrientDb end # return owner of collection rid - def owner(collection_id) - edge = get_edges("BelongsTo", "out", collection_id).first + def owner(collection) + collection_id = collection + collection_id = collection.id if collection.class == Collection + edge = get_edges("BelongsTo", "out", collection_id).first owner = get_by_rid(edge["in"]) if owner['@class'] == "User" @@ -99,7 +101,7 @@ module OrientDb return false if collection.blank? || user.blank? if collection.owner.class == Institution - institution_repository.associated_with(user).each do |institution| + user.institutions.each do |institution| return true if institution.id == collection.owner.id end else @@ -111,7 +113,7 @@ module OrientDb end def change_privacy(collection, privacy) - update_property(collection, 'privacy', privacy) if accepted_privacies(privacy) + update_property(collection, 'privacy', privacy) if privacy_accepted?(privacy) end private @@ -120,7 +122,7 @@ module OrientDb ['privacy'] end - def accepted_privacies(privacy) + def privacy_accepted?(privacy) ['private', 'public'].include? privacy end