Update email/notification, type: deliver

Closes [SCI-2643], [SCI-2644].
This commit is contained in:
Jure Grabnar 2018-09-23 18:45:13 +02:00
parent 59169f882d
commit 7877d559a3
5 changed files with 31 additions and 7 deletions

View file

@ -8,9 +8,15 @@ class AppMailer < Devise::Mailer
def notification(user, notification, opts = {}) def notification(user, notification, opts = {})
@user = user @user = user
@notification = notification @notification = notification
subject =
if notification.deliver?
subject = I18n.t('notifications.deliver.email_subject')
else
subject = I18n.t('notifications.email_title')
end
headers = { headers = {
to: @user.email, to: @user.email,
subject: I18n.t('notifications.email_title') subject: subject
}.merge(opts) }.merge(opts)
mail(headers) mail(headers)
end end

View file

@ -9,6 +9,9 @@
</div> </div>
<div class="col-xs-9 col-md-11"> <div class="col-xs-9 col-md-11">
<strong><%= sanitize_input(notification.title) %></strong> <br> <strong><%= sanitize_input(notification.title) %></strong> <br>
<% if notification.deliver? %>
Click the link to download the file. </br>
<% end %>
<%= l(notification.created_at, format: :full) %> | <%= sanitize_input(notification.message) %> <%= l(notification.created_at, format: :full) %> | <%= sanitize_input(notification.message) %>
</div> </div>
</div> </div>

View file

@ -9,6 +9,9 @@
<div class="col-xs-10"> <div class="col-xs-10">
<strong><%= sanitize_input(notification.title) %></strong> <br> <strong><%= sanitize_input(notification.title) %></strong> <br>
<% if notification.deliver? %>
Click the link to download the file.</br>
<% end %>
<%= l(notification.created_at, format: :full) %> | <%= sanitize_input(notification.message) %> <%= l(notification.created_at, format: :full) %> | <%= sanitize_input(notification.message) %>
</div> </div>
</div> </div>

View file

@ -1,13 +1,16 @@
<p>Hello <%= @user.name %>!</p> <p>Hello <%= @user.name %>,</p>
<p><%= I18n.t("notifications.email_title") %></p> <% unless @notification.deliver? %>
<p><%= I18n.t("notifications.email_title") %></p>
<p>Type: <%= I18n.t("notifications.types.#{@notification.type_of}") %></p> <p>Type: <%= I18n.t("notifications.types.#{@notification.type_of}") %></p>
<% end %>
<p> <p>
<% if @notification.system_message? || @notification.deliver? %> <% if @notification.system_message? %>
<% # We assume the system notification is clean %> <% # We assume the system notification is clean %>
<%= @notification.title.html_safe %> <%= @notification.title.html_safe %>
<% elsif @notification.deliver? %>
<%= I18n.t("notifications.deliver.email_body").html_safe %>
<% else %> <% else %>
<%= sanitize_input(prepend_server_url_to_links(@notification.title)) %> <%= sanitize_input(prepend_server_url_to_links(@notification.title)) %>
<% end %> <% end %>
@ -18,8 +21,12 @@
<% # We assume the system notification is clean %> <% # We assume the system notification is clean %>
<%= @notification.message.html_safe %> <%= @notification.message.html_safe %>
<% elsif @notification.deliver? %> <% elsif @notification.deliver? %>
<p>
<%= I18n.t("notifications.deliver.email_end_greeting").html_safe %>
</p>
<% # work around the problem with inserting the link of zipExport %> <% # work around the problem with inserting the link of zipExport %>
<% zip_id = /data-id='(\d*)'/.match(@notification.message)[1] %> <% zip_id = /data-id='(\d*)'/.match(@notification.message)[1] %>
<%= I18n.t("notifications.deliver.download_link") %>
<%= @notification.message.gsub(/href='.+'/, "href='#{zip_exports_download_url(zip_id)}'").html_safe %> <%= @notification.message.gsub(/href='.+'/, "href='#{zip_exports_download_url(zip_id)}'").html_safe %>
<% else %> <% else %>
<%= sanitize_input(prepend_server_url_to_links(@notification.message)) %> <%= sanitize_input(prepend_server_url_to_links(@notification.message)) %>

View file

@ -1811,6 +1811,11 @@ en:
recent_notification_description: 'Recent changes notifications appear whenever there is a change on a task you are assigned to.' recent_notification_description: 'Recent changes notifications appear whenever there is a change on a task you are assigned to.'
system_message: 'System message' system_message: 'System message'
system_message_description: 'System message notifications are specifically sent by site maintainers to notify all users about a system update.' system_message_description: 'System message notifications are specifically sent by site maintainers to notify all users about a system update.'
deliver:
download_link: "Download link:"
email_subject: "Your SciNote export is ready!"
email_body: "<p>The export of SciNote project(s) that you requested is ready!</p><p>You can find the link to download the file below or in your SciNote notifications. Please keep in mind that the link will expire in 7 days for security reasons.</p>"
email_end_greeting: "<p>Best regards,</p><p>Your SciNote team</p>"
show_all: "Show all notifications" show_all: "Show all notifications"
show_more: "Show more notifications" show_more: "Show more notifications"
no_notifications: "No notifications." no_notifications: "No notifications."
@ -1878,7 +1883,7 @@ en:
zip_export: zip_export:
modal_label: 'Export inventory' modal_label: 'Export inventory'
notification_title: 'Your package is ready to be exported!' notification_title: 'Your requested export package is ready!'
expired_title: 'Looks like your link has expired.' expired_title: 'Looks like your link has expired.'
expired_description: 'Please export the data again in order to receive a new link.' expired_description: 'Please export the data again in order to receive a new link.'
modal_label: 'Export request received' modal_label: 'Export request received'