diff --git a/app/controllers/orgs_controller.rb b/app/controllers/orgs_controller.rb index 78ad6f1777..e4f2423886 100644 --- a/app/controllers/orgs_controller.rb +++ b/app/controllers/orgs_controller.rb @@ -219,6 +219,7 @@ def org_params :remove_logo, :managed, :feedback_enabled, :org_links, :funder, :institution, :organisation, :feedback_msg, :org_id, :org_name, :org_crosswalk, + :helpdesk_email, identifiers_attributes: %i[identifier_scheme_id value], tracker_attributes: %i[code id]) end diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb index 7824d66081..f133706dd5 100644 --- a/app/helpers/mailer_helper.rb +++ b/app/helpers/mailer_helper.rb @@ -8,8 +8,8 @@ def tool_name @tool_name ||= ApplicationService.application_name end - def helpdesk_email - @helpdesk_email ||= Rails.configuration.x.organisation.helpdesk_email + def helpdesk_email(org: nil) + org&.helpdesk_email || Rails.configuration.x.organisation.helpdesk_email end # Returns an unordered HTML list with the permissions associated to the user passed diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index fe68f2e708..56267ee547 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -18,6 +18,7 @@ def welcome_notification(user) # Override the default Rails route helper for the contact_us page IF an alternate contact_us # url was defined in the dmproadmap.rb initializer file @contact_us = Rails.application.config.x.organisation.contact_us_url || contact_us_url + @helpdesk_email = helpdesk_email(org: @user.org) I18n.with_locale I18n.default_locale do mail(to: @user.email, @@ -38,6 +39,7 @@ def question_answered(data, user, answer, _options_string) @recipient_name = @data['name'].to_s @message = @data['message'].to_s @answer_text = @options_string.to_s + @helpdesk_email = helpdesk_email(org: @user.org) I18n.with_locale I18n.default_locale do mail(to: data['email'], @@ -53,6 +55,7 @@ def sharing_notification(role, user, inviter:) @username = @user.name @inviter = inviter @link = url_for(action: 'show', controller: 'plans', id: @role.plan.id) + @helpdesk_email = helpdesk_email(org: @inviter.org) I18n.with_locale I18n.default_locale do mail(to: @role.user.email, @@ -69,6 +72,7 @@ def permissions_change_notification(role, user) @user = user @recepient = @role.user @messaging = role_text(@role) + @helpdesk_email = helpdesk_email(org: @user.org) I18n.with_locale I18n.default_locale do mail(to: @recepient.email, @@ -83,6 +87,7 @@ def plan_access_removed(user, plan, current_user) @user = user @plan = plan @current_user = current_user + @helpdesk_email = helpdesk_email(org: @plan.org) I18n.with_locale I18n.default_locale do mail(to: @user.email, @@ -100,6 +105,7 @@ def feedback_notification(recipient, plan, requestor) @recipient_name = @recipient.name(false) @requestor_name = @user.name(false) @plan_name = @plan.title + @helpdesk_email = helpdesk_email(org: @plan.org) I18n.with_locale I18n.default_locale do mail(to: @recipient.email, @@ -118,6 +124,7 @@ def feedback_complete(recipient, plan, requestor) @plan = plan @phase = @plan.phases.first @plan_name = @plan.title + @helpdesk_email = helpdesk_email(org: @plan.org) I18n.with_locale I18n.default_locale do sender = Rails.configuration.x.organisation.do_not_reply_email || @@ -139,6 +146,7 @@ def plan_visibility(user, plan) @plan = plan @plan_title = @plan.title @plan_visibility = Plan::VISIBILITY_MESSAGE[@plan.visibility.to_sym] + @helpdesk_email = helpdesk_email(org: @plan.org) I18n.with_locale I18n.default_locale do mail(to: @user.email, @@ -167,6 +175,7 @@ def new_comment(commenter, plan, answer) @section_title = @question.section.title @phase_id = @question.section.phase.id @phase_link = url_for(action: 'edit', controller: 'plans', id: @plan.id, phase_id: @phase_id) + @helpdesk_email = helpdesk_email(org: @plan.org) I18n.with_locale I18n.default_locale do mail(to: @plan.owner.email, @@ -182,6 +191,7 @@ def admin_privileges(user) @user = user @username = @user.name @ul_list = privileges_list(@user) + @helpdesk_email = helpdesk_email(org: @user.org) I18n.with_locale I18n.default_locale do mail(to: user.email, @@ -199,6 +209,8 @@ def api_credentials(api_client) @name = @api_client.contact_name.present? ? @api_client.contact_name : @api_client.contact_email + @helpdesk_email = helpdesk_email(org: @api_client.org) + I18n.with_locale I18n.default_locale do mail(to: @api_client.contact_email, subject: format(_('%{tool_name} API changes'), tool_name: tool_name)) diff --git a/app/models/org.rb b/app/models/org.rb index 8f25d00e79..6b2a48525c 100644 --- a/app/models/org.rb +++ b/app/models/org.rb @@ -24,6 +24,7 @@ # language_id :integer # region_id :integer # managed :boolean default(false), not null +# helpdesk_email :string # # Foreign Keys # diff --git a/app/views/devise/mailer/invitation_instructions.html.erb b/app/views/devise/mailer/invitation_instructions.html.erb index a9e0989c4d..1e1af1af3e 100644 --- a/app/views/devise/mailer/invitation_instructions.html.erb +++ b/app/views/devise/mailer/invitation_instructions.html.erb @@ -1,15 +1,21 @@ <% tool_name = ApplicationService.application_name link = accept_invitation_url(@resource, :invitation_token => @token) - helpdesk_email = Rails.configuration.x.organisation.helpdesk_email contact_us = (Rails.configuration.x.organisation.contact_us_url || contact_us_url) email_subject = _('Query or feedback related to %{tool_name}') %{ :tool_name => tool_name } user_name = User.find_by(email: @resource.email).nil? ? @resource.email : User.find_by(email: @resource.email).name(false) - inviter_name = @resource.invited_by.name + inviter = @resource.invited_by + inviter_name = inviter.name + helpdesk_email = inviter.org&.helpdesk_email || + Rails.configuration.x.organisation.helpdesk_email %> <% I18n.with_locale I18n.default_locale do %> +

+ + +

- <%= _('Hello %{user_name}') %{ :user_name => user_name } %> + <%= _("Hello %{user_name}") %{ :user_name => user_name } %>

<%= _("Your colleague %{inviter_name} has invited you to contribute to "\ diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb index d7ee54d126..b5c41e5b85 100644 --- a/app/views/devise/mailer/reset_password_instructions.html.erb +++ b/app/views/devise/mailer/reset_password_instructions.html.erb @@ -3,6 +3,9 @@ helpdesk_email = Rails.configuration.x.organisation.helpdesk_email contact_us = Rails.configuration.x.organisation.contact_us_url || contact_us_url email_subject = _('Query or feedback related to %{tool_name}') %{ :tool_name => tool_name } + user = User.find_by(email: @resource.email) + helpdesk_email = user.org&.helpdesk_email || + Rails.configuration.x.organisation.helpdesk_email %> <% I18n.with_locale I18n.default_locale do %>

diff --git a/app/views/orgs/_profile_form.html.erb b/app/views/orgs/_profile_form.html.erb index 5226143c6d..8dd20013ba 100644 --- a/app/views/orgs/_profile_form.html.erb +++ b/app/views/orgs/_profile_form.html.erb @@ -86,6 +86,20 @@


+
+
+

<%= _("Help Desk email") %>

+
+
+
+
+ <%= f.label :helpdesk_email, _('Help Desk email'), class: "control-label" %> + <%= f.email_field :helpdesk_email, class: "form-control" %> +
+
+ +
+

<%= _("Administrator contact") %>

diff --git a/app/views/user_mailer/_email_signature.html.erb b/app/views/user_mailer/_email_signature.html.erb index 7594d71d93..a1b64abd30 100644 --- a/app/views/user_mailer/_email_signature.html.erb +++ b/app/views/user_mailer/_email_signature.html.erb @@ -17,7 +17,7 @@ <% end %> <%= _('Please do not reply to this email.') %> <%= sanitize(_('If you have any questions or need help, please contact us at %{helpdesk_email} or visit %{contact_us}') % { - helpdesk_email: mail_to(helpdesk_email, helpdesk_email, + helpdesk_email: mail_to(@helpdesk_email, @helpdesk_email, subject: email_subject), contact_us: link_to(contact_us, contact_us) }) %> diff --git a/db/migrate/20220315104737_add_helpdesk_email_to_orgs.rb b/db/migrate/20220315104737_add_helpdesk_email_to_orgs.rb new file mode 100644 index 0000000000..e646e9bf6d --- /dev/null +++ b/db/migrate/20220315104737_add_helpdesk_email_to_orgs.rb @@ -0,0 +1,5 @@ +class AddHelpdeskEmailToOrgs < ActiveRecord::Migration[5.2] + def change + add_column :orgs, :helpdesk_email, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 90b15b2838..56dbfef7d4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_08_19_160319) do +ActiveRecord::Schema.define(version: 2022_03_15_104737) do create_table "annotations", id: :integer, force: :cascade do |t| t.integer "question_id" @@ -275,6 +275,7 @@ t.text "api_create_plan_email_body" t.index ["language_id"], name: "fk_rails_5640112cab" t.index ["region_id"], name: "fk_rails_5a6adf6bab" + t.string "helpdesk_email" end create_table "perms", id: :integer, force: :cascade do |t|