From 08cad12de4514b34ca1a15a3b2eb8794a739b6c0 Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Thu, 25 Aug 2016 15:18:27 +0200 Subject: [PATCH] trying to send mail without recipient results in error 500 #560 --- app/controllers/dmsf_controller.rb | 15 +++++++-------- app/views/dmsf/email_entries.html.erb | 6 +++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb index ae1419f1..1e888feb 100644 --- a/app/controllers/dmsf_controller.rb +++ b/app/controllers/dmsf_controller.rb @@ -242,14 +242,12 @@ class DmsfController < ApplicationController def entries_email if params[:email][:to].strip.blank? - flash.now[:error] = l(:error_email_to_must_be_entered) - render :action => 'email_entries' - return + flash[:error] = l(:error_email_to_must_be_entered) + else + DmsfMailer.send_documents(@project, User.current, params[:email]).deliver + File.delete(params[:email][:zipped_content]) + flash[:notice] = l(:notice_email_sent, params[:email][:to]) end - DmsfMailer.send_documents(@project, User.current, params[:email]).deliver - File.delete(params[:email][:zipped_content]) - flash[:notice] = l(:notice_email_sent, params[:email][:to]) - redirect_to dmsf_folder_path(:id => @project, :folder_id => @folder) end @@ -460,7 +458,8 @@ class DmsfController < ApplicationController @email_params = { :zipped_content => zipped_content, :folders => selected_folders, - :files => selected_files + :files => selected_files, + :subject => "#{@project.name} #{l(:label_dmsf_file_plural).downcase}" } render :action => 'email_entries' rescue Exception diff --git a/app/views/dmsf/email_entries.html.erb b/app/views/dmsf/email_entries.html.erb index ada3a4b9..d3ebf78f 100644 --- a/app/views/dmsf/email_entries.html.erb +++ b/app/views/dmsf/email_entries.html.erb @@ -39,15 +39,15 @@

<%= label_tag('email[to]', l(:label_email_to)) %> - <%= text_field_tag('email[to]', @email_params['to'], :style => 'width: 90%;') %> + <%= text_field_tag('email[to]', @email_params[:to], :style => 'width: 90%;', :required => true) %>

<%= label_tag('email[cc]', l(:label_email_cc)) %> - <%= text_field_tag('email[cc]', @email_params['cc'], :style => 'width: 90%;') %> + <%= text_field_tag('email[cc]', @email_params[:cc], :style => 'width: 90%;') %>

<%= label_tag('email[subject]', l(:label_email_subject)) %> - <%= text_field_tag('email[subject]', @email_params['subject'], :style => 'width: 90%;') %> + <%= text_field_tag('email[subject]', @email_params[:subject], :style => 'width: 90%;') %>

<%= label_tag('', l(:label_email_documents)) %>