Commit 6c8bd41f21bdbc1027ea3cf7f3e7fe22b1f9da11
Exists in
staging
and in
3 other branches
Merge branch 'angular_poc' into staging
Showing
3 changed files
with
35 additions
and
0 deletions
Show diff stats
lib/noosfero/api/api.rb
lib/noosfero/api/entities.rb
@@ -236,6 +236,15 @@ module Noosfero | @@ -236,6 +236,15 @@ module Noosfero | ||
236 | expose :name | 236 | expose :name |
237 | end | 237 | end |
238 | 238 | ||
239 | + class Activity < Entity | ||
240 | + root 'activities', 'activity' | ||
241 | + expose :id, :params, :verb, :created_at, :updated_at, :comments_count, :visible | ||
242 | + expose :user, :using => Profile | ||
243 | + expose :target do |activity, opts| | ||
244 | + type_map = {Profile => ::Profile, ArticleBase => ::Article}.find {|h| activity.target.kind_of?(h.last)} | ||
245 | + type_map.first.represent(activity.target) unless type_map.nil? | ||
246 | + end | ||
247 | + end | ||
239 | 248 | ||
240 | end | 249 | end |
241 | end | 250 | end |
@@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
1 | +module Noosfero | ||
2 | + module API | ||
3 | + module V1 | ||
4 | + class Activities < Grape::API | ||
5 | + before { authenticate! } | ||
6 | + | ||
7 | + resource :profiles do | ||
8 | + | ||
9 | + get ':id/activities' do | ||
10 | + profile = environment.profiles | ||
11 | + profile = profile.visible_for_person(current_person) if profile.respond_to?(:visible_for_person) | ||
12 | + profile = profile.find_by_id(params[:id]) | ||
13 | + activities = profile.activities.map(&:activity) | ||
14 | + present activities, :with => Entities::Activity, :current_person => current_person | ||
15 | + end | ||
16 | + | ||
17 | + get ':id/network_activities' do | ||
18 | + #TODO | ||
19 | + end | ||
20 | + | ||
21 | + end | ||
22 | + end | ||
23 | + end | ||
24 | + end | ||
25 | +end |