diff --git a/README.md b/README.md index f113289d4..03a30208e 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ En local, un utilisateur de test est créé automatiquement, avec les identifian AutoArchiveProcedureJob.set(cron: "* * * * *").perform_later WeeklyOverviewJob.set(cron: "0 7 * * 1").perform_later AutoReceiveDossiersForProcedureJob.set(cron: "* * * * *").perform_later(procedure_declaratoire_id, Dossier.states.fetch(:en_instruction)) - SendinblueUpdateAdministrateursJob.set(cron: "0 10 * * *").perform_later + UpdateAdministrateurUsageStatisticsJob.set(cron: "0 10 * * *").perform_later FindDubiousProceduresJob.set(cron: "0 0 * * *").perform_later Administrateurs::ActivateBeforeExpirationJob.set(cron: "0 8 * * *").perform_later WarnExpiringDossiersJob.set(cron: "0 0 1 * *").perform_later diff --git a/app/jobs/update_administrateur_usage_statistics_job.rb b/app/jobs/update_administrateur_usage_statistics_job.rb index 940a98bae..a89fc365f 100644 --- a/app/jobs/update_administrateur_usage_statistics_job.rb +++ b/app/jobs/update_administrateur_usage_statistics_job.rb @@ -1,4 +1,6 @@ class UpdateAdministrateurUsageStatisticsJob < ApplicationJob + queue_as :cron + def perform AdministrateurUsageStatisticsService.new.update_administrateurs end diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 3449517ec..18164a03b 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -79,6 +79,7 @@ class Dossier < ApplicationRecord piece_justificative_file_attachment: :blob ], pieces_justificatives: [], + avis: [], etablissement: [], individual: [], user: []) @@ -176,7 +177,7 @@ class Dossier < ApplicationRecord end def messagerie_available? - !brouillon? && !archived + !brouillon? && !archived && !procedure.archivee? end def retention_end_date diff --git a/app/serializers/dossier_serializer.rb b/app/serializers/dossier_serializer.rb index 876b2dcaf..980254ce3 100644 --- a/app/serializers/dossier_serializer.rb +++ b/app/serializers/dossier_serializer.rb @@ -23,6 +23,7 @@ class DossierSerializer < ActiveModel::Serializer has_many :pieces_justificatives has_many :types_de_piece_justificative has_one :justificatif_motivation + has_many :avis has_many :champs, serializer: ChampSerializer diff --git a/app/services/administrateur_usage_statistics_service.rb b/app/services/administrateur_usage_statistics_service.rb index e599d0d3b..5cefeaf68 100644 --- a/app/services/administrateur_usage_statistics_service.rb +++ b/app/services/administrateur_usage_statistics_service.rb @@ -24,6 +24,7 @@ class AdministrateurUsageStatisticsService def administrateur_stats(administrateur) nb_dossiers_by_procedure_id = nb_dossiers_by_procedure_id(administrateur.id) nb_dossiers_by_synthetic_state = nb_dossiers_by_synthetic_state(administrateur.id) + nb_dossiers_roi = nb_dossiers_by_procedure_id.reject { |procedure_id, _count| is_brouillon(procedure_id) }.map { |_procedure_id, count| count }.sum result = { ds_sign_in_count: administrateur.sign_in_count, @@ -57,7 +58,9 @@ class AdministrateurUsageStatisticsService .map { |_procedure_id, count| count } .max || 0, nb_dossiers_traite: nb_dossiers_by_synthetic_state['termine'], - nb_dossiers_dossier_en_instruction: nb_dossiers_by_synthetic_state['en_instruction'] + nb_dossiers_dossier_en_instruction: nb_dossiers_by_synthetic_state['en_instruction'], + admin_roi_low: nb_dossiers_roi * 7.04, + admin_roi_high: nb_dossiers_roi * 17.25 } if administrateur.current_sign_in_at.present? diff --git a/app/services/commentaire_service.rb b/app/services/commentaire_service.rb index fa3b9a576..b7e8ef206 100644 --- a/app/services/commentaire_service.rb +++ b/app/services/commentaire_service.rb @@ -12,6 +12,9 @@ class CommentaireService end def build_with_email(email, dossier, params) + if !dossier.messagerie_available? + raise ArgumentError, "Commentaires cannot be added to brouillons or archived Dossiers" + end attributes = params.merge(email: email, dossier: dossier) Commentaire.new(attributes) end diff --git a/app/views/shared/dossiers/_messagerie.html.haml b/app/views/shared/dossiers/_messagerie.html.haml index 5d589fa5b..c50c17eaa 100644 --- a/app/views/shared/dossiers/_messagerie.html.haml +++ b/app/views/shared/dossiers/_messagerie.html.haml @@ -4,4 +4,7 @@ %li.message{ class: commentaire_is_from_me_class(commentaire, connected_user) } = render partial: "shared/dossiers/messages/message", locals: { commentaire: commentaire, connected_user: connected_user, messagerie_seen_at: messagerie_seen_at } - = render partial: "shared/dossiers/messages/form", locals: { commentaire: new_commentaire, form_url: form_url } + - if dossier.archived? + = render partial: "shared/dossiers/messages/messagerie_disabled", locals: { service: dossier.procedure.service } + - else + = render partial: "shared/dossiers/messages/form", locals: { commentaire: new_commentaire, form_url: form_url } diff --git a/app/views/shared/dossiers/messages/_messagerie_disabled.html.haml b/app/views/shared/dossiers/messages/_messagerie_disabled.html.haml new file mode 100644 index 000000000..5b1564796 --- /dev/null +++ b/app/views/shared/dossiers/messages/_messagerie_disabled.html.haml @@ -0,0 +1,14 @@ +.card.feedback + .card-title + La messagerie est désormais désactivée. + %p + Pour poser une question sur ce dossier, contactez : + %p + = service.nom + %br + = service.organisme + %br + - horaires = "Horaires : #{formatted_horaires(service.horaires)}" + = simple_format(horaires) + %p + = link_to service.email, "mailto:#{service.email}" diff --git a/app/views/users/_procedure_footer.html.haml b/app/views/users/_procedure_footer.html.haml index 495010d95..458c6ed00 100644 --- a/app/views/users/_procedure_footer.html.haml +++ b/app/views/users/_procedure_footer.html.haml @@ -27,7 +27,9 @@ %a{ href: "tel:#{service.telephone}" }= service.telephone %p - Horaires : #{formatted_horaires(service.horaires)} + - horaires = "Horaires : #{formatted_horaires(service.horaires)}" + = simple_format(horaires) + - politiques = politiques_conservation_de_donnees(procedure) - if politiques.present? diff --git a/config/environments/development.rb b/config/environments/development.rb index 1d51b0cd3..2a5367e65 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -59,7 +59,7 @@ Rails.application.configure do port: 3000 } - # Use Content-Security-Policy-Report-Only instead of Content-Security-Policy + # Use Content-Security-Policy-Report-Only headers config.content_security_policy_report_only = true # Raises error for missing translations diff --git a/config/environments/production.rb b/config/environments/production.rb index befbe17aa..0c93feb51 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -109,7 +109,8 @@ Rails.application.configure do host: ENV['APP_HOST'] } - config.content_security_policy_report_only = true + # The Content-Security-Policy is NOT in Report-Only mode + config.content_security_policy_report_only = false config.lograge.enabled = ENV['LOGRAGE_ENABLED'] == 'enabled' end diff --git a/config/environments/test.rb b/config/environments/test.rb index 2a1fb8e0f..0f05338b6 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -45,7 +45,7 @@ Rails.application.configure do protocol: :http } - # Use Content-Security-Policy-Report-Only instead of Content-Security-Policy + # Use Content-Security-Policy-Report-Only headers config.content_security_policy_report_only = true config.active_job.queue_adapter = :test diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index e7debcc0c..86a32f221 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -13,8 +13,8 @@ Rails.application.config.content_security_policy do |policy| # Pour les CSS, on a beaucoup de style inline et quelques balises