From d240b51128d971ab2c3bf3cff29404824a0d4c52 Mon Sep 17 00:00:00 2001 From: MoisesMachado Date: Thu, 4 Sep 2008 16:49:29 +0000 Subject: [PATCH] ActionItem234: final touches to the moderation of articles --- app/controllers/my_profile/cms_controller.rb | 3 +++ app/views/cms/publish.rhtml | 3 ++- app/views/cms/view.rhtml | 1 + app/views/content_viewer/view_page.rhtml | 8 +++++--- app/views/tasks/_approve_article.rhtml | 4 ++-- test/functional/content_viewer_controller_test.rb | 11 +++++++++++ 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index 3fac1a9..7fe52bb 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -131,7 +131,9 @@ class CmsController < MyProfileController end def publish + @article = profile.articles.find(params[:id]) + record_coming_from_public_view @groups = profile.memberships - [profile] @marked_groups = [] groups_ids = profile.memberships.map{|m|m.id.to_s} @@ -145,6 +147,7 @@ class CmsController < MyProfileController task = ApproveArticle.create!(:article => @article, :name => item[:name], :target => item[:group], :requestor => profile) task.finish unless item[:group].moderated_articles? end + redirect_back end end diff --git a/app/views/cms/publish.rhtml b/app/views/cms/publish.rhtml index d9c7f5c..5dcbfd1 100644 --- a/app/views/cms/publish.rhtml +++ b/app/views/cms/publish.rhtml @@ -1,7 +1,8 @@

<%= _('Select the groups where you want to publish your article') %>

<% form_tag do%> - <% @groups.each do |group| %> + <%= hidden_field_tag :back_to, @back_to %> + <% @groups.each do |group| %> <%= labelled_check_box group.name, 'marked_groups[][group_id]', group.id, @marked_groups.include?(group) %>
<%= labelled_text_field _('Title') + ': ', 'marked_groups[][name]', @article.name %>
diff --git a/app/views/cms/view.rhtml b/app/views/cms/view.rhtml index b55f880..e47fcfe 100644 --- a/app/views/cms/view.rhtml +++ b/app/views/cms/view.rhtml @@ -65,6 +65,7 @@ <%= link_to _('Edit'), :action => 'edit', :id => item.id %> <%= link_to _('Public view'), item.url %> + <%= link_to _('Spread this'), :action => 'publish', :id => item.id %> <%= link_to _('Use as homepage'), { :action => 'set_home_page', :id => item.id }, :method => :post %> <%= link_to _('Delete'), { :action => 'destroy', :id => item.id }, :method => :post, :confirm => _('Are you sure that you want to remove this item?') %> diff --git a/app/views/content_viewer/view_page.rhtml b/app/views/content_viewer/view_page.rhtml index 3bd4d14..4d01a59 100644 --- a/app/views/content_viewer/view_page.rhtml +++ b/app/views/content_viewer/view_page.rhtml @@ -35,9 +35,11 @@ <%= link_to content_tag( 'span', _('Edit') ), { :controller => 'cms', :action => 'edit', :id => @page }, :class => 'button with-text icon-edit' %> - <%= link_to content_tag( 'span', _('Publish') ), - { :controller => 'cms', :action => 'publish', :id => @page }, - :class => 'button with-text icon-edit' %> + <% if profile.kind_of?(Person) %> + <%= link_to content_tag( 'span', _('Spread this') ), + { :controller => 'cms', :action => 'publish', :id => @page }, + :class => 'button with-text icon-edit' %> + <% end %> <%= lightbox_button(:new, _('New publication'), :controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : nil)) %> <% end %> diff --git a/app/views/tasks/_approve_article.rhtml b/app/views/tasks/_approve_article.rhtml index bb0a2bc..6a6f804 100644 --- a/app/views/tasks/_approve_article.rhtml +++ b/app/views/tasks/_approve_article.rhtml @@ -19,9 +19,9 @@ :onclick => "Element.hide('group-for-friend-#{task.id}')") %> - <%= labelled_form_field _('Name for publishing'), f.text_field(:name) %> + <%= labelled_form_field _('Name for publishing'), f.text_field(:name, :style => 'width:80%;') %> - <%= labelled_form_field(_('Closing statment'), f.text_area(:closing_statment) ) %> + <%= labelled_form_field _('Comment for author'), f.text_area(:closing_statment, :style => 'height:200px; width:80%;') %> diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index ac13a8d..1efb0d7 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -412,5 +412,16 @@ class ContentViewerControllerTest < Test::Unit::TestCase assert_tag :tag => 'a', :attributes => {:href => ('/myprofile/' + profile.identifier + '/cms/publish/' + page.id.to_s)} end + + should 'not show link to publication on view if not on person profile' do + prof = Community.create!(:name => 'test comm', :identifier => 'test_comm') + page = prof.articles.create!(:name => 'myarticle', :body => 'the body of the text') + prof.affiliate(profile, Profile::Roles.all_roles) + login_as(profile.identifier) + + get :view_page, :profile => prof.identifier, :page => ['myarticle'] + + assert_no_tag :tag => 'a', :attributes => {:href => ('/myprofile/' + prof.identifier + '/cms/publish/' + page.id.to_s)} + end end -- libgit2 0.21.2