From 44c103f3d1f213305c79c9cac4e3d95e2fbc1474 Mon Sep 17 00:00:00 2001 From: Godwin Date: Tue, 19 Jul 2016 21:59:33 -0700 Subject: [PATCH] Added time to error report and translated emails into recipients locale instead of senders --- app/controllers/application_controller.rb | 9 +++++--- app/controllers/conferences_controller.rb | 22 +++++++------------- app/mailers/user_mailer.rb | 3 ++- app/views/user_mailer/error_report.html.haml | 3 +++ 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 309dea9..e4903c3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -158,6 +158,7 @@ class ApplicationController < LinguaFrancaApplicationController request, params, current_user, + Time.now.strftime("%d/%m/%Y %H:%M") ] end if Rails.env.preview? || Rails.env.production? rescue exception2 @@ -218,8 +219,9 @@ class ApplicationController < LinguaFrancaApplicationController request, params, current_user, + Time.now.strftime("%d/%m/%Y %H:%M") ] - end if Rails.env.preview? || Rails.env.production? + end# if Rails.env.preview? || Rails.env.production? end # raise the error if we are in development so that we can debug it @@ -403,7 +405,7 @@ class ApplicationController < LinguaFrancaApplicationController if object.respond_to?(:get_translators) object.get_translators(data, locale).each do |id, user| if user.id != current_user.id && user.id != translator_id - UserMailer.send_mail mailer do + UserMailer.send_mail mailer, user.locale do { :args => [object, data, locale, user, translator] } end end @@ -417,7 +419,7 @@ class ApplicationController < LinguaFrancaApplicationController if object.respond_to?(:get_translators) object.get_translators(data).each do |id, user| if user.id != current_user.id - UserMailer.send_mail mailer do + UserMailer.send_mail mailer, user.locale do { :args => [object, data, user, current_user] } end end @@ -440,6 +442,7 @@ class ApplicationController < LinguaFrancaApplicationController request, params, current_user, + Time.now.strftime("%d/%m/%Y %H:%M") ] end if Rails.env.preview? || Rails.env.production? rescue exception2 diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index 780100f..4e54a48 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -1614,10 +1614,8 @@ class ConferencesController < ApplicationController workshop.id, user_id) f.role = :collaborator f.save - UserMailer.send_mail :workshop_facilitator_request_approved do - { - :args => [ workshop, user ] - } + UserMailer.send_mail :workshop_facilitator_request_approved, user.locale do + [ workshop, user ] end return redirect_to view_workshop_url(@this_conference.slug, workshop.id) end @@ -1626,10 +1624,8 @@ class ConferencesController < ApplicationController WorkshopFacilitator.delete_all( :workshop_id => workshop.id, :user_id => user_id) - UserMailer.send_mail :workshop_facilitator_request_denied do - { - :args => [ workshop, user ] - } + UserMailer.send_mail :workshop_facilitator_request_denied, user.locale do + [ workshop, user ] end return redirect_to view_workshop_url(@this_conference.slug, workshop.id) end @@ -1669,10 +1665,8 @@ class ConferencesController < ApplicationController unless workshop.facilitator?(user) WorkshopFacilitator.create(user_id: user.id, workshop_id: workshop.id, role: :collaborator) - UserMailer.send_mail :workshop_facilitator_request_approved do - { - :args => [ workshop, user ] - } + UserMailer.send_mail :workshop_facilitator_request_approved, user.locale do + [ workshop, user ] end end @@ -1690,14 +1684,14 @@ class ConferencesController < ApplicationController comment = Comment.find_by!(id: params[:comment_id].to_i, model_type: :workshops, model_id: workshop.id) new_comment = comment.add_comment(current_user, params[:reply]) - UserMailer.send_mail :workshop_comment do + UserMailer.send_mail :workshop_comment, comment.user.locale do [ workshop, new_comment, comment.user ] end elsif params[:button] = 'add_comment' new_comment = workshop.add_comment(current_user, params[:comment]) workshop.active_facilitators.each do | u | - UserMailer.send_mail :workshop_comment do + UserMailer.send_mail :workshop_comment, u.locale do [ workshop, new_comment, u ] end end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index b02b8c8..cbab8b2 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -129,13 +129,14 @@ class UserMailer < ActionMailer::Base mail to: @user.named_email, subject: @subject end - def error_report(subject, message, report, exception, request, params, user) + def error_report(subject, message, report, exception, request, params, user, time = nil) @subject = subject @message = message @report = report @exception = exception @request = request @params = params + @time = time @user = User.find(user) if user.present? mail to: 'goodgodwin@hotmail.com', subject: @subject end diff --git a/app/views/user_mailer/error_report.html.haml b/app/views/user_mailer/error_report.html.haml index 3b6b83e..1ca2c22 100644 --- a/app/views/user_mailer/error_report.html.haml +++ b/app/views/user_mailer/error_report.html.haml @@ -28,6 +28,9 @@ %tr %td URL %td=@request['original_url'] + %tr + %td Time + %td=@time %h1 Params %table.error-report