Commit e5407b4aecbdada48742ef5487006db4a37522d9
1 parent
d1347c27
Exists in
staging
and in
3 other branches
Added export comments to comment_group_plugin
Showing
2 changed files
with
22 additions
and
1 deletions
Show diff stats
plugins/comment_group/controllers/profile/comment_group_plugin_profile_controller.rb
| @@ -19,4 +19,15 @@ class CommentGroupPluginProfileController < ProfileController | @@ -19,4 +19,15 @@ class CommentGroupPluginProfileController < ProfileController | ||
| 19 | 3 | 19 | 3 |
| 20 | end | 20 | end |
| 21 | 21 | ||
| 22 | + include CommentGroupPlugin::CommentsReport | ||
| 23 | + | ||
| 24 | + def export_comments | ||
| 25 | + article_id = params[:id] | ||
| 26 | + article = profile.articles.find(article_id) | ||
| 27 | + result = export_comments_csv(article) | ||
| 28 | + filename = "comments_for_article#{article_id}_#{DateTime.now.to_i}.csv" | ||
| 29 | + send_data result, | ||
| 30 | + :type => 'text/csv; charset=UTF-8; header=present', | ||
| 31 | + :disposition => "attachment; filename=#{filename}" | ||
| 32 | + end | ||
| 22 | end | 33 | end |
plugins/comment_group/lib/comment_group_plugin.rb
| @@ -28,7 +28,17 @@ class CommentGroupPlugin < Noosfero::Plugin | @@ -28,7 +28,17 @@ class CommentGroupPlugin < Noosfero::Plugin | ||
| 28 | true | 28 | true |
| 29 | end | 29 | end |
| 30 | 30 | ||
| 31 | - | 31 | + def article_extra_toolbar_buttons(article) |
| 32 | + user = context.send :user | ||
| 33 | + return [] if !article.comment_group_plugin_enabled? || !article.allow_edit?(user) | ||
| 34 | + [ | ||
| 35 | + { | ||
| 36 | + :title => _('Export Comments'), | ||
| 37 | + :url => {:controller => 'comment_group_plugin_profile', :profile => article.profile.identifier, :action => 'export_comments', :id => article.id}, | ||
| 38 | + :icon => :toggle_comment_paragraph | ||
| 39 | + } | ||
| 40 | + ] | ||
| 41 | + end | ||
| 32 | end | 42 | end |
| 33 | 43 | ||
| 34 | require_dependency 'comment_group_plugin/macros/allow_comment' | 44 | require_dependency 'comment_group_plugin/macros/allow_comment' |