Include attachments in forum post notifications (#16006).

Patch by Yuichi HARADA.


git-svn-id: http://svn.redmine.org/redmine/trunk@19506 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2020-02-11 02:34:25 +00:00
parent b6d26dc170
commit dec5f98112
4 changed files with 42 additions and 7 deletions

View File

@@ -77,10 +77,10 @@ class MessagesController < ApplicationController
@reply.author = User.current
@reply.board = @board
@reply.safe_attributes = params[:reply]
@reply.save_attachments(params[:attachments])
@topic.children << @reply
if !@reply.new_record?
call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply})
attachments = Attachment.attach_files(@reply, params[:attachments])
render_attachment_warning_if_needed(@reply)
end
flash[:notice] = l(:notice_successful_update)
@@ -91,12 +91,14 @@ class MessagesController < ApplicationController
def edit
(render_403; return false) unless @message.editable_by?(User.current)
@message.safe_attributes = params[:message]
if request.post? && @message.save
attachments = Attachment.attach_files(@message, params[:attachments])
render_attachment_warning_if_needed(@message)
flash[:notice] = l(:notice_successful_update)
@message.reload
redirect_to board_message_path(@message.board, @message.root, :r => (@message.parent_id && @message.id))
if request.post?
@message.save_attachments(params[:attachments])
if @message.save
render_attachment_warning_if_needed(@message)
flash[:notice] = l(:notice_successful_update)
@message.reload
redirect_to board_message_path(@message.board, @message.root, :r => (@message.parent_id && @message.id))
end
end
end

View File

@@ -2,3 +2,11 @@
<em><%= @message.author %></em>
<%= textilizable(@message, :content, :only_path => false) %>
<% if @message.attachments.any? -%>
<fieldset class="attachments"><legend><%= l(:label_attachment_plural) %></legend>
<% @message.attachments.each do |attachment| -%>
<%= link_to_attachment attachment, :download => true, :only_path => false %> (<%= number_to_human_size(attachment.filesize) %>)<br />
<% end -%>
</fieldset>
<% end -%>

View File

@@ -2,3 +2,10 @@
<%= @message.author %>
<%= @message.content %>
<% if @message.attachments.any? -%>
---<%= l(:label_attachment_plural).ljust(37, '-') %>
<% @message.attachments.each do |attachment| -%>
<%= attachment.filename %> (<%= number_to_human_size(attachment.filesize) %>)
<% end -%>
<% end -%>