refactor: mutualize email_expert logic
This commit is contained in:
parent
71b0592b0a
commit
5cd780251b
5 changed files with 42 additions and 31 deletions
|
@ -83,11 +83,7 @@ module Experts
|
|||
|
||||
def avis_new
|
||||
@new_avis = Avis.new
|
||||
if @dossier.procedure.experts_require_administrateur_invitation?
|
||||
@experts_emails = @dossier.procedure.experts_procedures.where(revoked_at: nil).map { _1.expert.email }.sort
|
||||
else
|
||||
@experts_emails = @dossier.procedure.experts.map(&:email).sort
|
||||
end
|
||||
@experts_emails = Expert.autocomplete_mails(@dossier.procedure)
|
||||
end
|
||||
|
||||
def create_avis
|
||||
|
|
|
@ -64,21 +64,13 @@ module Instructeurs
|
|||
def avis
|
||||
@avis_seen_at = current_instructeur.follows.find_by(dossier: dossier)&.avis_seen_at
|
||||
@avis = Avis.new
|
||||
if @dossier.procedure.experts_require_administrateur_invitation?
|
||||
@experts_emails = dossier.procedure.experts_procedures.where(revoked_at: nil).map(&:expert).map(&:email).sort
|
||||
else
|
||||
@experts_emails = @dossier.procedure.experts.map(&:email).sort
|
||||
end
|
||||
@experts_emails = Expert.autocomplete_mails(@dossier.procedure)
|
||||
end
|
||||
|
||||
def avis_new
|
||||
@avis_seen_at = current_instructeur.follows.find_by(dossier: dossier)&.avis_seen_at
|
||||
@avis = Avis.new
|
||||
if @dossier.procedure.experts_require_administrateur_invitation?
|
||||
@experts_emails = dossier.procedure.experts_procedures.where(revoked_at: nil).map(&:expert).map(&:email).sort
|
||||
else
|
||||
@experts_emails = @dossier.procedure.experts.map(&:email).sort
|
||||
end
|
||||
@experts_emails = Expert.autocomplete_mails(@dossier.procedure)
|
||||
end
|
||||
|
||||
def personnes_impliquees
|
||||
|
|
|
@ -29,6 +29,14 @@ class Expert < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def self.autocomplete_mails(procedure)
|
||||
if procedure.experts_require_administrateur_invitation?
|
||||
procedure.experts_procedures.where(revoked_at: nil).map(&:expert).map(&:email).sort
|
||||
else
|
||||
procedure.experts.map(&:email).sort
|
||||
end
|
||||
end
|
||||
|
||||
def merge(old_expert)
|
||||
return if old_expert.nil?
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue