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