Commit e5407b4aecbdada48742ef5487006db4a37522d9

Authored by Carlos Purificação
1 parent d1347c27

Added export comments to comment_group_plugin

plugins/comment_group/controllers/profile/comment_group_plugin_profile_controller.rb
... ... @@ -19,4 +19,15 @@ class CommentGroupPluginProfileController < ProfileController
19 19 3
20 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 33 end
... ...
plugins/comment_group/lib/comment_group_plugin.rb
... ... @@ -28,7 +28,17 @@ class CommentGroupPlugin < Noosfero::Plugin
28 28 true
29 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 42 end
33 43  
34 44 require_dependency 'comment_group_plugin/macros/allow_comment'
... ...