Add error message for invalid Newsletter user segment

Instead of the name of the User Segment we'll display an error message
This commit is contained in:
Bertocq
2018-02-21 01:02:51 +01:00
parent 7dfa056fe0
commit 38f7a222f5
5 changed files with 12 additions and 2 deletions

View File

@@ -4,4 +4,12 @@ module UserSegmentsHelper
[t("admin.segment_recipient.#{user_segment_name}"), user_segment_name]
end
end
def segment_name(user_segment)
if user_segment && UserSegments.respond_to?(user_segment)
I18n.t("admin.segment_recipient.#{user_segment}")
else
I18n.t("admin.segment_recipient.invalid_recipients_segment")
end
end
end

View File

@@ -19,7 +19,7 @@
<%= newsletter.subject %>
</td>
<td>
<%= t("admin.segment_recipient.#{newsletter.segment_recipient}") %>
<%= segment_name(newsletter.segment_recipient) %>
</td>
<td>
<% if newsletter.draft? %>

View File

@@ -27,7 +27,7 @@
<div class="row">
<div class="small-12 column">
<strong><%= t("admin.newsletters.show.segment_recipient") %></strong><br>
<%= t("admin.segment_recipient.#{@newsletter.segment_recipient}") %>
<%= segment_name(@newsletter.segment_recipient) %>
<%= t("admin.newsletters.show.affected_users", n: recipients_count) %>
</div>
</div>