Commit f0260209045c7d14c0b016227dd521f878e646b7

Authored by Aurélio A. Heckert
1 parent 6c54d1c3

API Filter enterprises by location

Showing 1 changed file with 5 additions and 3 deletions   Show diff stats
lib/noosfero/api/v1/enterprises.rb
@@ -5,13 +5,14 @@ module Noosfero @@ -5,13 +5,14 @@ module Noosfero
5 before { authenticate! } 5 before { authenticate! }
6 6
7 resource :enterprises do 7 resource :enterprises do
8 -  
9 - # Collect comments from articles 8 +
  9 + # Collect enterprises from environment
10 # 10 #
11 # Parameters: 11 # Parameters:
12 # from - date where the search will begin. If nothing is passed the default date will be the date of the first article created 12 # from - date where the search will begin. If nothing is passed the default date will be the date of the first article created
13 # oldest - Collect the oldest comments from reference_id comment. If nothing is passed the newest comments are collected 13 # oldest - Collect the oldest comments from reference_id comment. If nothing is passed the newest comments are collected
14 # limit - amount of comments returned. The default value is 20 14 # limit - amount of comments returned. The default value is 20
  15 + # georef params - read `Profile.by_location` for more information.
15 # 16 #
16 # Example Request: 17 # Example Request:
17 # GET /enterprises?from=2013-04-04-14:41:43&until=2014-04-04-14:41:43&limit=10 18 # GET /enterprises?from=2013-04-04-14:41:43&until=2014-04-04-14:41:43&limit=10
@@ -19,6 +20,7 @@ module Noosfero @@ -19,6 +20,7 @@ module Noosfero
19 get do 20 get do
20 enterprises = select_filtered_collection_of(environment, 'enterprises', params) 21 enterprises = select_filtered_collection_of(environment, 'enterprises', params)
21 enterprises = enterprises.visible_for_person(current_person) 22 enterprises = enterprises.visible_for_person(current_person)
  23 + enterprises = enterprises.by_location(params) # Must be the last. May return Exception obj.
22 present enterprises, :with => Entities::Enterprise 24 present enterprises, :with => Entities::Enterprise
23 end 25 end
24 26
@@ -39,7 +41,7 @@ module Noosfero @@ -39,7 +41,7 @@ module Noosfero
39 get do 41 get do
40 person = environment.people.find(params[:person_id]) 42 person = environment.people.find(params[:person_id])
41 enterprises = select_filtered_collection_of(person, 'enterprises', params) 43 enterprises = select_filtered_collection_of(person, 'enterprises', params)
42 - enterprises = enterprises.visible 44 + enterprises = enterprises.visible.by_location(params)
43 present enterprises, :with => Entities::Enterprise 45 present enterprises, :with => Entities::Enterprise
44 end 46 end
45 47