Commit ecfd75562d9adf32cab6effa7a90ede6cb4cfc5a
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'AI3220_proposals' into stable
Showing
5 changed files
with
67 additions
and
1 deletions
Show diff stats
plugins/proposals_discussion/controllers/profile/proposals_discussion_plugin_profile_controller.rb
0 → 100644
plugins/proposals_discussion/lib/proposals_discussion_plugin/discussion.rb
| @@ -4,6 +4,7 @@ class ProposalsDiscussionPlugin::Discussion < Folder | @@ -4,6 +4,7 @@ class ProposalsDiscussionPlugin::Discussion < Folder | ||
| 4 | 4 | ||
| 5 | has_many :topics, :class_name => 'ProposalsDiscussionPlugin::Topic', :foreign_key => 'parent_id' | 5 | has_many :topics, :class_name => 'ProposalsDiscussionPlugin::Topic', :foreign_key => 'parent_id' |
| 6 | has_many :proposals, :class_name => 'ProposalsDiscussionPlugin::Proposal', :through => :children, :source => :children | 6 | has_many :proposals, :class_name => 'ProposalsDiscussionPlugin::Proposal', :through => :children, :source => :children |
| 7 | + has_many :proposals_comments, :class_name => 'Comment', :through => :proposals, :source => :comments | ||
| 7 | 8 | ||
| 8 | settings_items :custom_body_label, :type => :string, :default => _('Body') | 9 | settings_items :custom_body_label, :type => :string, :default => _('Body') |
| 9 | 10 |
plugins/proposals_discussion/test/functional/proposals_discussion_plugin_profile_controller_test.rb
0 → 100644
| @@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
| 1 | +require File.dirname(__FILE__) + '/../test_helper' | ||
| 2 | + | ||
| 3 | +class ProposalsDiscussionPluginProfileControllerTest < ActionController::TestCase | ||
| 4 | + | ||
| 5 | + def setup | ||
| 6 | + @profile = fast_create(Community) | ||
| 7 | + @discussion = fast_create(ProposalsDiscussionPlugin::Discussion, :profile_id => @profile.id) | ||
| 8 | + @topic = fast_create(ProposalsDiscussionPlugin::Topic, :parent_id => @discussion.id, :profile_id => @profile.id) | ||
| 9 | + @person = create_user_with_permission('testinguser', 'post_content') | ||
| 10 | + login_as :testinguser | ||
| 11 | + end | ||
| 12 | + | ||
| 13 | + attr_reader :profile, :discussion, :topic, :person | ||
| 14 | + | ||
| 15 | + should 'assigns comments of all proposals' do | ||
| 16 | + proposal1 = fast_create(ProposalsDiscussionPlugin::Proposal, :profile_id => profile.id, :parent_id => topic.id) | ||
| 17 | + proposal2 = fast_create(ProposalsDiscussionPlugin::Proposal, :profile_id => profile.id, :parent_id => topic.id) | ||
| 18 | + comment1 = fast_create(Comment, :source_id => proposal1.id) | ||
| 19 | + comment2 = fast_create(Comment, :source_id => proposal1.id) | ||
| 20 | + comment3 = fast_create(Comment, :source_id => proposal2.id) | ||
| 21 | + get :export, :format => :csv, :article_id => discussion.id, :profile => profile.identifier | ||
| 22 | + assert_equivalent [comment1, comment2, comment3], assigns(:comments) | ||
| 23 | + end | ||
| 24 | + | ||
| 25 | +end |
plugins/proposals_discussion/views/content_viewer/discussion.html.erb
| @@ -8,9 +8,12 @@ | @@ -8,9 +8,12 @@ | ||
| 8 | 8 | ||
| 9 | <% if discussion.allow_create?(user) %> | 9 | <% if discussion.allow_create?(user) %> |
| 10 | <div class="actions"> | 10 | <div class="actions"> |
| 11 | - <%= link_to url_for({:controller => 'cms', :action => 'new', :type => "ProposalsDiscussionPlugin::Topic", :parent_id => discussion.id}), :class => 'button with-text icon-add' do %> | 11 | + <%= link_to({:controller => 'cms', :action => 'new', :type => "ProposalsDiscussionPlugin::Topic", :parent_id => discussion.id}, :class => 'button with-text icon-add') do %> |
| 12 | <strong><%= _("New Topic") %></strong> | 12 | <strong><%= _("New Topic") %></strong> |
| 13 | <% end %> | 13 | <% end %> |
| 14 | + <%= link_to({:controller => :proposals_discussion_plugin_profile, :action => :export, :format => :csv, :article_id => discussion.id}, :class => 'button with-text icon-spread') do %> | ||
| 15 | + <strong><%= _('Export') %></strong> | ||
| 16 | + <% end %> | ||
| 14 | </div> | 17 | </div> |
| 15 | <% end %> | 18 | <% end %> |
| 16 | 19 |
plugins/proposals_discussion/views/proposals_discussion_plugin_profile/export.csv.erb
0 → 100644
| @@ -0,0 +1,30 @@ | @@ -0,0 +1,30 @@ | ||
| 1 | +<% require 'csv' %> | ||
| 2 | + | ||
| 3 | +<% header = [ | ||
| 4 | + _('Topic'), | ||
| 5 | + _('Proposal'), | ||
| 6 | + _('Author'), | ||
| 7 | + _('Author Email'), | ||
| 8 | + _('Title'), | ||
| 9 | + _('Body'), | ||
| 10 | + _('Date') | ||
| 11 | +] %> | ||
| 12 | +<% header << _('Likes') if environment.plugin_enabled?('VotePlugin') %> | ||
| 13 | +<% header << _('Dislikes') if environment.plugin_enabled?('VotePlugin') %> | ||
| 14 | + | ||
| 15 | +<%= CSV.generate_line(header, :row_sep => ?\t, :quote_char => ?\ ) %> | ||
| 16 | + | ||
| 17 | +<% @comments.each do |comment| %> | ||
| 18 | + <% line = [ | ||
| 19 | + comment.source.parent ? comment.source.parent.name : '', | ||
| 20 | + comment.source.name, | ||
| 21 | + comment.author_name, | ||
| 22 | + comment.author_email, | ||
| 23 | + comment.title, | ||
| 24 | + comment.body, | ||
| 25 | + comment.created_at, | ||
| 26 | + ] %> | ||
| 27 | + <% line << comment.votes_for if environment.plugin_enabled?('VotePlugin') %> | ||
| 28 | + <% line << comment.votes_against if environment.plugin_enabled?('VotePlugin') %> | ||
| 29 | + <%= CSV.generate_line(line, :row_sep => ?\t, :quote_char => ?\ ) %> | ||
| 30 | +<% end %> |