Commit a7df1a640a6fdde6003e15c69045c9c6516a142b
Exists in
staging
Merge branch 'angular_poc' into staging
Showing
5 changed files
with
50 additions
and
1 deletions
Show diff stats
lib/noosfero/api/api.rb
lib/noosfero/api/entities.rb
@@ -79,6 +79,18 @@ module Noosfero | @@ -79,6 +79,18 @@ module Noosfero | ||
79 | expose :parent_id | 79 | expose :parent_id |
80 | end | 80 | end |
81 | 81 | ||
82 | + class Block < Entity | ||
83 | + root 'blocks', 'block' | ||
84 | + expose :id, :type, :settings, :position, :enabled | ||
85 | + expose :mirror, :mirror_block_id, :title | ||
86 | + end | ||
87 | + | ||
88 | + class Box < Entity | ||
89 | + root 'boxes', 'box' | ||
90 | + expose :id, :position | ||
91 | + expose :blocks, :using => Block | ||
92 | + end | ||
93 | + | ||
82 | class Profile < Entity | 94 | class Profile < Entity |
83 | expose :identifier, :name, :id | 95 | expose :identifier, :name, :id |
84 | expose :created_at, :format_with => :timestamp | 96 | expose :created_at, :format_with => :timestamp |
@@ -164,6 +176,7 @@ module Noosfero | @@ -164,6 +176,7 @@ module Noosfero | ||
164 | expose :votes_count | 176 | expose :votes_count |
165 | expose :comments_count | 177 | expose :comments_count |
166 | expose :archived, :documentation => {:type => "Boolean", :desc => "Defines if a article is readonly"} | 178 | expose :archived, :documentation => {:type => "Boolean", :desc => "Defines if a article is readonly"} |
179 | + expose :type | ||
167 | end | 180 | end |
168 | 181 | ||
169 | class Article < ArticleBase | 182 | class Article < ArticleBase |
lib/noosfero/api/helpers.rb
@@ -5,7 +5,7 @@ require_relative '../../find_by_contents' | @@ -5,7 +5,7 @@ require_relative '../../find_by_contents' | ||
5 | module API | 5 | module API |
6 | module APIHelpers | 6 | module APIHelpers |
7 | PRIVATE_TOKEN_PARAM = :private_token | 7 | PRIVATE_TOKEN_PARAM = :private_token |
8 | - DEFAULT_ALLOWED_PARAMETERS = [:parent_id, :from, :until, :content_type, :author_id, :archived] | 8 | + DEFAULT_ALLOWED_PARAMETERS = [:parent_id, :from, :until, :content_type, :author_id, :archived, :identifier] |
9 | 9 | ||
10 | include SanitizeParams | 10 | include SanitizeParams |
11 | include Noosfero::Plugin::HotSpot | 11 | include Noosfero::Plugin::HotSpot |
lib/noosfero/api/session.rb
@@ -44,6 +44,13 @@ module Noosfero | @@ -44,6 +44,13 @@ module Noosfero | ||
44 | present user, :with => Entities::UserLogin, :current_person => current_person | 44 | present user, :with => Entities::UserLogin, :current_person => current_person |
45 | end | 45 | end |
46 | 46 | ||
47 | + post "/login_from_cookie" do | ||
48 | + user = User.where(remember_token: cookies[:auth_token]).first | ||
49 | + return unauthorized! unless user && user.activated? | ||
50 | + @current_user = user | ||
51 | + present user, :with => Entities::UserLogin, :current_person => current_person | ||
52 | + end | ||
53 | + | ||
47 | # Create user. | 54 | # Create user. |
48 | # | 55 | # |
49 | # Parameters: | 56 | # Parameters: |
@@ -0,0 +1,28 @@ | @@ -0,0 +1,28 @@ | ||
1 | +module Noosfero | ||
2 | + module API | ||
3 | + module V1 | ||
4 | + | ||
5 | + class Boxes < Grape::API | ||
6 | + | ||
7 | + kinds = %w[profile community person enterprise] | ||
8 | + kinds.each do |kind| | ||
9 | + | ||
10 | + resource kind.pluralize.to_sym do | ||
11 | + | ||
12 | + segment "/:#{kind}_id" do | ||
13 | + resource :boxes do | ||
14 | + get do | ||
15 | + profile = environment.send(kind.pluralize).find(params["#{kind}_id"]) | ||
16 | + present profile.boxes, :with => Entities::Box | ||
17 | + end | ||
18 | + end | ||
19 | + end | ||
20 | + | ||
21 | + end | ||
22 | + | ||
23 | + end | ||
24 | + end | ||
25 | + | ||
26 | + end | ||
27 | + end | ||
28 | +end |