Commit 70a0ff47f7e7afc8482fbc931feabc0d3b8cbc0a
Exists in
master
and in
7 other branches
Merge branch 'master' of https://gitlab.com/noosfero-plugins/proposals_discussion
Showing
2 changed files
with
7 additions
and
4 deletions
Show diff stats
lib/proposals_discussion_plugin/api.rb
| 1 | 1 | class ProposalsDiscussionPlugin::API < Grape::API |
| 2 | 2 | |
| 3 | - | |
| 4 | 3 | resource :proposals_discussion_plugin do |
| 5 | 4 | |
| 6 | 5 | paginate per_page: 10, max_per_page: 20 |
| ... | ... | @@ -26,11 +25,11 @@ class ProposalsDiscussionPlugin::API < Grape::API |
| 26 | 25 | post ':id/propose' do |
| 27 | 26 | sanitize_params_hash(params) |
| 28 | 27 | |
| 29 | - parent_article = environment.articles.find(params[:id]) | |
| 28 | + parent_article = environment.articles.includes(:profile).find(params[:id]) | |
| 30 | 29 | |
| 31 | 30 | proposal_task = ProposalsDiscussionPlugin::ProposalTask.new |
| 32 | 31 | proposal_task.article = params[:article] |
| 33 | - proposal_task.article_parent_id = parent_article.id | |
| 32 | + proposal_task.article_parent = parent_article | |
| 34 | 33 | proposal_task.target = parent_article.profile |
| 35 | 34 | proposal_task.requestor = current_person |
| 36 | 35 | ... | ... |
lib/proposals_discussion_plugin/proposal_task.rb
| ... | ... | @@ -129,8 +129,12 @@ class ProposalsDiscussionPlugin::ProposalTask < Task |
| 129 | 129 | requestor.name if requestor |
| 130 | 130 | end |
| 131 | 131 | |
| 132 | + def article_parent=(parent) | |
| 133 | + @article_parent = parent | |
| 134 | + end | |
| 135 | + | |
| 132 | 136 | def article_parent |
| 133 | - Article.find_by_id article_parent_id.to_i | |
| 137 | + @article_parent ||= Article.find_by_id article_parent_id.to_i | |
| 134 | 138 | end |
| 135 | 139 | |
| 136 | 140 | def article_object | ... | ... |