unfollow stale instructeurs
when the group instructeur of a dossier is changed, unfollow the instructeurs who don't belong to the new groupe instructeur
This commit is contained in:
parent
f7a4759664
commit
fb3d7e45ba
2 changed files with 26 additions and 0 deletions
|
@ -213,6 +213,7 @@ class Dossier < ApplicationRecord
|
|||
before_save :build_default_champs, if: Proc.new { groupe_instructeur_id_was.nil? }
|
||||
before_save :update_search_terms
|
||||
|
||||
after_save :unfollow_stale_instructeurs
|
||||
after_save :send_dossier_received
|
||||
after_save :send_web_hook
|
||||
after_create :send_draft_notification_email
|
||||
|
@ -645,6 +646,14 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def unfollow_stale_instructeurs
|
||||
if saved_change_to_groupe_instructeur_id? && saved_change_to_groupe_instructeur_id[0].present?
|
||||
followers_instructeurs.each do |instructeur|
|
||||
instructeur.unfollow(self) unless instructeur.groupe_instructeurs.include?(groupe_instructeur)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.send_brouillon_expiration_notices
|
||||
brouillons = Dossier
|
||||
.brouillon_close_to_expiration
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue