Commit f0260209045c7d14c0b016227dd521f878e646b7
1 parent
6c54d1c3
Exists in
api_tasks
and in
4 other branches
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 | 5 | before { authenticate! } |
6 | 6 | |
7 | 7 | resource :enterprises do |
8 | - | |
9 | - # Collect comments from articles | |
8 | + | |
9 | + # Collect enterprises from environment | |
10 | 10 | # |
11 | 11 | # Parameters: |
12 | 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 | 13 | # oldest - Collect the oldest comments from reference_id comment. If nothing is passed the newest comments are collected |
14 | 14 | # limit - amount of comments returned. The default value is 20 |
15 | + # georef params - read `Profile.by_location` for more information. | |
15 | 16 | # |
16 | 17 | # Example Request: |
17 | 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 | 20 | get do |
20 | 21 | enterprises = select_filtered_collection_of(environment, 'enterprises', params) |
21 | 22 | enterprises = enterprises.visible_for_person(current_person) |
23 | + enterprises = enterprises.by_location(params) # Must be the last. May return Exception obj. | |
22 | 24 | present enterprises, :with => Entities::Enterprise |
23 | 25 | end |
24 | 26 | |
... | ... | @@ -39,7 +41,7 @@ module Noosfero |
39 | 41 | get do |
40 | 42 | person = environment.people.find(params[:person_id]) |
41 | 43 | enterprises = select_filtered_collection_of(person, 'enterprises', params) |
42 | - enterprises = enterprises.visible | |
44 | + enterprises = enterprises.visible.by_location(params) | |
43 | 45 | present enterprises, :with => Entities::Enterprise |
44 | 46 | end |
45 | 47 | ... | ... |