This commit is contained in:
Kara Diaby 2022-08-30 21:41:36 +02:00
parent 98f4250214
commit f8d4644f73
4 changed files with 29 additions and 11 deletions

View file

@ -46,6 +46,15 @@ class DossierMailer < ApplicationMailer
end
end
def notify_new_avis_to_instructeur(avis, instructeur_email)
I18n.with_locale(avis.dossier.user_locale) do
@avis = avis
@subject = default_i18n_subject(dossier_id: avis.dossier.id, libelle_demarche: avis.procedure.libelle)
mail(to: instructeur_email, subject: @subject)
end
end
def notify_new_dossier_depose_to_instructeur(dossier, instructeur_email)
I18n.with_locale(dossier.user_locale) do
@dossier = dossier

View file

@ -2,16 +2,17 @@
#
# Table name: assign_tos
#
# id :integer not null, primary key
# daily_email_notifications_enabled :boolean default(FALSE), not null
# instant_email_dossier_notifications_enabled :boolean default(FALSE), not null
# instant_email_message_notifications_enabled :boolean default(FALSE), not null
# manager :boolean default(FALSE)
# weekly_email_notifications_enabled :boolean default(TRUE), not null
# created_at :datetime
# updated_at :datetime
# groupe_instructeur_id :bigint
# instructeur_id :integer
# id :integer not null, primary key
# daily_email_notifications_enabled :boolean default(FALSE), not null
# instant_email_dossier_notifications_enabled :boolean default(FALSE), not null
# instant_email_message_notifications_enabled :boolean default(FALSE), not null
# instant_expert_avis_email_notifications_enabled :boolean default(FALSE), not null
# manager :boolean default(FALSE)
# weekly_email_notifications_enabled :boolean default(TRUE), not null
# created_at :datetime
# updated_at :datetime
# groupe_instructeur_id :bigint
# instructeur_id :integer
#
class AssignTo < ApplicationRecord
belongs_to :instructeur, optional: false

View file

@ -74,6 +74,10 @@ class Avis < ApplicationRecord
]
end
def updated_recently?
updated_at > 30.minutes.ago
end
def revoked?
revoked_at.present?
end

View file

@ -41,6 +41,10 @@ class Instructeur < ApplicationRecord
includes(:assign_to).where(assign_tos: { instant_email_dossier_notifications_enabled: true })
}
scope :with_instant_expert_avis_email_notifications_enabled, -> {
includes(:assign_to).where(assign_tos: { instant_expert_avis_email_notifications_enabled: true })
}
default_scope { eager_load(:user) }
def self.by_email(email)
@ -81,7 +85,7 @@ class Instructeur < ApplicationRecord
end
end
NOTIFICATION_SETTINGS = [:daily_email_notifications_enabled, :instant_email_dossier_notifications_enabled, :instant_email_message_notifications_enabled, :weekly_email_notifications_enabled]
NOTIFICATION_SETTINGS = [:daily_email_notifications_enabled, :instant_email_dossier_notifications_enabled, :instant_email_message_notifications_enabled, :weekly_email_notifications_enabled, :instant_expert_avis_email_notifications_enabled]
def notification_settings(procedure_id)
assign_to