From f0260209045c7d14c0b016227dd521f878e646b7 Mon Sep 17 00:00:00 2001 From: Aurélio A. Heckert Date: Sat, 13 Jun 2015 01:28:16 +0000 Subject: [PATCH] API Filter enterprises by location --- lib/noosfero/api/v1/enterprises.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/noosfero/api/v1/enterprises.rb b/lib/noosfero/api/v1/enterprises.rb index 07d9f41..6e267c8 100644 --- a/lib/noosfero/api/v1/enterprises.rb +++ b/lib/noosfero/api/v1/enterprises.rb @@ -5,13 +5,14 @@ module Noosfero before { authenticate! } resource :enterprises do - - # Collect comments from articles + + # Collect enterprises from environment # # Parameters: # from - date where the search will begin. If nothing is passed the default date will be the date of the first article created # oldest - Collect the oldest comments from reference_id comment. If nothing is passed the newest comments are collected # limit - amount of comments returned. The default value is 20 + # georef params - read `Profile.by_location` for more information. # # Example Request: # GET /enterprises?from=2013-04-04-14:41:43&until=2014-04-04-14:41:43&limit=10 @@ -19,6 +20,7 @@ module Noosfero get do enterprises = select_filtered_collection_of(environment, 'enterprises', params) enterprises = enterprises.visible_for_person(current_person) + enterprises = enterprises.by_location(params) # Must be the last. May return Exception obj. present enterprises, :with => Entities::Enterprise end @@ -39,7 +41,7 @@ module Noosfero get do person = environment.people.find(params[:person_id]) enterprises = select_filtered_collection_of(person, 'enterprises', params) - enterprises = enterprises.visible + enterprises = enterprises.visible.by_location(params) present enterprises, :with => Entities::Enterprise end -- libgit2 0.21.2