fix(instructeur): copy notifications settings from previous groupe instructeur

fix #6763
This commit is contained in:
Paul Chavard 2021-12-21 18:06:38 +00:00 committed by Pierre de La Morinerie
parent 2f6cd317bf
commit 4e779f445d
6 changed files with 111 additions and 49 deletions

View file

@ -81,14 +81,13 @@ class Instructeur < ApplicationRecord
end
end
def remove_from_groupe_instructeur(groupe_instructeur)
if groupe_instructeur.in?(groupe_instructeurs)
groupe_instructeurs.destroy(groupe_instructeur)
follows
.joins(:dossier)
.where(dossiers: { groupe_instructeur: groupe_instructeur })
.update_all(unfollowed_at: Time.zone.now)
end
NOTIFICATION_SETTINGS = [:daily_email_notifications_enabled, :instant_email_dossier_notifications_enabled, :instant_email_message_notifications_enabled, :weekly_email_notifications_enabled]
def notification_settings(procedure_id)
assign_to
.joins(:groupe_instructeur)
.find_by(groupe_instructeurs: { procedure_id: procedure_id })
&.slice(*NOTIFICATION_SETTINGS) || {}
end
def last_week_overview