From 0a4f86dda71679c761c6f2354e417dfe8557f03e Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Tue, 16 Jun 2015 15:33:38 -0300 Subject: [PATCH] api: remove trailing whitespaces --- lib/noosfero/api/v1/articles.rb | 67 +++++++++++++++++++++++++++++++++---------------------------------- lib/noosfero/api/v1/categories.rb | 12 ++++++------ lib/noosfero/api/v1/communities.rb | 32 ++++++++++++++++---------------- lib/noosfero/api/v1/enterprises.rb | 26 +++++++++++++------------- lib/noosfero/api/v1/people.rb | 12 ++++++------ lib/noosfero/api/v1/tasks.rb | 62 +++++++++++++++++++++++++++++++------------------------------- lib/noosfero/api/v1/users.rb | 14 +++++++------- 7 files changed, 112 insertions(+), 113 deletions(-) diff --git a/lib/noosfero/api/v1/articles.rb b/lib/noosfero/api/v1/articles.rb index 157155e..b3d8d5f 100644 --- a/lib/noosfero/api/v1/articles.rb +++ b/lib/noosfero/api/v1/articles.rb @@ -3,11 +3,11 @@ module Noosfero module V1 class Articles < Grape::API before { authenticate! } - + ARTICLE_TYPES = Article.descendants.map{|a| a.to_s} - + resource :articles do - + # Collect articles # # Parameters: @@ -22,13 +22,13 @@ module Noosfero articles = articles.display_filter(current_person, nil) present articles, :with => Entities::Article, :fields => params[:fields] end - + desc "Return the article id" get ':id' do article = find_article(environment.articles, params[:id]) present article, :with => Entities::Article, :fields => params[:fields] end - + get ':id/children' do article = find_article(environment.articles, params[:id]) @@ -37,7 +37,7 @@ module Noosfero articles = select_filtered_collection_of(article, 'children', params) articles = articles.display_filter(current_person, nil) - + #TODO make tests for this situation if votes_order articles = articles.joins('left join votes on articles.id=votes.voteable_id').group('articles.id').reorder('sum(coalesce(votes.vote, 0)) DESC') @@ -46,7 +46,7 @@ module Noosfero Article.hit(articles) present articles, :with => Entities::Article, :fields => params[:fields] end - + get ':id/children/:child_id' do article = find_article(environment.articles, params[:id]) present find_article(article.children, params[:child_id]), :with => Entities::Article, :fields => params[:fields] @@ -75,7 +75,7 @@ module Noosfero return forbidden! unless parent_article.allow_create?(current_person) klass_type= params[:content_type].nil? ? 'TinyMceArticle' : params[:content_type] - #FIXME see how to check the article types + #FIXME see how to check the article types #return forbidden! unless ARTICLE_TYPES.include?(klass_type) article = klass_type.constantize.new(params[:article]) @@ -92,7 +92,7 @@ module Noosfero end end - + resource :communities do segment '/:community_id' do resource :articles do @@ -102,38 +102,38 @@ module Noosfero articles = articles.display_filter(current_person, community) present articles, :with => Entities::Article, :fields => params[:fields] end - + get ':id' do community = environment.communities.find(params[:community_id]) article = find_article(community.articles, params[:id]) present article, :with => Entities::Article, :fields => params[:fields] end - + # Example Request: # POST api/v1/communites/:community_id/articles?private_token=234298743290432&article[name]=title&article[body]=body post do community = environment.communities.find(params[:community_id]) return forbidden! unless current_person.can_post_content?(community) - + klass_type= params[:content_type].nil? ? 'TinyMceArticle' : params[:content_type] return forbidden! unless ARTICLE_TYPES.include?(klass_type) - + article = klass_type.constantize.new(params[:article]) article.last_changed_by = current_person article.created_by= current_person article.profile = community - + if !article.save render_api_errors!(article.errors.full_messages) end present article, :with => Entities::Article, :fields => params[:fields] end - + end end - + end - + resource :people do segment '/:person_id' do resource :articles do @@ -143,36 +143,36 @@ module Noosfero articles = articles.display_filter(current_person, person) present articles, :with => Entities::Article, :fields => params[:fields] end - + get ':id' do person = environment.people.find(params[:person_id]) article = find_article(person.articles, params[:id]) present article, :with => Entities::Article, :fields => params[:fields] end - + post do person = environment.people.find(params[:person_id]) return forbidden! unless current_person.can_post_content?(person) - + klass_type= params[:content_type].nil? ? 'TinyMceArticle' : params[:content_type] return forbidden! unless ARTICLE_TYPES.include?(klass_type) - + article = klass_type.constantize.new(params[:article]) article.last_changed_by = current_person article.created_by= current_person article.profile = person - + if !article.save render_api_errors!(article.errors.full_messages) end present article, :with => Entities::Article, :fields => params[:fields] end - + end end - + end - + resource :enterprises do segment '/:enterprise_id' do resource :articles do @@ -182,37 +182,36 @@ module Noosfero articles = articles.display_filter(current_person, enterprise) present articles, :with => Entities::Article, :fields => params[:fields] end - + get ':id' do enterprise = environment.enterprises.find(params[:enterprise_id]) article = find_article(enterprise.articles, params[:id]) present article, :with => Entities::Article, :fields => params[:fields] end - + post do enterprise = environment.enterprises.find(params[:enterprise_id]) return forbidden! unless current_person.can_post_content?(enterprise) - + klass_type= params[:content_type].nil? ? 'TinyMceArticle' : params[:content_type] return forbidden! unless ARTICLE_TYPES.include?(klass_type) - + article = klass_type.constantize.new(params[:article]) article.last_changed_by = current_person article.created_by= current_person article.profile = enterprise - + if !article.save render_api_errors!(article.errors.full_messages) end present article, :with => Entities::Article, :fields => params[:fields] end - + end end - + end - - + end end end diff --git a/lib/noosfero/api/v1/categories.rb b/lib/noosfero/api/v1/categories.rb index 1392707..4b65d8d 100644 --- a/lib/noosfero/api/v1/categories.rb +++ b/lib/noosfero/api/v1/categories.rb @@ -3,22 +3,22 @@ module Noosfero module V1 class Categories < Grape::API before { authenticate! } - + resource :categories do - + get do type = params[:category_type] categories = type.nil? ? environment.categories : environment.categories.find(:all, :conditions => {:type => type}) present categories, :with => Entities::Category end - - desc "Return the category by id" + + desc "Return the category by id" get ':id' do present environment.categories.find(params[:id]), :with => Entities::Category end - + end - + end end end diff --git a/lib/noosfero/api/v1/communities.rb b/lib/noosfero/api/v1/communities.rb index 69382da..17d0fe2 100644 --- a/lib/noosfero/api/v1/communities.rb +++ b/lib/noosfero/api/v1/communities.rb @@ -3,9 +3,9 @@ module Noosfero module V1 class Communities < Grape::API before { authenticate! } - + resource :communities do - + # Collect comments from articles # # Parameters: @@ -21,8 +21,8 @@ module Noosfero communities = communities.visible_for_person(current_person) present communities, :with => Entities::Community end - - + + # Example Request: # POST api/v1/communties?private_token=234298743290432&community[name]=some_name post do @@ -32,40 +32,40 @@ module Noosfero rescue community = Community.new(params[:community]) end - + if !community.save render_api_errors!(community.errors.full_messages) end - + present community, :with => Entities::Community end - + get ':id' do community = environment.communities.visible.find_by_id(params[:id]) present community, :with => Entities::Community end - + end - + resource :people do - + segment '/:person_id' do - + resource :communities do - + get do person = environment.people.find(params[:person_id]) communities = select_filtered_collection_of(person, 'communities', params) communities = communities.visible present communities, :with => Entities::Community end - + end - + end - + end - + end end end diff --git a/lib/noosfero/api/v1/enterprises.rb b/lib/noosfero/api/v1/enterprises.rb index fb8ab13..07d9f41 100644 --- a/lib/noosfero/api/v1/enterprises.rb +++ b/lib/noosfero/api/v1/enterprises.rb @@ -3,9 +3,9 @@ module Noosfero module V1 class Enterprises < Grape::API before { authenticate! } - + resource :enterprises do - + # Collect comments from articles # # Parameters: @@ -21,35 +21,35 @@ module Noosfero enterprises = enterprises.visible_for_person(current_person) present enterprises, :with => Entities::Enterprise end - + desc "Return one enterprise by id" get ':id' do enterprise = environment.enterprises.visible.find_by_id(params[:id]) present enterprise, :with => Entities::Enterprise end - + end - + resource :people do - + segment '/:person_id' do - + resource :enterprises do - + get do person = environment.people.find(params[:person_id]) enterprises = select_filtered_collection_of(person, 'enterprises', params) enterprises = enterprises.visible present enterprises, :with => Entities::Enterprise end - + end - + end - + end - - + + end end end diff --git a/lib/noosfero/api/v1/people.rb b/lib/noosfero/api/v1/people.rb index 0b69d4b..dbc400a 100644 --- a/lib/noosfero/api/v1/people.rb +++ b/lib/noosfero/api/v1/people.rb @@ -3,9 +3,9 @@ module Noosfero module V1 class People < Grape::API before { authenticate! } - + resource :people do - + # Collect comments from articles # # Parameters: @@ -21,21 +21,21 @@ module Noosfero people = people.visible_for_person(current_person) present people, :with => Entities::Person end - + desc "Return the person information" get ':id' do person = environment.people.visible.find_by_id(params[:id]) present person, :with => Entities::Person end - + desc "Return the person friends" get ':id/friends' do friends = current_person.friends.visible present friends, :with => Entities::Person end - + end - + end end end diff --git a/lib/noosfero/api/v1/tasks.rb b/lib/noosfero/api/v1/tasks.rb index 0eda601..727617f 100644 --- a/lib/noosfero/api/v1/tasks.rb +++ b/lib/noosfero/api/v1/tasks.rb @@ -3,11 +3,11 @@ module Noosfero module V1 class Tasks < Grape::API # before { authenticate! } - + # ARTICLE_TYPES = Article.descendants.map{|a| a.to_s} - + resource :tasks do - + # Collect tasks # # Parameters: @@ -22,16 +22,16 @@ module Noosfero tasks = select_filtered_collection_of(environment, 'tasks', params) present tasks, :with => Entities::Task, :fields => params[:fields] end - + desc "Return the task id" get ':id' do task = find_task(environment.tasks, params[:id]) present task, :with => Entities::Task, :fields => params[:fields] end - + end - + resource :communities do segment '/:community_id' do resource :tasks do @@ -41,38 +41,38 @@ module Noosfero tasks = select_filtered_collection_of(community, 'tasks', params) present tasks, :with => Entities::Task, :fields => params[:fields] end - + get ':id' do community = environment.communities.find(params[:community_id]) task = find_task(community.tasks, params[:id]) present task, :with => Entities::Task, :fields => params[:fields] end - + # Example Request: # POST api/v1/communites/:community_id/articles?private_token=234298743290432&article[name]=title&article[body]=body post do community = environment.communities.find(params[:community_id]) #FIXME see the correct permission return forbidden! unless current_person.can_post_content?(community) -#FIXME check the task type before create +#FIXME check the task type before create klass_type= params[:content_type].nil? ? 'Task' : params[:content_type] # return forbidden! unless ARTICLE_TYPES.include?(klass_type) -# +# task = klass_type.constantize.new(params[:task]) task.requestor = current_person task.target = community - + if !task.save render_api_errors!(task.errors.full_messages) end present task, :with => Entities::Task, :fields => params[:fields] end - + end end - + end - + resource :people do segment '/:person_id' do resource :tasks do @@ -83,38 +83,38 @@ module Noosfero tasks = Task.all present tasks, :with => Entities::Task, :fields => params[:fields] end - + get ':id' do # person = environment.people.find(params[:person_id]) # article = find_article(person.articles, params[:id]) task = Task.first present task, :with => Entities::Task, :fields => params[:fields] end - + post do # person = environment.people.find(params[:person_id]) # return forbidden! unless current_person.can_post_content?(person) -# +# # klass_type= params[:content_type].nil? ? 'TinyMceArticle' : params[:content_type] # return forbidden! unless ARTICLE_TYPES.include?(klass_type) -# +# # article = klass_type.constantize.new(params[:article]) # article.last_changed_by = current_person # article.created_by= current_person # article.profile = person -# +# # if !article.save # render_api_errors!(article.errors.full_messages) # end task = Task.first present task, :with => Entities::Task, :fields => params[:fields] end - + end end - + end - + resource :enterprises do segment '/:enterprise_id' do resource :tasks do @@ -125,39 +125,39 @@ task = Task.first tasks = Task.all present tasks, :with => Entities::Task, :fields => params[:fields] end - + get ':id' do # enterprise = environment.enterprises.find(params[:enterprise_id]) # article = find_article(enterprise.articles, params[:id]) task = Task.first present task, :with => Entities::Task, :fields => params[:fields] end - + post do # enterprise = environment.enterprises.find(params[:enterprise_id]) # return forbidden! unless current_person.can_post_content?(enterprise) -# +# # klass_type= params[:content_type].nil? ? 'TinyMceArticle' : params[:content_type] # return forbidden! unless ARTICLE_TYPES.include?(klass_type) -# +# # article = klass_type.constantize.new(params[:article]) # article.last_changed_by = current_person # article.created_by= current_person # article.profile = enterprise -# +# # if !article.save # render_api_errors!(article.errors.full_messages) # end task = Task.first present task, :with => Entities::Task, :fields => params[:fields] end - + end end - + end - - + + end end end diff --git a/lib/noosfero/api/v1/users.rb b/lib/noosfero/api/v1/users.rb index 95ada77..c96e9f6 100644 --- a/lib/noosfero/api/v1/users.rb +++ b/lib/noosfero/api/v1/users.rb @@ -3,15 +3,15 @@ module Noosfero module V1 class Users < Grape::API before { authenticate! } - + resource :users do - + #FIXME make the pagination #FIXME put it on environment context get do present environment.users, :with => Entities::User end - + # Example Request: # POST api/v1/users?user[login]=some_login&user[password]=some post do @@ -21,7 +21,7 @@ module Noosfero if !user.save render_api_errors!(user.errors.full_messages) end - + present user, :with => Entities::User end @@ -38,14 +38,14 @@ module Noosfero output = {} user.person.role_assignments.map do |role_assigment| if role_assigment.resource.respond_to?(:identifier) && role_assigment.resource.identifier == params[:profile] - output[:permissions] = role_assigment.role.permissions + output[:permissions] = role_assigment.role.permissions end end present output end - + end - + end end end -- libgit2 0.21.2