From a17980e7a739fcb18afac474ab5a598e5207046d Mon Sep 17 00:00:00 2001 From: chiu Date: Wed, 20 May 2020 20:14:02 +0800 Subject: [PATCH] add editor to email --- app/controllers/admin/property_hires_controller.rb | 4 ++-- app/helpers/admin/property_hires_helper.rb | 6 +++--- app/views/email/delete_email.html.erb | 1 + app/views/email/edit_email.html.erb | 1 + config/locales/en.yml | 1 + config/locales/zh_tw.yml | 1 + 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/controllers/admin/property_hires_controller.rb b/app/controllers/admin/property_hires_controller.rb index 83b42bc..6f0e8c8 100644 --- a/app/controllers/admin/property_hires_controller.rb +++ b/app/controllers/admin/property_hires_controller.rb @@ -43,7 +43,7 @@ class Admin::PropertyHiresController < OrbitAdminController property = Property.find(params[:id]) rescue nil email = Array(MemberProfile.find(property.owners)).collect{|v| v.email} rescue [] email = User.all.select{|v| v.is_admin? && v.user_name != 'rulingcom'}.collect{|v| v.member_profile.email} if email.length == 0 - Admin::PropertyHiresHelper::HireMethod.send_mail('delete',email,property.id) + Admin::PropertyHiresHelper::HireMethod.send_mail('delete',email,property.id,nil,nil,current_user.id) property.destroy if !property.nil? if params[:page] redirect_to admin_property_hires_path(:page => params[:page]) @@ -58,7 +58,7 @@ class Admin::PropertyHiresController < OrbitAdminController property.update_attributes(property_params) email = Array(MemberProfile.find(property.owners)).collect{|v| v.email} rescue [] email = User.all.select{|v| v.is_admin? && v.user_name != 'rulingcom'}.collect{|v| v.member_profile.email} if email.length == 0 - Admin::PropertyHiresHelper::HireMethod.send_mail('edit',email,property.id) + Admin::PropertyHiresHelper::HireMethod.send_mail('edit',email,property.id,nil,nil,current_user.id) if params[:page] redirect_to admin_property_hires_path(:page => params[:page]) else diff --git a/app/helpers/admin/property_hires_helper.rb b/app/helpers/admin/property_hires_helper.rb index 9d2302b..cb29814 100644 --- a/app/helpers/admin/property_hires_helper.rb +++ b/app/helpers/admin/property_hires_helper.rb @@ -63,7 +63,7 @@ module Admin::PropertyHiresHelper a = multiple_lang_tag(key_field,markup,"#{key_index}][#{field}",field_sets,custom_options,end_block,{},markup=='text_area') a.html_safe end - def self.send_mail(field_name,email,property_id,send_date=nil,hire_id=nil) + def self.send_mail(field_name,email,property_id,send_date=nil,hire_id=nil,user_id=nil) property = Property.where(id: property_id).first if !property.nil? email_set = property.hire_email_sets.select{|v| v.field_name == field_name} @@ -76,14 +76,14 @@ module Admin::PropertyHiresHelper template:"email/#{field_name}_email.html.erb", mail_sentdate: send_date || Time.current, mail_subject: I18n.t("property_hire.email_#{field_name}_success"), - template_data:{'property_id'=>property_id,'content'=>content,'locale'=>I18n.locale.to_s,'hire_id'=>hire_id}) + template_data:{'property_id'=>property_id,'content'=>content,'locale'=>I18n.locale.to_s,'hire_id'=>hire_id,'user_id'=>user_id}) elsif !(email_set[0].disabled) mail = Email.create(mail_to: Array(email), module_app_key:"property_hire", template:"email/#{field_name}_email.html.erb", mail_sentdate: send_date || Time.current, mail_subject: email_set[0].title[I18n.locale], - template_data:{'property_id'=>property_id,'email_set_content'=>email_set[0].content.to_yaml,'content'=>content,'locale'=>I18n.locale.to_s,'hire_id'=>hire_id}) + template_data:{'property_id'=>property_id,'email_set_content'=>email_set[0].content.to_yaml,'content'=>content,'locale'=>I18n.locale.to_s,'hire_id'=>hire_id,'user_id'=>user_id}) end begin mail.deliver diff --git a/app/views/email/delete_email.html.erb b/app/views/email/delete_email.html.erb index ba959ec..0ab848e 100644 --- a/app/views/email/delete_email.html.erb +++ b/app/views/email/delete_email.html.erb @@ -9,6 +9,7 @@ <% property = Property.where(id: @data['property_id']).first %> <% if !property.nil? %>

<%= property['title'].collect{|k,v| v}.uniq.join('/') rescue nil %>

+ <%= t('property_hire.editor') %>: <%= User.find(user_id).name rescue nil %> <% I18n.with_locale(@data['locale']) do %> diff --git a/app/views/email/edit_email.html.erb b/app/views/email/edit_email.html.erb index 8a31a21..3290086 100644 --- a/app/views/email/edit_email.html.erb +++ b/app/views/email/edit_email.html.erb @@ -8,6 +8,7 @@ <%= t('property_hire.email_edit_success') %> <% end %>

<%= property['title'].collect{|k,v| v}.uniq.join('/') rescue nil %>

+<%= t('property_hire.editor') %>: <%= User.find(user_id).name rescue nil %> <% I18n.with_locale(@data['locale']) do %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index 612b409..6b8b034 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,5 +1,6 @@ en: property_hire: + editor: Editor email_p_hire_success: Hire Success email_edit_success: 'Property Hire Module:Edit Success' email_delete_success: 'Property Hire Module:Delete Success' diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 3e0a4d2..a32891d 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -1,5 +1,6 @@ zh_tw: property_hire: + editor: 編輯者 email_p_hire_success: 租借成功 email_edit_success: '租借模組:編輯成功' email_delete_success: '租借模組:刪除成功'