supprime un instructeur
This commit is contained in:
parent
d4de5769ee
commit
a6d007dbd3
6 changed files with 74 additions and 4 deletions
|
@ -17,9 +17,9 @@ class Instructeur < ApplicationRecord
|
|||
has_many :previously_followed_dossiers, -> { distinct }, through: :previous_follows, source: :dossier
|
||||
has_many :avis
|
||||
has_many :dossiers_from_avis, through: :avis, source: :dossier
|
||||
has_many :trusted_device_tokens
|
||||
has_many :trusted_device_tokens, dependent: :destroy
|
||||
|
||||
has_one :user
|
||||
has_one :user, dependent: :nullify
|
||||
|
||||
default_scope { eager_load(:user) }
|
||||
|
||||
|
@ -176,6 +176,10 @@ class Instructeur < ApplicationRecord
|
|||
trusted_device_token&.token_young?
|
||||
end
|
||||
|
||||
def can_be_deleted?
|
||||
user.administrateur.nil? && procedures.all? { |p| p.defaut_groupe_instructeur.instructeurs.count > 1 }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def annotations_hash(demande, annotations_privees, avis, messagerie)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue