Allows attachments on news (#1972).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8728 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2012-01-29 22:39:06 +00:00
parent 992aebf6df
commit 24138187eb
9 changed files with 80 additions and 18 deletions
+5
View File
@@ -27,6 +27,7 @@ class NewsController < ApplicationController
accept_api_auth :index
helper :watchers
helper :attachments
def index
case params[:format]
@@ -70,6 +71,8 @@ class NewsController < ApplicationController
if request.post?
@news.attributes = params[:news]
if @news.save
attachments = Attachment.attach_files(@news, params[:attachments])
render_attachment_warning_if_needed(@news)
flash[:notice] = l(:notice_successful_create)
redirect_to :controller => 'news', :action => 'index', :project_id => @project
else
@@ -83,6 +86,8 @@ class NewsController < ApplicationController
def update
if request.put? and @news.update_attributes(params[:news])
attachments = Attachment.attach_files(@news, params[:attachments])
render_attachment_warning_if_needed(@news)
flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'show', :id => @news
else
+1
View File
@@ -24,6 +24,7 @@ class News < ActiveRecord::Base
validates_length_of :title, :maximum => 60
validates_length_of :summary, :maximum => 255
acts_as_attachable :delete_permission => :manage_news
acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"], :include => :project
acts_as_event :url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.id}}
acts_as_activity_provider :find_options => {:include => [:project, :author]},
+2 -1
View File
@@ -3,6 +3,7 @@
<p><%= f.text_field :title, :required => true, :size => 60 %></p>
<p><%= f.text_area :summary, :cols => 60, :rows => 2 %></p>
<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 15, :class => 'wiki-edit' %></p>
<p id="attachments_form"><%= label_tag('attachments[1][file]', l(:label_attachment_plural))%><%= render :partial => 'attachments/form' %></p>
</div>
<%= wikitoolbar_for 'news_description' %>
+1 -1
View File
@@ -1,6 +1,6 @@
<h2><%=l(:label_news)%></h2>
<% labelled_form_for @news, :html => { :id => 'news-form', :method => :put } do |f| %>
<% labelled_form_for @news, :html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<%= link_to_remote l(:label_preview),
+1 -1
View File
@@ -8,7 +8,7 @@
<div id="add-news" style="display:none;">
<h2><%=l(:label_news_new)%></h2>
<% labelled_form_for @news, :url => project_news_index_path(@project),
:html => { :id => 'news-form' } do |f| %>
:html => { :id => 'news-form', :multipart => true } do |f| %>
<%= render :partial => 'news/form', :locals => { :f => f } %>
<%= submit_tag l(:button_create) %>
<%= link_to_remote l(:label_preview),
+1 -1
View File
@@ -1,7 +1,7 @@
<h2><%=l(:label_news_new)%></h2>
<% labelled_form_for @news, :url => project_news_index_path(@project),
:html => { :id => 'news-form' } do |f| %>
:html => { :id => 'news-form', :multipart => true } do |f| %>
<%= render :partial => 'news/form', :locals => { :f => f } %>
<%= submit_tag l(:button_create) %>
<%= link_to_remote l(:label_preview),
+3 -2
View File
@@ -17,7 +17,7 @@
<% if authorize_for('news', 'edit') %>
<div id="edit-news" style="display:none;">
<% labelled_form_for :news, @news, :url => news_path(@news),
:html => { :id => 'news-form', :method => :put } do |f| %>
:html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<%= link_to_remote l(:label_preview),
@@ -35,8 +35,9 @@
<p><% unless @news.summary.blank? %><em><%=h @news.summary %></em><br /><% end %>
<span class="author"><%= authoring @news.created_on, @news.author %></span></p>
<div class="wiki">
<%= textilizable(@news.description) %>
<%= textilizable(@news, :description) %>
</div>
<%= link_to_attachments @news %>
<br />
<div id="comments" style="margin-bottom:16px;">