Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Stabilise email for the case that status or type don't have a defined color

Henriette Darge1dcea8cbace6
diff --git a/app/helpers/mail_digest_helper.rb b/app/helpers/mail_digest_helper.rb
index d93bc7ae08f..428e8d94897 100644
--- a/app/helpers/mail_digest_helper.rb
+++ b/app/helpers/mail_digest_helper.rb
@@ -31,10 +31,10 @@
module MailDigestHelper
include ::ColorsHelper
- def digest_timespan_text(notification_count, wp_count)
+ def digest_summary_text(notification_count, wp_count)
date = Time.parse(Setting.notification_email_digest_time)
- I18n.t(:"mail.digests.time_frame",
+ I18n.t(:'mail.digests.time_frame',
time: Setting.notification_email_digest_time,
weekday: day_name(date.wday),
date: ::I18n.l(date.to_date, format: :long),
@@ -66,12 +66,12 @@ module MailDigestHelper
def type_color(type)
color_id = selected_color(type)
- Color.find(color_id).hexcode
+ Color.find(color_id).hexcode if color_id
end
- def status_colors(object)
- color_id = selected_color(object)
- Color.find(color_id).color_styles.map { |k, v| "#{k}:#{v};" }.join(' ')
+ def status_colors(status)
+ color_id = selected_color(status)
+ Color.find(color_id).color_styles.map { |k, v| "#{k}:#{v};" }.join(' ') if color_id
end
private
diff --git a/app/mailers/digest_mailer.rb b/app/mailers/digest_mailer.rb
index 7a585f94522..f11dcc44137 100644
--- a/app/mailers/digest_mailer.rb
+++ b/app/mailers/digest_mailer.rb
@@ -39,7 +39,7 @@ class DigestMailer < ApplicationMailer
helper :mail_digest
- MAX_SHOWN_WORK_PACKAGES = 15.freeze
+ MAX_SHOWN_WORK_PACKAGES = 15
class << self
def generate_message_id(_, user)
diff --git a/app/views/digest_mailer/work_packages.html.erb b/app/views/digest_mailer/work_packages.html.erb
index c156ac6d800..61a71aa7d12 100644
--- a/app/views/digest_mailer/work_packages.html.erb
+++ b/app/views/digest_mailer/work_packages.html.erb
@@ -12,7 +12,7 @@
</tr>
<tr>
<td style="font-size:14px; color: #1A67A3; font-weight: bold; padding-bottom: 10px;">
- <%= digest_timespan_text(@notification_ids.length, @aggregated_notifications.length) %>
+ <%= digest_summary_text(@notification_ids.length, @aggregated_notifications.length) %>
</td>
</tr>
<tr>
diff --git a/app/views/digest_mailer/work_packages.text.erb b/app/views/digest_mailer/work_packages.text.erb
index 46090e8d8a4..4f60246ba4a 100644
--- a/app/views/digest_mailer/work_packages.text.erb
+++ b/app/views/digest_mailer/work_packages.text.erb
@@ -1,3 +1,7 @@
+<%= I18n.t(:'mail.digests.salutation', user: @user.firstname) %>
+<%= digest_summary_text(@notification_ids.length, @aggregated_notifications.length) %>
+<%= "-" * 100 %>
+
<% @aggregated_notifications.first(DigestMailer::MAX_SHOWN_WORK_PACKAGES).each do | work_package, notifications_by_work_package| %>
<%= "=" * (('# ' + work_package.id.to_s + work_package.subject).length + 4) %>