Invite experts to linked dossiers

closes #3669
This commit is contained in:
Paul Chavard 2019-08-21 09:09:20 +02:00
parent ed8bece0fa
commit 86b271997b
14 changed files with 105 additions and 40 deletions

View file

@ -12,7 +12,6 @@ class Avis < ApplicationRecord
before_validation -> { sanitize_email(:email) }
before_create :try_to_assign_instructeur
after_create :notify_instructeur
default_scope { joins(:dossier) }
scope :with_answer, -> { where.not(answer: nil) }
@ -24,6 +23,7 @@ class Avis < ApplicationRecord
# The form allows subtmitting avis requests to several emails at once,
# hence this virtual attribute.
attr_accessor :emails
attr_accessor :invite_linked_dossiers
def email_to_display
instructeur&.email || email
@ -49,10 +49,6 @@ class Avis < ApplicationRecord
private
def notify_instructeur
AvisMailer.avis_invitation(self).deliver_later
end
def try_to_assign_instructeur
instructeur = Instructeur.find_by(email: email)
if instructeur