Commit 0a4f86dda71679c761c6f2354e417dfe8557f03e
1 parent
4cb1363d
Exists in
api_tasks
and in
4 other branches
api: remove trailing whitespaces
Showing
7 changed files
with
112 additions
and
113 deletions
Show diff stats
lib/noosfero/api/v1/articles.rb
| ... | ... | @@ -3,11 +3,11 @@ module Noosfero |
| 3 | 3 | module V1 |
| 4 | 4 | class Articles < Grape::API |
| 5 | 5 | before { authenticate! } |
| 6 | - | |
| 6 | + | |
| 7 | 7 | ARTICLE_TYPES = Article.descendants.map{|a| a.to_s} |
| 8 | - | |
| 8 | + | |
| 9 | 9 | resource :articles do |
| 10 | - | |
| 10 | + | |
| 11 | 11 | # Collect articles |
| 12 | 12 | # |
| 13 | 13 | # Parameters: |
| ... | ... | @@ -22,13 +22,13 @@ module Noosfero |
| 22 | 22 | articles = articles.display_filter(current_person, nil) |
| 23 | 23 | present articles, :with => Entities::Article, :fields => params[:fields] |
| 24 | 24 | end |
| 25 | - | |
| 25 | + | |
| 26 | 26 | desc "Return the article id" |
| 27 | 27 | get ':id' do |
| 28 | 28 | article = find_article(environment.articles, params[:id]) |
| 29 | 29 | present article, :with => Entities::Article, :fields => params[:fields] |
| 30 | 30 | end |
| 31 | - | |
| 31 | + | |
| 32 | 32 | get ':id/children' do |
| 33 | 33 | article = find_article(environment.articles, params[:id]) |
| 34 | 34 | |
| ... | ... | @@ -37,7 +37,7 @@ module Noosfero |
| 37 | 37 | articles = select_filtered_collection_of(article, 'children', params) |
| 38 | 38 | articles = articles.display_filter(current_person, nil) |
| 39 | 39 | |
| 40 | - | |
| 40 | + | |
| 41 | 41 | #TODO make tests for this situation |
| 42 | 42 | if votes_order |
| 43 | 43 | 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 |
| 46 | 46 | Article.hit(articles) |
| 47 | 47 | present articles, :with => Entities::Article, :fields => params[:fields] |
| 48 | 48 | end |
| 49 | - | |
| 49 | + | |
| 50 | 50 | get ':id/children/:child_id' do |
| 51 | 51 | article = find_article(environment.articles, params[:id]) |
| 52 | 52 | present find_article(article.children, params[:child_id]), :with => Entities::Article, :fields => params[:fields] |
| ... | ... | @@ -75,7 +75,7 @@ module Noosfero |
| 75 | 75 | return forbidden! unless parent_article.allow_create?(current_person) |
| 76 | 76 | |
| 77 | 77 | klass_type= params[:content_type].nil? ? 'TinyMceArticle' : params[:content_type] |
| 78 | - #FIXME see how to check the article types | |
| 78 | + #FIXME see how to check the article types | |
| 79 | 79 | #return forbidden! unless ARTICLE_TYPES.include?(klass_type) |
| 80 | 80 | |
| 81 | 81 | article = klass_type.constantize.new(params[:article]) |
| ... | ... | @@ -92,7 +92,7 @@ module Noosfero |
| 92 | 92 | end |
| 93 | 93 | |
| 94 | 94 | end |
| 95 | - | |
| 95 | + | |
| 96 | 96 | resource :communities do |
| 97 | 97 | segment '/:community_id' do |
| 98 | 98 | resource :articles do |
| ... | ... | @@ -102,38 +102,38 @@ module Noosfero |
| 102 | 102 | articles = articles.display_filter(current_person, community) |
| 103 | 103 | present articles, :with => Entities::Article, :fields => params[:fields] |
| 104 | 104 | end |
| 105 | - | |
| 105 | + | |
| 106 | 106 | get ':id' do |
| 107 | 107 | community = environment.communities.find(params[:community_id]) |
| 108 | 108 | article = find_article(community.articles, params[:id]) |
| 109 | 109 | present article, :with => Entities::Article, :fields => params[:fields] |
| 110 | 110 | end |
| 111 | - | |
| 111 | + | |
| 112 | 112 | # Example Request: |
| 113 | 113 | # POST api/v1/communites/:community_id/articles?private_token=234298743290432&article[name]=title&article[body]=body |
| 114 | 114 | post do |
| 115 | 115 | community = environment.communities.find(params[:community_id]) |
| 116 | 116 | return forbidden! unless current_person.can_post_content?(community) |
| 117 | - | |
| 117 | + | |
| 118 | 118 | klass_type= params[:content_type].nil? ? 'TinyMceArticle' : params[:content_type] |
| 119 | 119 | return forbidden! unless ARTICLE_TYPES.include?(klass_type) |
| 120 | - | |
| 120 | + | |
| 121 | 121 | article = klass_type.constantize.new(params[:article]) |
| 122 | 122 | article.last_changed_by = current_person |
| 123 | 123 | article.created_by= current_person |
| 124 | 124 | article.profile = community |
| 125 | - | |
| 125 | + | |
| 126 | 126 | if !article.save |
| 127 | 127 | render_api_errors!(article.errors.full_messages) |
| 128 | 128 | end |
| 129 | 129 | present article, :with => Entities::Article, :fields => params[:fields] |
| 130 | 130 | end |
| 131 | - | |
| 131 | + | |
| 132 | 132 | end |
| 133 | 133 | end |
| 134 | - | |
| 134 | + | |
| 135 | 135 | end |
| 136 | - | |
| 136 | + | |
| 137 | 137 | resource :people do |
| 138 | 138 | segment '/:person_id' do |
| 139 | 139 | resource :articles do |
| ... | ... | @@ -143,36 +143,36 @@ module Noosfero |
| 143 | 143 | articles = articles.display_filter(current_person, person) |
| 144 | 144 | present articles, :with => Entities::Article, :fields => params[:fields] |
| 145 | 145 | end |
| 146 | - | |
| 146 | + | |
| 147 | 147 | get ':id' do |
| 148 | 148 | person = environment.people.find(params[:person_id]) |
| 149 | 149 | article = find_article(person.articles, params[:id]) |
| 150 | 150 | present article, :with => Entities::Article, :fields => params[:fields] |
| 151 | 151 | end |
| 152 | - | |
| 152 | + | |
| 153 | 153 | post do |
| 154 | 154 | person = environment.people.find(params[:person_id]) |
| 155 | 155 | return forbidden! unless current_person.can_post_content?(person) |
| 156 | - | |
| 156 | + | |
| 157 | 157 | klass_type= params[:content_type].nil? ? 'TinyMceArticle' : params[:content_type] |
| 158 | 158 | return forbidden! unless ARTICLE_TYPES.include?(klass_type) |
| 159 | - | |
| 159 | + | |
| 160 | 160 | article = klass_type.constantize.new(params[:article]) |
| 161 | 161 | article.last_changed_by = current_person |
| 162 | 162 | article.created_by= current_person |
| 163 | 163 | article.profile = person |
| 164 | - | |
| 164 | + | |
| 165 | 165 | if !article.save |
| 166 | 166 | render_api_errors!(article.errors.full_messages) |
| 167 | 167 | end |
| 168 | 168 | present article, :with => Entities::Article, :fields => params[:fields] |
| 169 | 169 | end |
| 170 | - | |
| 170 | + | |
| 171 | 171 | end |
| 172 | 172 | end |
| 173 | - | |
| 173 | + | |
| 174 | 174 | end |
| 175 | - | |
| 175 | + | |
| 176 | 176 | resource :enterprises do |
| 177 | 177 | segment '/:enterprise_id' do |
| 178 | 178 | resource :articles do |
| ... | ... | @@ -182,37 +182,36 @@ module Noosfero |
| 182 | 182 | articles = articles.display_filter(current_person, enterprise) |
| 183 | 183 | present articles, :with => Entities::Article, :fields => params[:fields] |
| 184 | 184 | end |
| 185 | - | |
| 185 | + | |
| 186 | 186 | get ':id' do |
| 187 | 187 | enterprise = environment.enterprises.find(params[:enterprise_id]) |
| 188 | 188 | article = find_article(enterprise.articles, params[:id]) |
| 189 | 189 | present article, :with => Entities::Article, :fields => params[:fields] |
| 190 | 190 | end |
| 191 | - | |
| 191 | + | |
| 192 | 192 | post do |
| 193 | 193 | enterprise = environment.enterprises.find(params[:enterprise_id]) |
| 194 | 194 | return forbidden! unless current_person.can_post_content?(enterprise) |
| 195 | - | |
| 195 | + | |
| 196 | 196 | klass_type= params[:content_type].nil? ? 'TinyMceArticle' : params[:content_type] |
| 197 | 197 | return forbidden! unless ARTICLE_TYPES.include?(klass_type) |
| 198 | - | |
| 198 | + | |
| 199 | 199 | article = klass_type.constantize.new(params[:article]) |
| 200 | 200 | article.last_changed_by = current_person |
| 201 | 201 | article.created_by= current_person |
| 202 | 202 | article.profile = enterprise |
| 203 | - | |
| 203 | + | |
| 204 | 204 | if !article.save |
| 205 | 205 | render_api_errors!(article.errors.full_messages) |
| 206 | 206 | end |
| 207 | 207 | present article, :with => Entities::Article, :fields => params[:fields] |
| 208 | 208 | end |
| 209 | - | |
| 209 | + | |
| 210 | 210 | end |
| 211 | 211 | end |
| 212 | - | |
| 212 | + | |
| 213 | 213 | end |
| 214 | - | |
| 215 | - | |
| 214 | + | |
| 216 | 215 | end |
| 217 | 216 | end |
| 218 | 217 | end | ... | ... |
lib/noosfero/api/v1/categories.rb
| ... | ... | @@ -3,22 +3,22 @@ module Noosfero |
| 3 | 3 | module V1 |
| 4 | 4 | class Categories < Grape::API |
| 5 | 5 | before { authenticate! } |
| 6 | - | |
| 6 | + | |
| 7 | 7 | resource :categories do |
| 8 | - | |
| 8 | + | |
| 9 | 9 | get do |
| 10 | 10 | type = params[:category_type] |
| 11 | 11 | categories = type.nil? ? environment.categories : environment.categories.find(:all, :conditions => {:type => type}) |
| 12 | 12 | present categories, :with => Entities::Category |
| 13 | 13 | end |
| 14 | - | |
| 15 | - desc "Return the category by id" | |
| 14 | + | |
| 15 | + desc "Return the category by id" | |
| 16 | 16 | get ':id' do |
| 17 | 17 | present environment.categories.find(params[:id]), :with => Entities::Category |
| 18 | 18 | end |
| 19 | - | |
| 19 | + | |
| 20 | 20 | end |
| 21 | - | |
| 21 | + | |
| 22 | 22 | end |
| 23 | 23 | end |
| 24 | 24 | end | ... | ... |
lib/noosfero/api/v1/communities.rb
| ... | ... | @@ -3,9 +3,9 @@ module Noosfero |
| 3 | 3 | module V1 |
| 4 | 4 | class Communities < Grape::API |
| 5 | 5 | before { authenticate! } |
| 6 | - | |
| 6 | + | |
| 7 | 7 | resource :communities do |
| 8 | - | |
| 8 | + | |
| 9 | 9 | # Collect comments from articles |
| 10 | 10 | # |
| 11 | 11 | # Parameters: |
| ... | ... | @@ -21,8 +21,8 @@ module Noosfero |
| 21 | 21 | communities = communities.visible_for_person(current_person) |
| 22 | 22 | present communities, :with => Entities::Community |
| 23 | 23 | end |
| 24 | - | |
| 25 | - | |
| 24 | + | |
| 25 | + | |
| 26 | 26 | # Example Request: |
| 27 | 27 | # POST api/v1/communties?private_token=234298743290432&community[name]=some_name |
| 28 | 28 | post do |
| ... | ... | @@ -32,40 +32,40 @@ module Noosfero |
| 32 | 32 | rescue |
| 33 | 33 | community = Community.new(params[:community]) |
| 34 | 34 | end |
| 35 | - | |
| 35 | + | |
| 36 | 36 | if !community.save |
| 37 | 37 | render_api_errors!(community.errors.full_messages) |
| 38 | 38 | end |
| 39 | - | |
| 39 | + | |
| 40 | 40 | present community, :with => Entities::Community |
| 41 | 41 | end |
| 42 | - | |
| 42 | + | |
| 43 | 43 | get ':id' do |
| 44 | 44 | community = environment.communities.visible.find_by_id(params[:id]) |
| 45 | 45 | present community, :with => Entities::Community |
| 46 | 46 | end |
| 47 | - | |
| 47 | + | |
| 48 | 48 | end |
| 49 | - | |
| 49 | + | |
| 50 | 50 | resource :people do |
| 51 | - | |
| 51 | + | |
| 52 | 52 | segment '/:person_id' do |
| 53 | - | |
| 53 | + | |
| 54 | 54 | resource :communities do |
| 55 | - | |
| 55 | + | |
| 56 | 56 | get do |
| 57 | 57 | person = environment.people.find(params[:person_id]) |
| 58 | 58 | communities = select_filtered_collection_of(person, 'communities', params) |
| 59 | 59 | communities = communities.visible |
| 60 | 60 | present communities, :with => Entities::Community |
| 61 | 61 | end |
| 62 | - | |
| 62 | + | |
| 63 | 63 | end |
| 64 | - | |
| 64 | + | |
| 65 | 65 | end |
| 66 | - | |
| 66 | + | |
| 67 | 67 | end |
| 68 | - | |
| 68 | + | |
| 69 | 69 | end |
| 70 | 70 | end |
| 71 | 71 | end | ... | ... |
lib/noosfero/api/v1/enterprises.rb
| ... | ... | @@ -3,9 +3,9 @@ module Noosfero |
| 3 | 3 | module V1 |
| 4 | 4 | class Enterprises < Grape::API |
| 5 | 5 | before { authenticate! } |
| 6 | - | |
| 6 | + | |
| 7 | 7 | resource :enterprises do |
| 8 | - | |
| 8 | + | |
| 9 | 9 | # Collect comments from articles |
| 10 | 10 | # |
| 11 | 11 | # Parameters: |
| ... | ... | @@ -21,35 +21,35 @@ module Noosfero |
| 21 | 21 | enterprises = enterprises.visible_for_person(current_person) |
| 22 | 22 | present enterprises, :with => Entities::Enterprise |
| 23 | 23 | end |
| 24 | - | |
| 24 | + | |
| 25 | 25 | desc "Return one enterprise by id" |
| 26 | 26 | get ':id' do |
| 27 | 27 | enterprise = environment.enterprises.visible.find_by_id(params[:id]) |
| 28 | 28 | present enterprise, :with => Entities::Enterprise |
| 29 | 29 | end |
| 30 | - | |
| 30 | + | |
| 31 | 31 | end |
| 32 | - | |
| 32 | + | |
| 33 | 33 | resource :people do |
| 34 | - | |
| 34 | + | |
| 35 | 35 | segment '/:person_id' do |
| 36 | - | |
| 36 | + | |
| 37 | 37 | resource :enterprises do |
| 38 | - | |
| 38 | + | |
| 39 | 39 | get do |
| 40 | 40 | person = environment.people.find(params[:person_id]) |
| 41 | 41 | enterprises = select_filtered_collection_of(person, 'enterprises', params) |
| 42 | 42 | enterprises = enterprises.visible |
| 43 | 43 | present enterprises, :with => Entities::Enterprise |
| 44 | 44 | end |
| 45 | - | |
| 45 | + | |
| 46 | 46 | end |
| 47 | - | |
| 47 | + | |
| 48 | 48 | end |
| 49 | - | |
| 49 | + | |
| 50 | 50 | end |
| 51 | - | |
| 52 | - | |
| 51 | + | |
| 52 | + | |
| 53 | 53 | end |
| 54 | 54 | end |
| 55 | 55 | end | ... | ... |
lib/noosfero/api/v1/people.rb
| ... | ... | @@ -3,9 +3,9 @@ module Noosfero |
| 3 | 3 | module V1 |
| 4 | 4 | class People < Grape::API |
| 5 | 5 | before { authenticate! } |
| 6 | - | |
| 6 | + | |
| 7 | 7 | resource :people do |
| 8 | - | |
| 8 | + | |
| 9 | 9 | # Collect comments from articles |
| 10 | 10 | # |
| 11 | 11 | # Parameters: |
| ... | ... | @@ -21,21 +21,21 @@ module Noosfero |
| 21 | 21 | people = people.visible_for_person(current_person) |
| 22 | 22 | present people, :with => Entities::Person |
| 23 | 23 | end |
| 24 | - | |
| 24 | + | |
| 25 | 25 | desc "Return the person information" |
| 26 | 26 | get ':id' do |
| 27 | 27 | person = environment.people.visible.find_by_id(params[:id]) |
| 28 | 28 | present person, :with => Entities::Person |
| 29 | 29 | end |
| 30 | - | |
| 30 | + | |
| 31 | 31 | desc "Return the person friends" |
| 32 | 32 | get ':id/friends' do |
| 33 | 33 | friends = current_person.friends.visible |
| 34 | 34 | present friends, :with => Entities::Person |
| 35 | 35 | end |
| 36 | - | |
| 36 | + | |
| 37 | 37 | end |
| 38 | - | |
| 38 | + | |
| 39 | 39 | end |
| 40 | 40 | end |
| 41 | 41 | end | ... | ... |
lib/noosfero/api/v1/tasks.rb
| ... | ... | @@ -3,11 +3,11 @@ module Noosfero |
| 3 | 3 | module V1 |
| 4 | 4 | class Tasks < Grape::API |
| 5 | 5 | # before { authenticate! } |
| 6 | - | |
| 6 | + | |
| 7 | 7 | # ARTICLE_TYPES = Article.descendants.map{|a| a.to_s} |
| 8 | - | |
| 8 | + | |
| 9 | 9 | resource :tasks do |
| 10 | - | |
| 10 | + | |
| 11 | 11 | # Collect tasks |
| 12 | 12 | # |
| 13 | 13 | # Parameters: |
| ... | ... | @@ -22,16 +22,16 @@ module Noosfero |
| 22 | 22 | tasks = select_filtered_collection_of(environment, 'tasks', params) |
| 23 | 23 | present tasks, :with => Entities::Task, :fields => params[:fields] |
| 24 | 24 | end |
| 25 | - | |
| 25 | + | |
| 26 | 26 | desc "Return the task id" |
| 27 | 27 | get ':id' do |
| 28 | 28 | task = find_task(environment.tasks, params[:id]) |
| 29 | 29 | present task, :with => Entities::Task, :fields => params[:fields] |
| 30 | 30 | end |
| 31 | - | |
| 31 | + | |
| 32 | 32 | |
| 33 | 33 | end |
| 34 | - | |
| 34 | + | |
| 35 | 35 | resource :communities do |
| 36 | 36 | segment '/:community_id' do |
| 37 | 37 | resource :tasks do |
| ... | ... | @@ -41,38 +41,38 @@ module Noosfero |
| 41 | 41 | tasks = select_filtered_collection_of(community, 'tasks', params) |
| 42 | 42 | present tasks, :with => Entities::Task, :fields => params[:fields] |
| 43 | 43 | end |
| 44 | - | |
| 44 | + | |
| 45 | 45 | get ':id' do |
| 46 | 46 | community = environment.communities.find(params[:community_id]) |
| 47 | 47 | task = find_task(community.tasks, params[:id]) |
| 48 | 48 | present task, :with => Entities::Task, :fields => params[:fields] |
| 49 | 49 | end |
| 50 | - | |
| 50 | + | |
| 51 | 51 | # Example Request: |
| 52 | 52 | # POST api/v1/communites/:community_id/articles?private_token=234298743290432&article[name]=title&article[body]=body |
| 53 | 53 | post do |
| 54 | 54 | community = environment.communities.find(params[:community_id]) |
| 55 | 55 | #FIXME see the correct permission |
| 56 | 56 | return forbidden! unless current_person.can_post_content?(community) |
| 57 | -#FIXME check the task type before create | |
| 57 | +#FIXME check the task type before create | |
| 58 | 58 | klass_type= params[:content_type].nil? ? 'Task' : params[:content_type] |
| 59 | 59 | # return forbidden! unless ARTICLE_TYPES.include?(klass_type) |
| 60 | -# | |
| 60 | +# | |
| 61 | 61 | task = klass_type.constantize.new(params[:task]) |
| 62 | 62 | task.requestor = current_person |
| 63 | 63 | task.target = community |
| 64 | - | |
| 64 | + | |
| 65 | 65 | if !task.save |
| 66 | 66 | render_api_errors!(task.errors.full_messages) |
| 67 | 67 | end |
| 68 | 68 | present task, :with => Entities::Task, :fields => params[:fields] |
| 69 | 69 | end |
| 70 | - | |
| 70 | + | |
| 71 | 71 | end |
| 72 | 72 | end |
| 73 | - | |
| 73 | + | |
| 74 | 74 | end |
| 75 | - | |
| 75 | + | |
| 76 | 76 | resource :people do |
| 77 | 77 | segment '/:person_id' do |
| 78 | 78 | resource :tasks do |
| ... | ... | @@ -83,38 +83,38 @@ module Noosfero |
| 83 | 83 | tasks = Task.all |
| 84 | 84 | present tasks, :with => Entities::Task, :fields => params[:fields] |
| 85 | 85 | end |
| 86 | - | |
| 86 | + | |
| 87 | 87 | get ':id' do |
| 88 | 88 | # person = environment.people.find(params[:person_id]) |
| 89 | 89 | # article = find_article(person.articles, params[:id]) |
| 90 | 90 | task = Task.first |
| 91 | 91 | present task, :with => Entities::Task, :fields => params[:fields] |
| 92 | 92 | end |
| 93 | - | |
| 93 | + | |
| 94 | 94 | post do |
| 95 | 95 | # person = environment.people.find(params[:person_id]) |
| 96 | 96 | # return forbidden! unless current_person.can_post_content?(person) |
| 97 | -# | |
| 97 | +# | |
| 98 | 98 | # klass_type= params[:content_type].nil? ? 'TinyMceArticle' : params[:content_type] |
| 99 | 99 | # return forbidden! unless ARTICLE_TYPES.include?(klass_type) |
| 100 | -# | |
| 100 | +# | |
| 101 | 101 | # article = klass_type.constantize.new(params[:article]) |
| 102 | 102 | # article.last_changed_by = current_person |
| 103 | 103 | # article.created_by= current_person |
| 104 | 104 | # article.profile = person |
| 105 | -# | |
| 105 | +# | |
| 106 | 106 | # if !article.save |
| 107 | 107 | # render_api_errors!(article.errors.full_messages) |
| 108 | 108 | # end |
| 109 | 109 | task = Task.first |
| 110 | 110 | present task, :with => Entities::Task, :fields => params[:fields] |
| 111 | 111 | end |
| 112 | - | |
| 112 | + | |
| 113 | 113 | end |
| 114 | 114 | end |
| 115 | - | |
| 115 | + | |
| 116 | 116 | end |
| 117 | - | |
| 117 | + | |
| 118 | 118 | resource :enterprises do |
| 119 | 119 | segment '/:enterprise_id' do |
| 120 | 120 | resource :tasks do |
| ... | ... | @@ -125,39 +125,39 @@ task = Task.first |
| 125 | 125 | tasks = Task.all |
| 126 | 126 | present tasks, :with => Entities::Task, :fields => params[:fields] |
| 127 | 127 | end |
| 128 | - | |
| 128 | + | |
| 129 | 129 | get ':id' do |
| 130 | 130 | # enterprise = environment.enterprises.find(params[:enterprise_id]) |
| 131 | 131 | # article = find_article(enterprise.articles, params[:id]) |
| 132 | 132 | task = Task.first |
| 133 | 133 | present task, :with => Entities::Task, :fields => params[:fields] |
| 134 | 134 | end |
| 135 | - | |
| 135 | + | |
| 136 | 136 | post do |
| 137 | 137 | # enterprise = environment.enterprises.find(params[:enterprise_id]) |
| 138 | 138 | # return forbidden! unless current_person.can_post_content?(enterprise) |
| 139 | -# | |
| 139 | +# | |
| 140 | 140 | # klass_type= params[:content_type].nil? ? 'TinyMceArticle' : params[:content_type] |
| 141 | 141 | # return forbidden! unless ARTICLE_TYPES.include?(klass_type) |
| 142 | -# | |
| 142 | +# | |
| 143 | 143 | # article = klass_type.constantize.new(params[:article]) |
| 144 | 144 | # article.last_changed_by = current_person |
| 145 | 145 | # article.created_by= current_person |
| 146 | 146 | # article.profile = enterprise |
| 147 | -# | |
| 147 | +# | |
| 148 | 148 | # if !article.save |
| 149 | 149 | # render_api_errors!(article.errors.full_messages) |
| 150 | 150 | # end |
| 151 | 151 | task = Task.first |
| 152 | 152 | present task, :with => Entities::Task, :fields => params[:fields] |
| 153 | 153 | end |
| 154 | - | |
| 154 | + | |
| 155 | 155 | end |
| 156 | 156 | end |
| 157 | - | |
| 157 | + | |
| 158 | 158 | end |
| 159 | - | |
| 160 | - | |
| 159 | + | |
| 160 | + | |
| 161 | 161 | end |
| 162 | 162 | end |
| 163 | 163 | end | ... | ... |
lib/noosfero/api/v1/users.rb
| ... | ... | @@ -3,15 +3,15 @@ module Noosfero |
| 3 | 3 | module V1 |
| 4 | 4 | class Users < Grape::API |
| 5 | 5 | before { authenticate! } |
| 6 | - | |
| 6 | + | |
| 7 | 7 | resource :users do |
| 8 | - | |
| 8 | + | |
| 9 | 9 | #FIXME make the pagination |
| 10 | 10 | #FIXME put it on environment context |
| 11 | 11 | get do |
| 12 | 12 | present environment.users, :with => Entities::User |
| 13 | 13 | end |
| 14 | - | |
| 14 | + | |
| 15 | 15 | # Example Request: |
| 16 | 16 | # POST api/v1/users?user[login]=some_login&user[password]=some |
| 17 | 17 | post do |
| ... | ... | @@ -21,7 +21,7 @@ module Noosfero |
| 21 | 21 | if !user.save |
| 22 | 22 | render_api_errors!(user.errors.full_messages) |
| 23 | 23 | end |
| 24 | - | |
| 24 | + | |
| 25 | 25 | present user, :with => Entities::User |
| 26 | 26 | end |
| 27 | 27 | |
| ... | ... | @@ -38,14 +38,14 @@ module Noosfero |
| 38 | 38 | output = {} |
| 39 | 39 | user.person.role_assignments.map do |role_assigment| |
| 40 | 40 | if role_assigment.resource.respond_to?(:identifier) && role_assigment.resource.identifier == params[:profile] |
| 41 | - output[:permissions] = role_assigment.role.permissions | |
| 41 | + output[:permissions] = role_assigment.role.permissions | |
| 42 | 42 | end |
| 43 | 43 | end |
| 44 | 44 | present output |
| 45 | 45 | end |
| 46 | - | |
| 46 | + | |
| 47 | 47 | end |
| 48 | - | |
| 48 | + | |
| 49 | 49 | end |
| 50 | 50 | end |
| 51 | 51 | end | ... | ... |