diff --git a/app/models/profile.rb b/app/models/profile.rb index 9633376..3fe3ef9 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -421,6 +421,10 @@ class Profile < ActiveRecord::Base !profiles.exists? end + def self.visible_for_person(person) + self.all + end + validates_presence_of :identifier, :name validates_length_of :nickname, :maximum => 16, :allow_nil => true validate :valid_template diff --git a/lib/noosfero/api/v1/people.rb b/lib/noosfero/api/v1/people.rb index 92ca938..ec33653 100644 --- a/lib/noosfero/api/v1/people.rb +++ b/lib/noosfero/api/v1/people.rb @@ -105,6 +105,19 @@ module Noosfero present output end end + + resource :profiles do + segment '/:profile_id' do + resource :members do + get do + profile = environment.profiles.find_by_id(params[:profile_id]) + members = profile.members + present members, :with => Entities::Person, :current_person => current_person + end + end + end + end + end end end diff --git a/lib/noosfero/api/v1/profiles.rb b/lib/noosfero/api/v1/profiles.rb index e203070..302fd7a 100644 --- a/lib/noosfero/api/v1/profiles.rb +++ b/lib/noosfero/api/v1/profiles.rb @@ -8,13 +8,15 @@ module Noosfero get do profiles = select_filtered_collection_of(environment, 'profiles', params) - profiles = profiles.visible_for_person(current_person) if profiles.respond_to?(:visible_for_person) + profiles = profiles.visible_for_person(current_person) profiles = profiles.by_location(params) # Must be the last. May return Exception obj. present profiles, :with => Entities::Profile, :current_person => current_person end get ':id' do - profile = environment.profiles.visible_for_person(current_person).find_by_id(params[:id]) + profiles = environment.profiles + profiles = profiles.visible_for_person(current_person) + profile = profiles.find_by_id(params[:id]) present profile, :with => Entities::Profile, :current_person => current_person end end -- libgit2 0.21.2