Skip to content

Commit

Permalink
fix issue 88
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasfranck committed Oct 4, 2023
1 parent 7350fb1 commit e8118bf
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
46 changes: 46 additions & 0 deletions app/views/branded/devise/mailer/invitation_instructions.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<%
tool_name = ApplicationService.application_name
link = plans_url()
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 = @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 %>
<p>


</p>
<p>
<%= _("Hello %{user_name}") %{ :user_name => user_name } %>
</p>
<p>
<%= _("Your colleague %{inviter_name} has invited you to contribute to "\
" their Data Management Plan in %{tool_name}") % {
tool_name: tool_name,
inviter_name: inviter_name
} %>
</p>
<p>
<%= sanitize(_('%{click_here} to accept the invitation, (or copy %{link} into your browser). If you don\'t want to accept the invitation, please ignore this email.') % {
click_here: link_to(_('Click here'), link), link: link })
%>
</p>
<p>
<%= _('All the best') %>
<br />
The DMPonline.be team
</p>
<p>
<%= _('You may change your notification preferences on your profile page. ') %>
<%= _('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,
subject: email_subject),
contact_us: link_to(contact_us, contact_us)
}) %>
</p>
<% end %>
11 changes: 9 additions & 2 deletions config/initializers/ugent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
require "plan_exports_controller"
require 'plans_helper'
require "settings/template"
require "devise/mailer"

module PlansHelper

Expand Down Expand Up @@ -999,16 +1000,22 @@ def name_with_orcid

end

# skip invitation email
User.before_invitation_created do |user|

# fix auto generated names (during invitation in roles controller)
# fix this in User.before_validation does not work (not validated?)
user.firstname = User.nemo if user.firstname == "First Name"
user.surname = User.nemo if user.surname == "Surname"

user.skip_invitation = true
end

class Devise::Mailer
# devise mailer does not user app/views/branded as stated by rails
# purpose: when a user is added to a plan, an invitation mail is
# and for existing user a sharing notification mail. We made sure
# here that the invitation mail looks the same as the sharing notification
# mail
prepend_view_path(Rails.root.join("app", "views", "branded"))
end

class Org
Expand Down

0 comments on commit e8118bf

Please sign in to comment.