From 7704e2d9191d00d19115198f981e2262bc11dc25 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Thu, 22 Nov 2007 19:19:47 +0000 Subject: [PATCH] Forums: attachments can now be added to replies. git-svn-id: http://redmine.rubyforge.org/svn/trunk@923 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/messages_controller.rb | 8 ++++++-- app/views/messages/_form.rhtml | 3 ++- app/views/messages/show.rhtml | 17 ++++++++++------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 645aadf1c..9352c4af4 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -35,8 +35,7 @@ class MessagesController < ApplicationController @message.board = @board if request.post? && @message.save params[:attachments].each { |file| - next unless file.size > 0 - Attachment.create(:container => @message, :file => file, :author => User.current) + Attachment.create(:container => @message, :file => file, :author => User.current) if file.size > 0 } if params[:attachments] and params[:attachments].is_a? Array redirect_to :action => 'show', :id => @message end @@ -47,6 +46,11 @@ class MessagesController < ApplicationController @reply.author = User.current @reply.board = @board @message.children << @reply + if !@reply.new_record? + params[:attachments].each { |file| + Attachment.create(:container => @reply, :file => file, :author => User.current) if file.size > 0 + } if params[:attachments] and params[:attachments].is_a? Array + end redirect_to :action => 'show', :id => @message end diff --git a/app/views/messages/_form.rhtml b/app/views/messages/_form.rhtml index e484baf2f..25d88cd44 100644 --- a/app/views/messages/_form.rhtml +++ b/app/views/messages/_form.rhtml @@ -5,10 +5,11 @@


<%= f.text_field :subject, :required => true, :size => 120 %>

-

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

+

<%= f.text_area :content, :required => true, :cols => 80, :rows => 15, :class => 'wiki-edit', :id => 'message_content' %>

<%= wikitoolbar_for 'message_content' %> <%= render :partial => 'attachments/form' %> + diff --git a/app/views/messages/show.rhtml b/app/views/messages/show.rhtml index 772f0653e..e39c09d50 100644 --- a/app/views/messages/show.rhtml +++ b/app/views/messages/show.rhtml @@ -1,27 +1,30 @@

<%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> » <%=h @message.subject %>

+

<%= authoring @message.created_on, @message.author %>

<%= textilizable(@message.content, :attachments => @message.attachments) %>
<%= link_to_attachments @message.attachments, :no_author => true %> +

+

<%= l(:label_reply_plural) %>

<% @message.children.each do |message| %> "> -

<%=h message.subject %> - <%= message.author.name %>, <%= format_time(message.created_on) %>

+

<%=h message.subject %> - <%= authoring message.created_on, message.author %>

<%= textilizable message.content %>
+ <%= link_to_attachments message.attachments, :no_author => true %> <% end %> +
<% if authorize_for('messages', 'reply') %> -

<%= toggle_link l(:button_reply), "reply", :focus => "reply_content" %>

+

<%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %>

<% end %> -- 2.39.5