diff --git a/app/assets/stylesheets/new_design/merci.scss b/app/assets/stylesheets/new_design/merci.scss
index b9986c443..e52b91bb2 100644
--- a/app/assets/stylesheets/new_design/merci.scss
+++ b/app/assets/stylesheets/new_design/merci.scss
@@ -30,4 +30,10 @@
a {
margin-top: 40px;
}
+
+ .monavis {
+ img {
+ margin-top: 2 * $default-padding;
+ }
+ }
}
diff --git a/app/controllers/manager/administrateurs_controller.rb b/app/controllers/manager/administrateurs_controller.rb
index 91866045c..83894c0ab 100644
--- a/app/controllers/manager/administrateurs_controller.rb
+++ b/app/controllers/manager/administrateurs_controller.rb
@@ -33,6 +33,21 @@ module Manager
head :ok
end
+ def delete
+ administrateur = Administrateur.find(params[:id])
+
+ if !administrateur.can_be_deleted?
+ fail "Impossible de supprimer cet administrateur car il a des dossiers ou des procédures"
+ end
+ administrateur.dossiers.each(&:delete_and_keep_track)
+ administrateur.destroy
+
+ logger.info("L'administrateur #{administrateur.id} est supprimé par #{current_user.id}")
+ flash[:notice] = "L'administrateur #{administrateur.id} est supprimé"
+
+ redirect_to manager_administrateurs_path
+ end
+
private
def create_administrateur_params
diff --git a/app/controllers/new_administrateur/mail_templates_controller.rb b/app/controllers/new_administrateur/mail_templates_controller.rb
index 7bc7dfba6..32039afa3 100644
--- a/app/controllers/new_administrateur/mail_templates_controller.rb
+++ b/app/controllers/new_administrateur/mail_templates_controller.rb
@@ -8,8 +8,9 @@ module NewAdministrateur
@service = procedure.service
mail_template = find_mail_template_by_slug(params[:id])
+ @rendered_template = sanitize(mail_template.body)
- render(html: sanitize(mail_template.body), layout: 'mailers/notification')
+ render(template: 'notification_mailer/send_notification', layout: 'mailers/notifications_layout')
end
private
diff --git a/app/mailers/dossier_mailer.rb b/app/mailers/dossier_mailer.rb
index 613b64775..ce00ce63f 100644
--- a/app/mailers/dossier_mailer.rb
+++ b/app/mailers/dossier_mailer.rb
@@ -13,7 +13,7 @@ class DossierMailer < ApplicationMailer
subject = "Retrouvez votre brouillon pour la démarche « #{dossier.procedure.libelle} »"
mail(to: dossier.user.email, subject: subject) do |format|
- format.html { render layout: 'mailers/notification' }
+ format.html { render layout: 'mailers/notifications_layout' }
end
end
@@ -25,7 +25,7 @@ class DossierMailer < ApplicationMailer
subject = "Nouveau message pour votre dossier nº #{dossier.id} (#{dossier.procedure.libelle})"
mail(to: dossier.user.email, subject: subject) do |format|
- format.html { render layout: 'mailers/notification' }
+ format.html { render layout: 'mailers/notifications_layout' }
end
end
diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb
index 87379f6df..816ff2c7c 100644
--- a/app/mailers/notification_mailer.rb
+++ b/app/mailers/notification_mailer.rb
@@ -6,8 +6,12 @@
# The subject and body of a Notification can be customized by each demarche.
#
class NotificationMailer < ApplicationMailer
+ include ActionView::Helpers::SanitizeHelper
+
helper ServiceHelper
+ layout 'mailers/notifications_layout'
+
def send_dossier_received(dossier)
send_notification(dossier, dossier.procedure.received_mail_template)
end
@@ -41,12 +45,9 @@ class NotificationMailer < ApplicationMailer
@dossier = dossier
@service = dossier.procedure.service
@logo_url = attach_logo(dossier.procedure)
+ @rendered_template = sanitize(body)
- mail(subject: subject, to: email) do |format|
- # rubocop:disable Rails/OutputSafety
- format.html { render(html: body.html_safe, layout: 'mailers/notification') }
- # rubocop:enable Rails/OutputSafety
- end
+ mail(subject: subject, to: email, template_name: 'send_notification')
end
def create_commentaire_for_notification(dossier, subject, body)
diff --git a/app/models/administrateur.rb b/app/models/administrateur.rb
index 6d1de0927..87c4ed221 100644
--- a/app/models/administrateur.rb
+++ b/app/models/administrateur.rb
@@ -123,4 +123,8 @@ class Administrateur < ApplicationRecord
def gestionnaire
Gestionnaire.find_by(email: email)
end
+
+ def can_be_deleted?
+ dossiers.state_instruction_commencee.none? && procedures.none?
+ end
end
diff --git a/app/models/dossier.rb b/app/models/dossier.rb
index a0251397b..0c80cf727 100644
--- a/app/models/dossier.rb
+++ b/app/models/dossier.rb
@@ -15,6 +15,8 @@ class Dossier < ApplicationRecord
INSTRUCTION_COMMENCEE = TERMINE + [states.fetch(:en_instruction)]
SOUMIS = EN_CONSTRUCTION_OU_INSTRUCTION + TERMINE
+ TAILLE_MAX_ZIP = 50.megabytes
+
has_one :etablissement, dependent: :destroy
has_one :individual, dependent: :destroy
has_one :attestation, dependent: :destroy
@@ -461,7 +463,7 @@ class Dossier < ApplicationRecord
end
def attachments_downloadable?
- !PiecesJustificativesService.liste_pieces_justificatives(self).empty? && PiecesJustificativesService.pieces_justificatives_total_size(self) < 50.megabytes
+ !PiecesJustificativesService.liste_pieces_justificatives(self).empty? && PiecesJustificativesService.pieces_justificatives_total_size(self) < Dossier::TAILLE_MAX_ZIP
end
private
diff --git a/app/models/mails/closed_mail.rb b/app/models/mails/closed_mail.rb
index a0245bac6..03888a50c 100644
--- a/app/models/mails/closed_mail.rb
+++ b/app/models/mails/closed_mail.rb
@@ -12,9 +12,9 @@ module Mails
def self.default_template_name_for_procedure(procedure)
attestation_template = procedure.attestation_template
if attestation_template&.activated?
- "notification_mailer/closed_mail_with_attestation"
+ "notification_mailer/default_templates/closed_mail_with_attestation"
else
- "notification_mailer/closed_mail"
+ "notification_mailer/default_templates/closed_mail"
end
end
end
diff --git a/app/models/mails/initiated_mail.rb b/app/models/mails/initiated_mail.rb
index fc32ae5da..9653b8d8c 100644
--- a/app/models/mails/initiated_mail.rb
+++ b/app/models/mails/initiated_mail.rb
@@ -5,7 +5,7 @@ module Mails
belongs_to :procedure
SLUG = "initiated_mail"
- DEFAULT_TEMPLATE_NAME = "notification_mailer/initiated_mail"
+ DEFAULT_TEMPLATE_NAME = "notification_mailer/default_templates/initiated_mail"
DISPLAYED_NAME = 'Accusé de réception'
DEFAULT_SUBJECT = 'Votre dossier nº --numéro du dossier-- a bien été reçu (--libellé démarche--)'
DOSSIER_STATE = Dossier.states.fetch(:en_construction)
diff --git a/app/models/mails/received_mail.rb b/app/models/mails/received_mail.rb
index 5cb3258e1..8e1c73b24 100644
--- a/app/models/mails/received_mail.rb
+++ b/app/models/mails/received_mail.rb
@@ -5,7 +5,7 @@ module Mails
belongs_to :procedure
SLUG = "received_mail"
- DEFAULT_TEMPLATE_NAME = "notification_mailer/received_mail"
+ DEFAULT_TEMPLATE_NAME = "notification_mailer/default_templates/received_mail"
DISPLAYED_NAME = 'Accusé de passage en instruction'
DEFAULT_SUBJECT = 'Votre dossier nº --numéro du dossier-- va être instruit (--libellé démarche--)'
DOSSIER_STATE = Dossier.states.fetch(:en_instruction)
diff --git a/app/models/mails/refused_mail.rb b/app/models/mails/refused_mail.rb
index d4b4d25db..ad598d859 100644
--- a/app/models/mails/refused_mail.rb
+++ b/app/models/mails/refused_mail.rb
@@ -5,7 +5,7 @@ module Mails
belongs_to :procedure
SLUG = "refused_mail"
- DEFAULT_TEMPLATE_NAME = "notification_mailer/refused_mail"
+ DEFAULT_TEMPLATE_NAME = "notification_mailer/default_templates/refused_mail"
DISPLAYED_NAME = 'Accusé de rejet du dossier'
DEFAULT_SUBJECT = 'Votre dossier nº --numéro du dossier-- a été refusé (--libellé démarche--)'
DOSSIER_STATE = Dossier.states.fetch(:refuse)
diff --git a/app/models/mails/without_continuation_mail.rb b/app/models/mails/without_continuation_mail.rb
index 11cd9a182..449bd40ab 100644
--- a/app/models/mails/without_continuation_mail.rb
+++ b/app/models/mails/without_continuation_mail.rb
@@ -5,7 +5,7 @@ module Mails
belongs_to :procedure
SLUG = "without_continuation"
- DEFAULT_TEMPLATE_NAME = "notification_mailer/without_continuation_mail"
+ DEFAULT_TEMPLATE_NAME = "notification_mailer/default_templates/without_continuation_mail"
DISPLAYED_NAME = 'Accusé de classement sans suite'
DEFAULT_SUBJECT = 'Votre dossier nº --numéro du dossier-- a été classé sans suite (--libellé démarche--)'
DOSSIER_STATE = Dossier.states.fetch(:sans_suite)
diff --git a/app/views/admin/procedures/monavis.html.haml b/app/views/admin/procedures/monavis.html.haml
index 226c2f24b..0b55058a2 100644
--- a/app/views/admin/procedures/monavis.html.haml
+++ b/app/views/admin/procedures/monavis.html.haml
@@ -1,6 +1,6 @@
.row.white-back
#procedure_new.section.section-label
- = form_for @procedure, url: url_for({ controller: 'admin/procedures', action: :update_monavis, id: @procedure.id }), multipart: true do |f|
+ = form_for @procedure, url: url_for({ controller: 'admin/procedures', action: :update_monavis }), multipart: true do |f|
= render partial: 'monavis', locals: { f: f }
.text-right
= f.button 'Enregistrer', class: 'btn btn-success'
diff --git a/app/views/admin/procedures/new_from_existing.html.haml b/app/views/admin/procedures/new_from_existing.html.haml
index 2800c40b4..b7479670d 100644
--- a/app/views/admin/procedures/new_from_existing.html.haml
+++ b/app/views/admin/procedures/new_from_existing.html.haml
@@ -10,11 +10,6 @@
%br
Besoin d'aide ?
%br
- > Nous proposons des ateliers en ligne pour vous aider à créer votre 1er formulaire et répondre à vos questions :
- = link_to "inscrivez-vous ici",
- "https://vimeo.com/334463514",
- target: "_blank"
- %br
> Vous pouvez
= link_to "visionner cette vidéo",
"https://vimeo.com/261478872",
@@ -31,6 +26,11 @@
"https://calendly.com/demarches-simplifiees/accompagnement-administrateur-demarches-simplifiees-fr",
target: "_blank"
+ :javascript
+ document.addEventListener("turbolinks:load", function() {
+ $crisp.push(["do", "trigger:run", ["admin-signup"]]);
+ });
+
.form
.send-wrapper
diff --git a/app/views/dossier_mailer/notify_new_answer.html.haml b/app/views/dossier_mailer/notify_new_answer.html.haml
index 502b5a985..3e0195afe 100644
--- a/app/views/dossier_mailer/notify_new_answer.html.haml
+++ b/app/views/dossier_mailer/notify_new_answer.html.haml
@@ -1,3 +1,6 @@
+- content_for :procedure_logo do
+ = render 'layouts/mailers/logo', url: @logo_url
+
%p
Bonjour,
@@ -10,4 +13,7 @@
= round_button('Lire le message', messagerie_dossier_url(@dossier))
-= render partial: "layouts/mailers/signature", locals: { service: @service }
+= render 'layouts/mailers/signature', service: @service
+
+- content_for :footer do
+ = render 'layouts/mailers/service_footer', service: @service, dossier: @dossier
diff --git a/app/views/dossier_mailer/notify_new_draft.html.haml b/app/views/dossier_mailer/notify_new_draft.html.haml
index 9c3a63a9a..fc22af857 100644
--- a/app/views/dossier_mailer/notify_new_draft.html.haml
+++ b/app/views/dossier_mailer/notify_new_draft.html.haml
@@ -1,3 +1,6 @@
+- content_for :procedure_logo do
+ = render 'layouts/mailers/logo', url: @logo_url
+
%p
Bonjour,
@@ -10,4 +13,7 @@
à l’adresse suivante :
= link_to dossier_url(@dossier), dossier_url(@dossier), target: '_blank', rel: 'noopener'
-= render partial: "layouts/mailers/signature"
+= render 'layouts/mailers/signature'
+
+- content_for :footer do
+ = render 'layouts/mailers/service_footer', service: @service, dossier: @dossier
diff --git a/app/views/gestionnaires/dossiers/_header.html.haml b/app/views/gestionnaires/dossiers/_header.html.haml
index 61afc1361..77a9debbe 100644
--- a/app/views/gestionnaires/dossiers/_header.html.haml
+++ b/app/views/gestionnaires/dossiers/_header.html.haml
@@ -18,13 +18,16 @@
= link_to "Tout le dossier", print_gestionnaire_dossier_path(dossier.procedure, dossier), target: "_blank", rel: "noopener", class: "menu-item menu-link"
%li
= link_to "Uniquement cet onglet", "#", onclick: "window.print()", class: "menu-item menu-link"
- - if Flipflop.download_as_zip_enabled? && dossier.attachments_downloadable?
+ - if Flipflop.download_as_zip_enabled? && !PiecesJustificativesService.liste_pieces_justificatives(dossier).empty?
%span.dropdown.print-menu-opener
%button.button.dropdown-button.icon-only
%span.icon.attachment
%ul.print-menu.dropdown-content
%li
- = link_to "Télécharger toutes les pièces jointes", telecharger_pjs_gestionnaire_dossier_path(dossier.procedure, dossier), target: "_blank", rel: "noopener", class: "menu-item menu-link"
+ - if PiecesJustificativesService.pieces_justificatives_total_size(dossier) < Dossier::TAILLE_MAX_ZIP
+ = link_to "Télécharger toutes les pièces jointes", telecharger_pjs_gestionnaire_dossier_path(dossier.procedure, dossier), target: "_blank", rel: "noopener", class: "menu-item menu-link"
+ - else
+ %p.menu-item Le téléchargement des pièces jointes est désactivé pour les dossiers de plus de #{number_to_human_size Dossier::TAILLE_MAX_ZIP}.
= render partial: "gestionnaires/procedures/dossier_actions", locals: { procedure: dossier.procedure, dossier: dossier, dossier_is_followed: current_gestionnaire&.follow?(dossier) }
diff --git a/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_update_monavis.html.haml b/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_update_monavis.html.haml
new file mode 100644
index 000000000..fad3db3bb
--- /dev/null
+++ b/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_update_monavis.html.haml
@@ -0,0 +1 @@
+= render partial: 'layouts/left_panels/left_panel_admin_procedurescontroller_navbar', locals: { active: 'MonAvis' }
diff --git a/app/views/layouts/mailers/_logo.html.haml b/app/views/layouts/mailers/_logo.html.haml
new file mode 100644
index 000000000..2b0aa1ae2
--- /dev/null
+++ b/app/views/layouts/mailers/_logo.html.haml
@@ -0,0 +1,5 @@
+- if url.present?
+ %table{ width: "100%", border: "0", cellspacing: "0", cellpadding: "0" }
+ %tr
+ %td{ align: "center" }
+ = image_tag url, height: "150", style: "display:block; max-height: 150px; max-width: 150px;"
diff --git a/app/views/layouts/mailers/_service_footer.html.haml b/app/views/layouts/mailers/_service_footer.html.haml
new file mode 100644
index 000000000..c60d887b6
--- /dev/null
+++ b/app/views/layouts/mailers/_service_footer.html.haml
@@ -0,0 +1,34 @@
+%strong
+ Merci de ne pas répondre à cet email.
+ - if dossier.present? && dossier.messagerie_available?
+ Pour vous adresser à votre administration, passez directement par la
+ = succeed '.' do
+ = link_to 'messagerie du dossier', messagerie_dossier_url(dossier), target: '_blank', rel: 'noopener'
+
+- if service.present?
+ %table{ width: "100%", border: "0", cellspacing: "0", cellpadding: "0", style: "cursor:auto;color:#55575d;font-family:Helvetica, Arial, sans-serif;font-size:11px;line-height:22px;text-align:left;" }
+ %tr
+ %td{ width: "50%", valign: "top" }
+ %p
+ %strong Cette démarche est gérée par :
+ %br
+ = service.nom
+ %br
+ = service.organisme
+ %br
+ = service.adresse
+ %td{ width: "50%", valign: "top" }
+ %p
+ %strong Poser une question sur votre dossier :
+ %br
+ - if dossier.present? && dossier.messagerie_available?
+ = link_to 'Par la messagerie', messagerie_dossier_url(dossier), target: '_blank', rel: 'noopener'
+ - else
+ Par email :
+ = link_to service.email, "mailto:#{service.email}"
+ %br
+ Par téléphone :
+ = link_to service.telephone, "tel:#{service.telephone}"
+ %br
+ Horaires : #{ formatted_horaires(service.horaires) }
+
diff --git a/app/views/layouts/mailers/notification.html.haml b/app/views/layouts/mailers/notification.html.haml
deleted file mode 100644
index 04da35e63..000000000
--- a/app/views/layouts/mailers/notification.html.haml
+++ /dev/null
@@ -1,44 +0,0 @@
-- if @logo_url.present?
- - content_for :procedure_logo do
- %table{ width: "100%", border: "0", cellspacing: "0", cellpadding: "0" }
- %tr
- %td{ align: "center" }
- = image_tag @logo_url, height: "150", style: "display:block; max-height: 150px; max-width: 150px;"
-
-- content_for :footer do
- %strong
- Merci de ne pas répondre à cet email.
- - if @dossier.present? && @dossier.messagerie_available?
- Pour vous adresser à votre administration, passez directement par la
- = succeed '.' do
- = link_to 'messagerie du dossier', messagerie_dossier_url(@dossier), target: '_blank', rel: 'noopener'
-
- - if @service.present?
- %table{ width: "100%", border: "0", cellspacing: "0", cellpadding: "0", style: "cursor:auto;color:#55575d;font-family:Helvetica, Arial, sans-serif;font-size:11px;line-height:22px;text-align:left;" }
- %tr
- %td{ width: "50%", valign: "top" }
- %p
- %strong Cette démarche est gérée par :
- %br
- = @service.nom
- %br
- = @service.organisme
- %br
- = @service.adresse
- %td{ width: "50%", valign: "top" }
- %p
- %strong Poser une question sur votre dossier :
- %br
- - if @dossier.present? && @dossier.messagerie_available?
- = link_to 'Par la messagerie', messagerie_dossier_url(@dossier), target: '_blank', rel: 'noopener'
- - else
- Par email :
- = link_to @service.email, "mailto:#{@service.email}"
- %br
- Par téléphone :
- = link_to @service.telephone, "tel:#{@service.telephone}"
- %br
- Horaires : #{ formatted_horaires(@service.horaires) }
-
-
-= render template: 'layouts/mailers/notifications_layout'
diff --git a/app/views/layouts/navbars/_navbar_admin_procedurescontroller_monavis.html.haml b/app/views/layouts/navbars/_navbar_admin_procedurescontroller_monavis.html.haml
new file mode 100644
index 000000000..1ff68e01a
--- /dev/null
+++ b/app/views/layouts/navbars/_navbar_admin_procedurescontroller_monavis.html.haml
@@ -0,0 +1 @@
+= render partial: 'layouts/navbars/navbar_admin_procedurescontroller_index'
diff --git a/app/views/layouts/navbars/_navbar_admin_procedurescontroller_update_monavis.html.haml b/app/views/layouts/navbars/_navbar_admin_procedurescontroller_update_monavis.html.haml
new file mode 100644
index 000000000..1ff68e01a
--- /dev/null
+++ b/app/views/layouts/navbars/_navbar_admin_procedurescontroller_update_monavis.html.haml
@@ -0,0 +1 @@
+= render partial: 'layouts/navbars/navbar_admin_procedurescontroller_index'
diff --git a/app/views/manager/administrateurs/show.html.erb b/app/views/manager/administrateurs/show.html.erb
index 8d152a733..34b4b9857 100644
--- a/app/views/manager/administrateurs/show.html.erb
+++ b/app/views/manager/administrateurs/show.html.erb
@@ -36,6 +36,7 @@ as well as a link to its edit page.
<% if page.resource.invitation_expired? %>
<%= link_to "renvoyer l'invitation", reinvite_manager_administrateur_path(page.resource), method: :post, class: "button" %>
<% end %>
+ <%= button_to "supprimer", delete_manager_administrateur_path(page.resource), method: :delete, disabled: !page.resource.can_be_deleted?, class: "button", data: { confirm: "Confirmez-vous la suppression de l'administrateur ?" }, title: page.resource.can_be_deleted? ? "Supprimer" : "Cet administrateur a des dossiers ou des procédures et ne peut être supprimé" %>
diff --git a/app/views/notification_mailer/_signature.html.haml b/app/views/notification_mailer/default_templates/_signature.html.haml
similarity index 100%
rename from app/views/notification_mailer/_signature.html.haml
rename to app/views/notification_mailer/default_templates/_signature.html.haml
diff --git a/app/views/notification_mailer/closed_mail.html.haml b/app/views/notification_mailer/default_templates/closed_mail.html.haml
similarity index 78%
rename from app/views/notification_mailer/closed_mail.html.haml
rename to app/views/notification_mailer/default_templates/closed_mail.html.haml
index dcaf366be..8af4e8e82 100644
--- a/app/views/notification_mailer/closed_mail.html.haml
+++ b/app/views/notification_mailer/default_templates/closed_mail.html.haml
@@ -7,4 +7,4 @@
%p
À tout moment, vous pouvez consulter votre dossier et les éventuels messages de l'administration à cette adresse : --lien dossier--
-= render partial: "notification_mailer/signature"
+= render partial: "notification_mailer/default_templates/signature"
diff --git a/app/views/notification_mailer/closed_mail_with_attestation.html.haml b/app/views/notification_mailer/default_templates/closed_mail_with_attestation.html.haml
similarity index 83%
rename from app/views/notification_mailer/closed_mail_with_attestation.html.haml
rename to app/views/notification_mailer/default_templates/closed_mail_with_attestation.html.haml
index 22dce3d5a..1c95b1ca7 100644
--- a/app/views/notification_mailer/closed_mail_with_attestation.html.haml
+++ b/app/views/notification_mailer/default_templates/closed_mail_with_attestation.html.haml
@@ -10,4 +10,4 @@
%p
À tout moment, vous pouvez consulter votre dossier et les éventuels messages de l'administration à cette adresse : --lien dossier--
-= render partial: "notification_mailer/signature"
+= render partial: "notification_mailer/default_templates/signature"
diff --git a/app/views/notification_mailer/initiated_mail.html.haml b/app/views/notification_mailer/default_templates/initiated_mail.html.haml
similarity index 79%
rename from app/views/notification_mailer/initiated_mail.html.haml
rename to app/views/notification_mailer/default_templates/initiated_mail.html.haml
index 91007a340..de2c1c91a 100644
--- a/app/views/notification_mailer/initiated_mail.html.haml
+++ b/app/views/notification_mailer/default_templates/initiated_mail.html.haml
@@ -7,4 +7,4 @@
%p
À tout moment, vous pouvez consulter votre dossier et les éventuels messages de l'administration à cette adresse : --lien dossier--
-= render partial: "notification_mailer/signature"
+= render partial: "notification_mailer/default_templates/signature"
diff --git a/app/views/notification_mailer/received_mail.html.haml b/app/views/notification_mailer/default_templates/received_mail.html.haml
similarity index 74%
rename from app/views/notification_mailer/received_mail.html.haml
rename to app/views/notification_mailer/default_templates/received_mail.html.haml
index d006d6271..234d1b1fe 100644
--- a/app/views/notification_mailer/received_mail.html.haml
+++ b/app/views/notification_mailer/default_templates/received_mail.html.haml
@@ -4,4 +4,4 @@
%p
Votre administration vous confirme la bonne réception de votre dossier nº --numéro du dossier--. Celui-ci sera instruit dans le délai légal déclaré par votre interlocuteur.
-= render partial: "notification_mailer/signature"
+= render partial: "notification_mailer/default_templates/signature"
diff --git a/app/views/notification_mailer/refused_mail.html.haml b/app/views/notification_mailer/default_templates/refused_mail.html.haml
similarity index 82%
rename from app/views/notification_mailer/refused_mail.html.haml
rename to app/views/notification_mailer/default_templates/refused_mail.html.haml
index f45054ca2..5cf09152f 100644
--- a/app/views/notification_mailer/refused_mail.html.haml
+++ b/app/views/notification_mailer/default_templates/refused_mail.html.haml
@@ -10,4 +10,4 @@
%p
Pour en savoir plus sur le motif du refus, vous pouvez consulter votre dossier et les éventuels messages de l'administration à cette adresse : --lien dossier--
-= render partial: "notification_mailer/signature"
+= render partial: "notification_mailer/default_templates/signature"
diff --git a/app/views/notification_mailer/without_continuation_mail.html.haml b/app/views/notification_mailer/default_templates/without_continuation_mail.html.haml
similarity index 83%
rename from app/views/notification_mailer/without_continuation_mail.html.haml
rename to app/views/notification_mailer/default_templates/without_continuation_mail.html.haml
index c397c1adc..731d65f08 100644
--- a/app/views/notification_mailer/without_continuation_mail.html.haml
+++ b/app/views/notification_mailer/default_templates/without_continuation_mail.html.haml
@@ -10,4 +10,4 @@
%p
Pour en savoir plus sur les raisons de ce classement sans suite, vous pouvez consulter votre dossier et les éventuels messages de l'administration à cette adresse : --lien dossier--
-= render partial: "notification_mailer/signature"
+= render partial: "notification_mailer/default_templates/signature"
diff --git a/app/views/notification_mailer/send_notification.html.haml b/app/views/notification_mailer/send_notification.html.haml
new file mode 100644
index 000000000..875806f48
--- /dev/null
+++ b/app/views/notification_mailer/send_notification.html.haml
@@ -0,0 +1,7 @@
+- content_for :procedure_logo do
+ = render 'layouts/mailers/logo', url: @logo_url
+
+= @rendered_template
+
+- content_for :footer do
+ = render 'layouts/mailers/service_footer', service: @service, dossier: @dossier
diff --git a/app/views/root/suivi.html.haml b/app/views/root/suivi.html.haml
index c56519619..12f4a963b 100644
--- a/app/views/root/suivi.html.haml
+++ b/app/views/root/suivi.html.haml
@@ -18,6 +18,6 @@
%br
Nous utilisons pour cela Matomo, un outil libre, paramétré pour être en conformité avec la recommandation « Cookies » de la CNIL. Cela signifie que votre adresse IP, par exemple, est anonymisée avant d’être enregistrée. Il est donc impossible d’associer vos visites sur ce site à votre personne.
- %h2.new-h2 Je contribue à enrichir vos données, puis-je y accéder ?
+ %h2.new-h2 Comment désactiver le suivi statistique sur mon navigateur ?
%p.new-p
- Bien sûr ! Les statistiques d’usage sont en accès libre sur stats.data.gouv.fr.
+ Si vous souhaitez désactiver ce suivi statistique, il vous suffit d’activer la fonctionnalité « Ne pas me pister » de votre navigateur. Notre outil de suivi le prendra en compte, et cessera d’inclure vos visites dans les statistiques.
diff --git a/app/views/users/dossiers/merci.html.haml b/app/views/users/dossiers/merci.html.haml
index 941ffe36f..4cd67b54b 100644
--- a/app/views/users/dossiers/merci.html.haml
+++ b/app/views/users/dossiers/merci.html.haml
@@ -23,4 +23,5 @@
.flex.column.align-center
= link_to 'Accéder à votre dossier', dossier_path(@dossier), class: 'button large primary'
= link_to 'Déposer un autre dossier', procedure_lien(@dossier.procedure)
- != @dossier.procedure.monavis_embed
+ .monavis
+ != @dossier.procedure.monavis_embed
diff --git a/config/initializers/urls.rb b/config/initializers/urls.rb
index 7d279eec6..afd9bcbd9 100644
--- a/config/initializers/urls.rb
+++ b/config/initializers/urls.rb
@@ -1,6 +1,6 @@
# API URLs
API_ADRESSE_URL = ENV.fetch("API_ADRESSE_URL", "https://api-adresse.data.gouv.fr")
-API_CARTO_URL = ENV.fetch("API_CARTO_URL", "https://apicarto.sgmap.fr")
+API_CARTO_URL = ENV.fetch("API_CARTO_URL", "https://sandbox.geo.api.gouv.fr/apicarto")
API_ENTREPRISE_URL = ENV.fetch("API_ENTREPRISE_URL", "https://entreprise.api.gouv.fr/v2")
API_GEO_URL = ENV.fetch("API_GEO_URL", "https://geo.api.gouv.fr")
API_GEO_SANDBOX_URL = ENV.fetch("API_GEO_SANDBOX_URL", "https://sandbox.geo.api.gouv.fr")
diff --git a/config/routes.rb b/config/routes.rb
index e77e6eb5f..fc9169607 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -21,6 +21,7 @@ Rails.application.routes.draw do
resources :administrateurs, only: [:index, :show, :new, :create] do
post 'reinvite', on: :member
put 'enable_feature', on: :member
+ delete 'delete', on: :member
end
resources :users, only: [:index, :show] do
diff --git a/spec/lib/api_carto/api_spec.rb b/spec/lib/api_carto/api_spec.rb
index 900debfda..2e52a58b1 100644
--- a/spec/lib/api_carto/api_spec.rb
+++ b/spec/lib/api_carto/api_spec.rb
@@ -5,7 +5,7 @@ describe ApiCarto::API do
subject { described_class.search_qp(geojson) }
before do
- stub_request(:post, "https://apicarto.sgmap.fr/quartiers-prioritaires/search")
+ stub_request(:post, "https://sandbox.geo.api.gouv.fr/apicarto/quartiers-prioritaires/search")
.with(:body => /.*/,
:headers => { 'Content-Type' => 'application/json' })
.to_return(status: status, body: body)
@@ -53,7 +53,7 @@ describe ApiCarto::API do
subject { described_class.search_cadastre(geojson) }
before do
- stub_request(:post, "https://apicarto.sgmap.fr/cadastre/geometrie")
+ stub_request(:post, "https://sandbox.geo.api.gouv.fr/apicarto/cadastre/geometrie")
.with(:body => /.*/,
:headers => { 'Content-Type' => 'application/json' })
.to_return(status: status, body: body)
diff --git a/spec/lib/api_carto/cadastre_adapter_spec.rb b/spec/lib/api_carto/cadastre_adapter_spec.rb
index 6aa2858ca..aaba3cae7 100644
--- a/spec/lib/api_carto/cadastre_adapter_spec.rb
+++ b/spec/lib/api_carto/cadastre_adapter_spec.rb
@@ -4,7 +4,7 @@ describe ApiCarto::CadastreAdapter do
subject { described_class.new(coordinates).results }
before do
- stub_request(:post, "https://apicarto.sgmap.fr/cadastre/geometrie")
+ stub_request(:post, "https://sandbox.geo.api.gouv.fr/apicarto/cadastre/geometrie")
.with(:body => /.*/,
:headers => { 'Content-Type' => 'application/json' })
.to_return(status: status, body: body)
diff --git a/spec/lib/api_carto/quartiers_prioritaires_adapter_spec.rb b/spec/lib/api_carto/quartiers_prioritaires_adapter_spec.rb
index b4ac7ef3a..32f5eb60b 100644
--- a/spec/lib/api_carto/quartiers_prioritaires_adapter_spec.rb
+++ b/spec/lib/api_carto/quartiers_prioritaires_adapter_spec.rb
@@ -4,7 +4,7 @@ describe ApiCarto::QuartiersPrioritairesAdapter do
subject { described_class.new(coordinates).results }
before do
- stub_request(:post, "https://apicarto.sgmap.fr/quartiers-prioritaires/search")
+ stub_request(:post, "https://sandbox.geo.api.gouv.fr/apicarto/quartiers-prioritaires/search")
.with(:body => /.*/,
:headers => { 'Content-Type' => 'application/json' })
.to_return(status: status, body: body)
diff --git a/spec/mailers/dossier_mailer_spec.rb b/spec/mailers/dossier_mailer_spec.rb
index 626d1513b..145d8b17f 100644
--- a/spec/mailers/dossier_mailer_spec.rb
+++ b/spec/mailers/dossier_mailer_spec.rb
@@ -3,6 +3,12 @@ require "rails_helper"
RSpec.describe DossierMailer, type: :mailer do
let(:to_email) { 'gestionnaire@exemple.gouv.fr' }
+ shared_examples 'a dossier notification' do
+ it 'includes the contact informations in the footer' do
+ expect(subject.body).to include('ne pas répondre')
+ end
+ end
+
describe '.notify_new_draft' do
let(:dossier) { create(:dossier, procedure: build(:simple_procedure)) }
@@ -12,6 +18,8 @@ RSpec.describe DossierMailer, type: :mailer do
it { expect(subject.subject).to include(dossier.procedure.libelle) }
it { expect(subject.body).to include(dossier.procedure.libelle) }
it { expect(subject.body).to include(dossier_url(dossier)) }
+
+ it_behaves_like 'a dossier notification'
end
describe '.notify_new_answer' do
@@ -22,6 +30,8 @@ RSpec.describe DossierMailer, type: :mailer do
it { expect(subject.subject).to include("Nouveau message") }
it { expect(subject.subject).to include(dossier.id.to_s) }
it { expect(subject.body).to include(messagerie_dossier_url(dossier)) }
+
+ it_behaves_like 'a dossier notification'
end
describe '.notify_deletion_to_user' do
diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb
index b0d203807..4d28508b9 100644
--- a/spec/mailers/notification_mailer_spec.rb
+++ b/spec/mailers/notification_mailer_spec.rb
@@ -1,58 +1,55 @@
require "spec_helper"
RSpec.describe NotificationMailer, type: :mailer do
- shared_examples_for "create a commentaire not notified" do
- it do
- expect { subject.deliver_now }.to change { Commentaire.count }.by(1)
-
- subject.deliver_now
- commentaire = Commentaire.last
- expect(commentaire.body).to include(email_template.subject_for_dossier(dossier), email_template.body_for_dossier(dossier))
- expect(commentaire.dossier).to eq(dossier)
- end
- end
-
let(:user) { create(:user) }
- let(:dossier) { create(:dossier, :with_service, :en_construction, user: user) }
-
- describe '.send_notification' do
- let(:email_template) { instance_double('email_template', subject_for_dossier: 'subject', body_for_dossier: 'body') }
-
- subject(:mail) do
- klass = Class.new(described_class) do
- # We’re testing the (private) method `NotificationMailer#send_notification`.
- #
- # The standard trick to test a private method would be to `send(:send_notification)`, but doesn’t work here,
- # because ActionMailer does some magic to expose public instance methods as class methods.
- # So, we use inheritance instead to make the private method public for testing purposes.
- def send_notification(dossier, template)
- super
- end
- end
- klass.send_notification(dossier, email_template)
- end
-
- it { expect(mail.subject).to eq(email_template.subject_for_dossier) }
- it { expect(mail.body).to include(email_template.body_for_dossier) }
- it { expect(mail.body).to have_link('messagerie') }
-
- it_behaves_like "create a commentaire not notified"
- end
+ let(:procedure) { create(:simple_procedure) }
+ let(:dossier) { create(:dossier, :en_construction, :for_individual, :with_service, user: user, procedure: procedure) }
describe '.send_dossier_received' do
- subject(:mail) { described_class.send_dossier_received(dossier) }
- let(:email_template) { create(:received_mail) }
+ let(:email_template) { create(:received_mail, subject: 'Email subject', body: 'Your dossier was processed. Thanks.') }
before do
dossier.procedure.received_mail = email_template
end
- it do
- expect(mail.subject).to eq(email_template.subject)
- expect(mail.body).to include(email_template.body)
+ subject(:mail) { described_class.send_dossier_received(dossier) }
+
+ it 'creates a commentaire in the messagerie' do
+ expect { subject.deliver_now }.to change { Commentaire.count }.by(1)
+
+ commentaire = Commentaire.last
+ expect(commentaire.body).to include(email_template.subject_for_dossier(dossier), email_template.body_for_dossier(dossier))
+ expect(commentaire.dossier).to eq(dossier)
+ end
+
+ it 'renders the template' do
+ expect(mail.subject).to eq('Email subject')
+ expect(mail.body).to include('Your dossier was processed')
expect(mail.body).to have_link('messagerie')
end
- it_behaves_like "create a commentaire not notified"
+ context 'when the template body contains tags' do
+ let(:email_template) { create(:received_mail, subject: 'Email subject', body: 'Hello --nom--, your dossier --lien dossier-- was processed.') }
+
+ it 'replaces value tags with the proper value' do
+ expect(mail.body).to have_content(dossier.individual.nom)
+ end
+
+ it 'replaces link tags with a clickable link' do
+ expect(mail.body).to have_link(dossier_url(dossier))
+ end
+ end
+
+ context 'when the template body contains HTML' do
+ let(:email_template) { create(:received_mail, body: 'Your dossier was processed. ') }
+
+ it 'allows basic formatting tags' do
+ expect(mail.body).to include('dossier')
+ end
+
+ it 'sanitizes sensitive content' do
+ expect(mail.body).not_to include('iframe')
+ end
+ end
end
end