##// END OF EJS Templates
Forums: attachments can now be added to replies....
Jean-Philippe Lang -
r910:7704e2d9191d
parent child
Show More
@@ -1,61 +1,65
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class MessagesController < ApplicationController
19 19 layout 'base'
20 20 before_filter :find_project, :authorize
21 21
22 22 verify :method => :post, :only => [ :reply, :destroy ], :redirect_to => { :action => :show }
23 23
24 24 helper :attachments
25 25 include AttachmentsHelper
26 26
27 27 def show
28 28 @reply = Message.new(:subject => "RE: #{@message.subject}")
29 29 render :action => "show", :layout => false if request.xhr?
30 30 end
31 31
32 32 def new
33 33 @message = Message.new(params[:message])
34 34 @message.author = User.current
35 35 @message.board = @board
36 36 if request.post? && @message.save
37 37 params[:attachments].each { |file|
38 next unless file.size > 0
39 Attachment.create(:container => @message, :file => file, :author => User.current)
38 Attachment.create(:container => @message, :file => file, :author => User.current) if file.size > 0
40 39 } if params[:attachments] and params[:attachments].is_a? Array
41 40 redirect_to :action => 'show', :id => @message
42 41 end
43 42 end
44 43
45 44 def reply
46 45 @reply = Message.new(params[:reply])
47 46 @reply.author = User.current
48 47 @reply.board = @board
49 48 @message.children << @reply
49 if !@reply.new_record?
50 params[:attachments].each { |file|
51 Attachment.create(:container => @reply, :file => file, :author => User.current) if file.size > 0
52 } if params[:attachments] and params[:attachments].is_a? Array
53 end
50 54 redirect_to :action => 'show', :id => @message
51 55 end
52 56
53 57 private
54 58 def find_project
55 59 @board = Board.find(params[:board_id], :include => :project)
56 60 @project = @board.project
57 61 @message = @board.topics.find(params[:id]) if params[:id]
58 62 rescue ActiveRecord::RecordNotFound
59 63 render_404
60 64 end
61 65 end
@@ -1,14 +1,15
1 1 <%= error_messages_for 'message' %>
2 2
3 3 <div class="box">
4 4 <!--[form:message]-->
5 5 <p><label><%= l(:field_subject) %></label><br />
6 6 <%= f.text_field :subject, :required => true, :size => 120 %></p>
7 7
8 <p><%= f.text_area :content, :required => true, :cols => 80, :rows => 15, :class => 'wiki-edit' %></p>
8 <p><%= f.text_area :content, :required => true, :cols => 80, :rows => 15, :class => 'wiki-edit', :id => 'message_content' %></p>
9 9 <%= wikitoolbar_for 'message_content' %>
10 10 <!--[eoform:message]-->
11 11
12 12 <span class="tabular">
13 13 <%= render :partial => 'attachments/form' %>
14 </span>
14 15 </div>
@@ -1,27 +1,30
1 1 <h2><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> &#187; <%=h @message.subject %></h2>
2 2
3 <div class="message">
3 4 <p><span class="author"><%= authoring @message.created_on, @message.author %></span></p>
4 5 <div class="wiki">
5 6 <%= textilizable(@message.content, :attachments => @message.attachments) %>
6 7 </div>
7 8 <%= link_to_attachments @message.attachments, :no_author => true %>
9 </div>
8 10 <br />
9 11
12 <div class="message reply">
10 13 <h3 class="icon22 icon22-comment"><%= l(:label_reply_plural) %></h3>
11 14 <% @message.children.each do |message| %>
12 15 <a name="<%= "message-#{message.id}" %>"></a>
13 <h4><%=h message.subject %> - <%= message.author.name %>, <%= format_time(message.created_on) %></h4>
16 <h4><%=h message.subject %> - <%= authoring message.created_on, message.author %></h4>
14 17 <div class="wiki"><%= textilizable message.content %></div>
18 <%= link_to_attachments message.attachments, :no_author => true %>
15 19 <% end %>
20 </div>
16 21
17 22 <% if authorize_for('messages', 'reply') %>
18 <p><%= toggle_link l(:button_reply), "reply", :focus => "reply_content" %></p>
23 <p><%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %></p>
19 24 <div id="reply" style="display:none;">
20 <%= error_messages_for 'message' %>
21 <% form_for :reply, @reply, :url => {:action => 'reply', :id => @message} do |f| %>
22 <p><%= f.text_field :subject, :required => true, :size => 60 %></p>
23 <p><%= f.text_area :content, :required => true, :cols => 80, :rows => 10 %></p>
24 <p><%= submit_tag l(:button_submit) %></p>
25 <% form_for :reply, @reply, :url => {:action => 'reply', :id => @message}, :html => {:multipart => true} do |f| %>
26 <%= render :partial => 'form', :locals => {:f => f} %>
27 <%= submit_tag l(:button_submit) %>
25 28 <% end %>
26 29 </div>
27 30 <% end %>
General Comments 0
You need to be logged in to leave comments. Login now