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:
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user