Show name and email for deleted poll officer's user account

Avoid to raise an exception `Module::DelegationError' when trying to
show the name and/or email of a poll officer whose user account has
been deleted.
We'll show a message "User deleted" and "Email deleted" instead.
This commit is contained in:
Julian Herrero
2019-05-31 18:29:11 +02:00
parent 90c1d681d0
commit 1f76b25e2a
4 changed files with 37 additions and 1 deletions

View File

@@ -7,7 +7,13 @@ class Poll
validates :user_id, presence: true, uniqueness: true
delegate :name, :email, to: :user
def name
user&.name || I18n.t("shared.author_info.author_deleted")
end
def email
user&.email || I18n.t("shared.author_info.email_deleted")
end
def voting_days_assigned_polls
officer_assignments.voting_days.includes(booth_assignment: :poll).