Commit 135c10f90f3957f2455b9ddcb6f8065e71dd30aa
Exists in
staging
and in
4 other branches
Merge branch 'api' into production
Showing
4 changed files
with
62 additions
and
1 deletions
Show diff stats
lib/noosfero/api/api.rb
lib/noosfero/api/entities.rb
lib/noosfero/api/v1/articles.rb
... | ... | @@ -28,6 +28,35 @@ module Noosfero |
28 | 28 | article = find_article(environment.articles, params[:id]) |
29 | 29 | present article, :with => Entities::Article, :fields => params[:fields] |
30 | 30 | end |
31 | + | |
32 | + post ':id/report_abuse' do | |
33 | + article = find_article(environment.articles, params[:id]) | |
34 | + profile = article.profile | |
35 | + begin | |
36 | + abuse_report = AbuseReport.new(:reason => params[:report_abuse]) | |
37 | + if !params[:content_type].blank? | |
38 | + article = params[:content_type].constantize.find(params[:content_id]) | |
39 | + abuse_report.content = article_reported_version(article) | |
40 | + end | |
41 | + | |
42 | + current_person.register_report(abuse_report, profile) | |
43 | + | |
44 | + if !params[:content_type].blank? | |
45 | + abuse_report = AbuseReport.find_by_reporter_id_and_abuse_complaint_id(current_person.id, profile.opened_abuse_complaint.id) | |
46 | + Delayed::Job.enqueue DownloadReportedImagesJob.new(abuse_report, article) | |
47 | + end | |
48 | + | |
49 | + { | |
50 | + :success => true, | |
51 | + :message => _('Your abuse report was registered. The administrators are reviewing your report.'), | |
52 | + } | |
53 | + rescue Exception => exception | |
54 | + #logger.error(exception.to_s) | |
55 | + render_api_error!(_('Your report couldn\'t be saved due to some problem. Please contact the administrator.'), 400) | |
56 | + end | |
57 | + | |
58 | + end | |
59 | + | |
31 | 60 | |
32 | 61 | desc "Returns the total followers for the article" |
33 | 62 | get ':id/followers' do |
... | ... | @@ -141,7 +170,7 @@ module Noosfero |
141 | 170 | article = find_article(community.articles, params[:id]) |
142 | 171 | present article, :with => Entities::Article, :fields => params[:fields] |
143 | 172 | end |
144 | - | |
173 | + | |
145 | 174 | # Example Request: |
146 | 175 | # POST api/v1/communites/:community_id/articles?private_token=234298743290432&article[name]=title&article[body]=body |
147 | 176 | post do | ... | ... |
... | ... | @@ -0,0 +1,30 @@ |
1 | +module Noosfero | |
2 | + module API | |
3 | + module V1 | |
4 | + class Tags < Grape::API | |
5 | + before { authenticate! } | |
6 | + | |
7 | + resource :articles do | |
8 | + | |
9 | + resource ':id/tags' do | |
10 | + | |
11 | + get do | |
12 | + article = find_article(environment.articles, params[:id]) | |
13 | + present article.tag_list | |
14 | + end | |
15 | + | |
16 | + desc "Add a tag to an article" | |
17 | + post do | |
18 | + article = find_article(environment.articles, params[:id]) | |
19 | + article.tag_list=params[:tags] | |
20 | + article.save | |
21 | + present article.tag_list | |
22 | + end | |
23 | + | |
24 | + end | |
25 | + end | |
26 | + | |
27 | + end | |
28 | + end | |
29 | + end | |
30 | +end | ... | ... |