diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 0d091396a..34d4a13cc 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -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 diff --git a/app/models/news.rb b/app/models/news.rb index 763063d13..78dcc0c8c 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -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]}, diff --git a/app/views/news/_form.html.erb b/app/views/news/_form.html.erb index a3eb87e36..0d181a330 100644 --- a/app/views/news/_form.html.erb +++ b/app/views/news/_form.html.erb @@ -3,6 +3,7 @@

<%= 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' %>

+

<%= label_tag('attachments[1][file]', l(:label_attachment_plural))%><%= render :partial => 'attachments/form' %>

- + <%= wikitoolbar_for 'news_description' %> diff --git a/app/views/news/edit.html.erb b/app/views/news/edit.html.erb index 182f22fbe..f00a024c1 100644 --- a/app/views/news/edit.html.erb +++ b/app/views/news/edit.html.erb @@ -1,6 +1,6 @@

<%=l(:label_news)%>

-<% 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), diff --git a/app/views/news/index.html.erb b/app/views/news/index.html.erb index 4d13d3a32..d0370c03f 100644 --- a/app/views/news/index.html.erb +++ b/app/views/news/index.html.erb @@ -8,7 +8,7 @@