Forums: attachments can now be added to replies.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@923 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2007-11-22 19:19:47 +00:00
parent 0634591b3d
commit 7704e2d919
3 changed files with 18 additions and 10 deletions

View File

@ -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

View File

@ -5,10 +5,11 @@
<p><label><%= l(:field_subject) %></label><br />
<%= f.text_field :subject, :required => true, :size => 120 %></p>
<p><%= f.text_area :content, :required => true, :cols => 80, :rows => 15, :class => 'wiki-edit' %></p>
<p><%= f.text_area :content, :required => true, :cols => 80, :rows => 15, :class => 'wiki-edit', :id => 'message_content' %></p>
<%= wikitoolbar_for 'message_content' %>
<!--[eoform:message]-->
<span class="tabular">
<%= render :partial => 'attachments/form' %>
</span>
</div>

View File

@ -1,27 +1,30 @@
<h2><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> &#187; <%=h @message.subject %></h2>
<div class="message">
<p><span class="author"><%= authoring @message.created_on, @message.author %></span></p>
<div class="wiki">
<%= textilizable(@message.content, :attachments => @message.attachments) %>
</div>
<%= link_to_attachments @message.attachments, :no_author => true %>
</div>
<br />
<div class="message reply">
<h3 class="icon22 icon22-comment"><%= l(:label_reply_plural) %></h3>
<% @message.children.each do |message| %>
<a name="<%= "message-#{message.id}" %>"></a>
<h4><%=h message.subject %> - <%= message.author.name %>, <%= format_time(message.created_on) %></h4>
<h4><%=h message.subject %> - <%= authoring message.created_on, message.author %></h4>
<div class="wiki"><%= textilizable message.content %></div>
<%= link_to_attachments message.attachments, :no_author => true %>
<% end %>
</div>
<% if authorize_for('messages', 'reply') %>
<p><%= toggle_link l(:button_reply), "reply", :focus => "reply_content" %></p>
<p><%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %></p>
<div id="reply" style="display:none;">
<%= error_messages_for 'message' %>
<% form_for :reply, @reply, :url => {:action => 'reply', :id => @message} do |f| %>
<p><%= f.text_field :subject, :required => true, :size => 60 %></p>
<p><%= f.text_area :content, :required => true, :cols => 80, :rows => 10 %></p>
<p><%= submit_tag l(:button_submit) %></p>
<% form_for :reply, @reply, :url => {:action => 'reply', :id => @message}, :html => {:multipart => true} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<%= submit_tag l(:button_submit) %>
<% end %>
</div>
<% end %>