Commit c6d67b73c057085f15e1863c356f25b0ebb43c07
1 parent
a3dea573
Exists in
staging
and in
30 other branches
api: fix creation of specific article
Showing
1 changed file
with
1 additions
and
3 deletions
Show diff stats
lib/noosfero/api/helpers.rb
@@ -98,8 +98,6 @@ require_relative '../../find_by_contents' | @@ -98,8 +98,6 @@ require_relative '../../find_by_contents' | ||
98 | end | 98 | end |
99 | end | 99 | end |
100 | 100 | ||
101 | - ARTICLE_TYPES = ['Article'] + Article.descendants.map{|a| a.to_s} | ||
102 | - | ||
103 | def find_article(articles, id) | 101 | def find_article(articles, id) |
104 | article = articles.find(id) | 102 | article = articles.find(id) |
105 | article.display_to?(current_person) ? article : forbidden! | 103 | article.display_to?(current_person) ? article : forbidden! |
@@ -109,7 +107,7 @@ require_relative '../../find_by_contents' | @@ -109,7 +107,7 @@ require_relative '../../find_by_contents' | ||
109 | return forbidden! unless current_person.can_post_content?(asset) | 107 | return forbidden! unless current_person.can_post_content?(asset) |
110 | 108 | ||
111 | klass_type = params[:content_type] || params[:article].delete(:type) || TinyMceArticle.name | 109 | klass_type = params[:content_type] || params[:article].delete(:type) || TinyMceArticle.name |
112 | - return forbidden! unless ARTICLE_TYPES.include?(klass_type) | 110 | + return forbidden! unless klass_type.constantize <= Article |
113 | 111 | ||
114 | article = klass_type.constantize.new(params[:article]) | 112 | article = klass_type.constantize.new(params[:article]) |
115 | article.last_changed_by = current_person | 113 | article.last_changed_by = current_person |