Commit a7df1a640a6fdde6003e15c69045c9c6516a142b

Authored by Victor Costa
2 parents 3aba3cdf 12f96cd5
Exists in staging

Merge branch 'angular_poc' into staging

lib/noosfero/api/api.rb
... ... @@ -54,6 +54,7 @@ module Noosfero
54 54 mount V1::Environments
55 55 mount V1::Search
56 56 mount V1::Contacts
  57 + mount V1::Boxes
57 58  
58 59 mount Session
59 60  
... ...
lib/noosfero/api/entities.rb
... ... @@ -79,6 +79,18 @@ module Noosfero
79 79 expose :parent_id
80 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 94 class Profile < Entity
83 95 expose :identifier, :name, :id
84 96 expose :created_at, :format_with => :timestamp
... ... @@ -164,6 +176,7 @@ module Noosfero
164 176 expose :votes_count
165 177 expose :comments_count
166 178 expose :archived, :documentation => {:type => "Boolean", :desc => "Defines if a article is readonly"}
  179 + expose :type
167 180 end
168 181  
169 182 class Article < ArticleBase
... ...
lib/noosfero/api/helpers.rb
... ... @@ -5,7 +5,7 @@ require_relative &#39;../../find_by_contents&#39;
5 5 module API
6 6 module APIHelpers
7 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 10 include SanitizeParams
11 11 include Noosfero::Plugin::HotSpot
... ...
lib/noosfero/api/session.rb
... ... @@ -44,6 +44,13 @@ module Noosfero
44 44 present user, :with => Entities::UserLogin, :current_person => current_person
45 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 54 # Create user.
48 55 #
49 56 # Parameters:
... ...
lib/noosfero/api/v1/boxes.rb 0 → 100644
... ... @@ -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
... ...