From 2b779644682bfb2c47e1bf1e30e65a4384e2bf26 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 22 Sep 2007 17:52:43 +0000 Subject: [PATCH] The news list now shows the full news contents. News add/edit forms are now accessible with no additional request. git-svn-id: http://redmine.rubyforge.org/svn/trunk@750 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/projects_controller.rb | 4 ++-- app/views/news/_form.rhtml | 2 +- app/views/news/show.rhtml | 13 ++++++++++- app/views/projects/list_news.rhtml | 26 +++++++++++++++++---- test/functional/projects_controller_test.rb | 2 +- 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index d4b8e5dd..2c9a441c 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -383,11 +383,11 @@ class ProjectsController < ApplicationController # Show news list of @project def list_news - @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "#{News.table_name}.created_on DESC" + @news_pages, @newss = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "#{News.table_name}.created_on DESC" respond_to do |format| format.html { render :layout => false if request.xhr? } - format.atom { render_feed(@news, :title => "#{@project.name}: #{l(:label_news_plural)}") } + format.atom { render_feed(@newss, :title => "#{@project.name}: #{l(:label_news_plural)}") } end end diff --git a/app/views/news/_form.rhtml b/app/views/news/_form.rhtml index 1ea3c6aa..0cfe7a6d 100644 --- a/app/views/news/_form.rhtml +++ b/app/views/news/_form.rhtml @@ -1,5 +1,5 @@ <%= error_messages_for 'news' %> -
+

<%= f.text_field :title, :required => true, :size => 60 %>

<%= f.text_area :summary, :cols => 60, :rows => 2 %>

<%= f.text_area :description, :required => true, :cols => 60, :rows => 15, :class => 'wiki-edit' %>

diff --git a/app/views/news/show.rhtml b/app/views/news/show.rhtml index 5f92801f..21316212 100644 --- a/app/views/news/show.rhtml +++ b/app/views/news/show.rhtml @@ -1,10 +1,21 @@
-<%= link_to_if_authorized l(:button_edit), {:controller => 'news', :action => 'edit', :id => @news}, :class => 'icon icon-edit' %> +<%= link_to_if_authorized l(:button_edit), + {:controller => 'news', :action => 'edit', :id => @news}, + :class => 'icon icon-edit', + :onclick => 'Element.show("edit-news"); return false;' %> <%= link_to_if_authorized l(:button_delete), {:controller => 'news', :action => 'destroy', :id => @news}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %>

<%=h @news.title %>

+ +

<% unless @news.summary.empty? %><%=h @news.summary %>
<% end %> <%= authoring @news.created_on, @news.author %>

<%= textilizable(@news.description) %> diff --git a/app/views/projects/list_news.rhtml b/app/views/projects/list_news.rhtml index 82d63a28..b58524e3 100644 --- a/app/views/projects/list_news.rhtml +++ b/app/views/projects/list_news.rhtml @@ -1,15 +1,31 @@
-<%= link_to_if_authorized l(:label_news_new), {:controller => 'projects', :action => 'add_news', :id => @project}, :class => 'icon icon-add' %> +<%= link_to_if_authorized l(:label_news_new), + {:controller => 'projects', :action => 'add_news', :id => @project}, + :class => 'icon icon-add', + :onclick => 'Element.show("add-news"); return false;' %> +
+ +

<%=l(:label_news_plural)%>

-<% if @news.empty? %> +<% if @newss.empty? %>

<%= l(:label_no_data) %>

+<% else %> +<% @newss.each do |news| %> +

<%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news %> + <%= "(#{news.comments_count} #{lwr(:label_comment, news.comments_count).downcase})" if news.comments_count > 0 %>

+

<%= authoring news.created_on, news.author %>

+ <%= textilizable(news.description) %> +<% end %> <% end %> - - -<%= render :partial => 'news/news', :collection => @news %> <%= pagination_links_full @news_pages %> <% content_for :header_tags do %> diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index 5990cd0e..b065d82b 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -88,7 +88,7 @@ class ProjectsControllerTest < Test::Unit::TestCase get :list_news, :id => 1 assert_response :success assert_template 'list_news' - assert_not_nil assigns(:news) + assert_not_nil assigns(:newss) end def test_list_files