Add the possibility to disable weekly email notifications (instructeur) && rename the column email_notifications_enabled to daily_email_notification_enabled

This commit is contained in:
kara Diaby 2020-02-11 15:51:15 +01:00 committed by GitHub Action
parent 35b608fb7d
commit 0b8a59d5e9
6 changed files with 33 additions and 8 deletions

View file

@ -231,8 +231,7 @@ module Instructeurs
end
def update_email_notifications
assign_to.update!(email_notifications_enabled: params[:assign_to][:email_notifications_enabled])
assign_to.update!(assign_to_params)
flash.notice = 'Vos notifications sont enregistrées.'
redirect_to instructeur_procedure_path(procedure)
end
@ -246,6 +245,10 @@ module Instructeurs
private
def assign_to_params
params.require(:assign_to).permit(:email_notifications_enabled, :weekly_email_notifications_enabled)
end
def assign_exports
groupe_instructeurs_for_procedure = current_instructeur.groupe_instructeurs.where(procedure: procedure)
@xlsx_export = Export.find_for_format_and_groupe_instructeurs(:xlsx, groupe_instructeurs_for_procedure)

View file

@ -75,11 +75,12 @@ class Instructeur < ApplicationRecord
start_date = Time.zone.now.beginning_of_week
active_procedure_overviews = procedures
.where(assign_tos: { weekly_email_notifications_enabled: true })
.publiees
.map { |procedure| procedure.procedure_overview(start_date, groupe_instructeurs) }
.filter(&:had_some_activities?)
if active_procedure_overviews.count == 0
if active_procedure_overviews.empty?
nil
else
{

View file

@ -27,18 +27,18 @@
= form.radio_button :email_notifications_enabled, false
Non
= form.label nil, "Recevoir un récapitulatif hebdomadaire"
= form.label :email_notification, "Recevoir un récapitulatif hebdomadaire"
%p.notice
Cet email récapitule lactivité de la semaine sur lensemble de vos démarches.
%p.notice
Il est envoyé chaque semaine le lundi matin, et nest pas désactivable.
Il est envoyé chaque semaine le lundi matin.
.radios
%label
= radio_button_tag "not_implemented", "Oui", true, disabled: true
= form.radio_button :weekly_email_notifications_enabled, true
Oui
%label
= radio_button_tag "not_implemented", "Non", false, disabled: true
= form.radio_button :weekly_email_notifications_enabled, false
Non
.send-wrapper