diff --git a/app/assets/images/icons/download-white.svg b/app/assets/images/icons/download-white.svg new file mode 100644 index 000000000..9b3f106ad --- /dev/null +++ b/app/assets/images/icons/download-white.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/stylesheets/new_design/demarches_index.scss b/app/assets/stylesheets/new_design/demarches_index.scss new file mode 100644 index 000000000..e14441051 --- /dev/null +++ b/app/assets/stylesheets/new_design/demarches_index.scss @@ -0,0 +1,32 @@ +@import "colors"; + +#demarches-index { + margin-bottom: 30px; +} + +.page-title { + margin-top: 30px; + margin-bottom: 30px; +} + +.list-header { + color: $grey; + font-weight: bold; + margin-bottom: 10px; +} + +.demarche-links { + border-top: 1px solid $border-grey; + margin-bottom: 30px; +} + +.demarche-link { + display: block; + padding: 10px; + border-bottom: 1px solid $border-grey; + width: 100%; + + &:hover { + background-color: $lighter-blue; + } +} diff --git a/app/assets/stylesheets/new_design/dossier_show.scss b/app/assets/stylesheets/new_design/dossier_show.scss index be12db19e..e85c5d10c 100644 --- a/app/assets/stylesheets/new_design/dossier_show.scss +++ b/app/assets/stylesheets/new_design/dossier_show.scss @@ -2,6 +2,8 @@ @import "constants"; #dossier-show { + margin-bottom: 30px; + .sub-header { .label { float: right; diff --git a/app/assets/stylesheets/new_design/icons.scss b/app/assets/stylesheets/new_design/icons.scss index 7962cf268..c2efb749a 100644 --- a/app/assets/stylesheets/new_design/icons.scss +++ b/app/assets/stylesheets/new_design/icons.scss @@ -53,6 +53,10 @@ background-image: image-url("icons/attachment.svg"); } + &.download { + background-image: image-url("icons/download-white.svg"); + } + &.lock { background-image: image-url("icons/lock.svg"); } diff --git a/app/assets/stylesheets/new_design/patron.scss b/app/assets/stylesheets/new_design/patron.scss index 9c255eb6f..90f4931f4 100644 --- a/app/assets/stylesheets/new_design/patron.scss +++ b/app/assets/stylesheets/new_design/patron.scss @@ -1,7 +1,12 @@ -@import "placeholders"; +@import "colors"; .patron { p { margin-bottom: 20px; } + + .icon.download { + background-color: $blue; + box-shadow: 0px 0px 1px 2px $blue; + } } diff --git a/app/assets/stylesheets/new_design/status_overview.scss b/app/assets/stylesheets/new_design/status_overview.scss index 55643b1d3..beede684f 100644 --- a/app/assets/stylesheets/new_design/status_overview.scss +++ b/app/assets/stylesheets/new_design/status_overview.scss @@ -55,18 +55,28 @@ margin: auto; } - h3 { - font-size: 1.1em; - font-weight: bold; - margin-bottom: $default-spacer; - } - p { margin-bottom: $default-padding; } + .decision { + font-size: 1.2em; + margin-top: $default-padding * 3; + margin-bottom: $default-padding * 3; + } + + .icon { + margin-right: $default-spacer; + } + + h3 { + font-weight: bold; + margin-bottom: $default-spacer; + } + blockquote { quotes: "« " " »" "‘" "’"; + margin-bottom: $default-padding * 3; } blockquote::before { @@ -77,7 +87,7 @@ content: close-quote; } - .icon { - margin-right: $default-spacer; + .action { + margin-bottom: $default-padding * 3; } } diff --git a/app/controllers/new_user/demarches_controller.rb b/app/controllers/new_user/demarches_controller.rb new file mode 100644 index 000000000..56c984dd6 --- /dev/null +++ b/app/controllers/new_user/demarches_controller.rb @@ -0,0 +1,21 @@ +module NewUser + class DemarchesController < UserController + def index + @previous_demarches_still_active = current_user + .dossiers + .includes(:procedure) + .map(&:procedure) + .uniq + .select { |p| p.publiee? } + + @popular_demarches = Procedure + .select("procedures.*, COUNT(*) AS procedures_count") + .joins(:dossiers) + .publiees + .where(dossiers: { created_at: 7.days.ago..Time.now }) + .group("procedures.id") + .order("procedures_count DESC") + .limit(5) + end + end +end diff --git a/app/controllers/new_user/dossiers_controller.rb b/app/controllers/new_user/dossiers_controller.rb index d602695f5..ce5023b9f 100644 --- a/app/controllers/new_user/dossiers_controller.rb +++ b/app/controllers/new_user/dossiers_controller.rb @@ -2,8 +2,6 @@ module NewUser class DossiersController < UserController include DossierHelper - helper_method :new_demarche_url - before_action :ensure_ownership!, except: [:index, :show, :demande, :messagerie, :brouillon, :update_brouillon, :modifier, :update, :recherche] before_action :ensure_ownership_or_invitation!, only: [:show, :demande, :messagerie, :brouillon, :update_brouillon, :modifier, :update, :create_commentaire] before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update_brouillon, :modifier, :update] @@ -177,10 +175,6 @@ module NewUser end end - def new_demarche_url - "https://doc.demarches-simplifiees.fr/listes-des-demarches" - end - private def ensure_dossier_can_be_updated diff --git a/app/views/new_user/demarches/index.html.haml b/app/views/new_user/demarches/index.html.haml new file mode 100644 index 000000000..c7ccaef2c --- /dev/null +++ b/app/views/new_user/demarches/index.html.haml @@ -0,0 +1,25 @@ +- content_for(:title, "Démarches") + +- content_for :footer do + = render partial: "new_user/dossiers/index_footer" + +#demarches-index + .container + %h1.page-title Démarches + + - if @previous_demarches_still_active.present? + %h2.list-header SUR LESQUELLES VOUS AVEZ DÉJÀ DÉPOSÉ UN DOSSIER + %ul.demarche-links + - @previous_demarches_still_active.each do |demarche| + %li + = link_to(demarche.libelle, commencer_url(procedure_path: demarche.path), class: "demarche-link") + + - if @popular_demarches.present? + %h2.list-header LES PLUS POPULAIRES + %ul.demarche-links + - @popular_demarches.each do |demarche| + %li + = link_to(demarche.libelle, commencer_url(procedure_path: demarche.path), class: "demarche-link") + + %h2.list-header TOUTES LES DÉMARCHES + = link_to("Voir l'intégralité des démarches disponibles", LISTE_DES_DEMARCHES_URL, class: "button") diff --git a/app/views/new_user/dossiers/_footer.html.haml b/app/views/new_user/dossiers/_dossier_footer.html.haml similarity index 73% rename from app/views/new_user/dossiers/_footer.html.haml rename to app/views/new_user/dossiers/_dossier_footer.html.haml index 95c0aa129..b4fce7631 100644 --- a/app/views/new_user/dossiers/_footer.html.haml +++ b/app/views/new_user/dossiers/_dossier_footer.html.haml @@ -36,10 +36,4 @@ %p= politique .footer-row.footer-bottom-line - = link_to "Accessibilité", accessibilite_index_path, :class => "footer-link" - – - = link_to "CGU", CGU_URL, :class => "footer-link", :target => "_blank", rel: "noopener noreferrer" - – - = link_to "Mentions légales", MENTIONS_LEGALES_URL, :class => "footer-link", :target => "_blank", rel: "noopener noreferrer" - – - = contact_link "Contact technique", class: "footer-link", dossier_id: dossier.id + = render partial: "new_user/dossiers/general_footer_row", locals: { dossier: @dossier } diff --git a/app/views/new_user/dossiers/_general_footer_row.html.haml b/app/views/new_user/dossiers/_general_footer_row.html.haml new file mode 100644 index 000000000..de46e2cc4 --- /dev/null +++ b/app/views/new_user/dossiers/_general_footer_row.html.haml @@ -0,0 +1,7 @@ += link_to "Accessibilité", accessibilite_index_path, :class => "footer-link" +– += link_to "CGU", CGU_URL, :class => "footer-link", :target => "_blank", rel: "noopener noreferrer" +– += link_to "Mentions légales", MENTIONS_LEGALES_URL, :class => "footer-link", :target => "_blank", rel: "noopener noreferrer" +– += contact_link "Contact technique", class: "footer-link", dossier_id: dossier&.id diff --git a/app/views/new_user/dossiers/_index_footer.html.haml b/app/views/new_user/dossiers/_index_footer.html.haml new file mode 100644 index 000000000..241ba25d7 --- /dev/null +++ b/app/views/new_user/dossiers/_index_footer.html.haml @@ -0,0 +1,4 @@ +%footer.dossier-footer + .container + .footer-row.footer-bottom-line + = render partial: "new_user/dossiers/general_footer_row", locals: { dossier: nil } diff --git a/app/views/new_user/dossiers/brouillon.html.haml b/app/views/new_user/dossiers/brouillon.html.haml index 81f264954..77dec858b 100644 --- a/app/views/new_user/dossiers/brouillon.html.haml +++ b/app/views/new_user/dossiers/brouillon.html.haml @@ -1,7 +1,7 @@ - content_for(:title, "Modification du brouillon nº #{@dossier.id} (#{@dossier.procedure.libelle})") - content_for :footer do - = render partial: "new_user/dossiers/footer", locals: { dossier: @dossier } + = render partial: "new_user/dossiers/dossier_footer", locals: { dossier: @dossier } .dossier-edit .dossier-header.sub-header diff --git a/app/views/new_user/dossiers/demande.html.haml b/app/views/new_user/dossiers/demande.html.haml index f5be19d48..623a8ac54 100644 --- a/app/views/new_user/dossiers/demande.html.haml +++ b/app/views/new_user/dossiers/demande.html.haml @@ -1,5 +1,8 @@ - content_for(:title, "Demande · Dossier nº #{@dossier.id} (#{@dossier.procedure.libelle})") +- content_for :footer do + = render partial: "new_user/dossiers/dossier_footer", locals: { dossier: @dossier } + #dossier-show = render partial: 'new_user/dossiers/show/header', locals: { dossier: @dossier } @@ -8,3 +11,4 @@ .container - if !@dossier.read_only? = link_to "Modifier le dossier", modifier_dossier_path(@dossier), class: 'button primary edit-form' + .clearfix diff --git a/app/views/new_user/dossiers/identite.html.haml b/app/views/new_user/dossiers/identite.html.haml index 920184db9..e4a5cc412 100644 --- a/app/views/new_user/dossiers/identite.html.haml +++ b/app/views/new_user/dossiers/identite.html.haml @@ -1,7 +1,7 @@ - content_for(:title, "Nouveau dossier (#{@dossier.procedure.libelle})") - content_for :footer do - = render partial: "new_user/dossiers/footer", locals: { dossier: @dossier } + = render partial: "new_user/dossiers/dossier_footer", locals: { dossier: @dossier } .two-columns .columns-container diff --git a/app/views/new_user/dossiers/index.html.haml b/app/views/new_user/dossiers/index.html.haml index e37d78286..40c6189c7 100644 --- a/app/views/new_user/dossiers/index.html.haml +++ b/app/views/new_user/dossiers/index.html.haml @@ -1,8 +1,11 @@ - content_for(:title, "Dossiers") +- content_for :footer do + = render partial: "new_user/dossiers/index_footer" + .dossiers-headers.sub-header .container - = link_to "Commencer une nouvelle démarche", new_demarche_url, class: "button secondary new-demarche" + = link_to "Commencer une nouvelle démarche", demarches_url, class: "button secondary new-demarche" - if @dossiers_invites.count == 0 %h1.page-title Mes dossiers @@ -63,4 +66,4 @@ .dossiers-table-empty %h2.empty-text Aucun dossier. %p.empty-text-details Vous n’avez pas encore commencé de démarche. - = link_to "Commencer une nouvelle démarche", new_demarche_url, class: "button primary" + = link_to "Commencer une nouvelle démarche", demarches_url, class: "button primary" diff --git a/app/views/new_user/dossiers/messagerie.html.haml b/app/views/new_user/dossiers/messagerie.html.haml index 7715042cb..9cac5fe77 100644 --- a/app/views/new_user/dossiers/messagerie.html.haml +++ b/app/views/new_user/dossiers/messagerie.html.haml @@ -1,5 +1,8 @@ - content_for(:title, "Messagerie · Dossier nº #{@dossier.id} (#{@dossier.procedure.libelle})") +- content_for :footer do + = render partial: "new_user/dossiers/dossier_footer", locals: { dossier: @dossier } + #dossier-show = render partial: 'new_user/dossiers/show/header', locals: { dossier: @dossier } diff --git a/app/views/new_user/dossiers/modifier.html.haml b/app/views/new_user/dossiers/modifier.html.haml index 624dcaa6a..7341db4fd 100644 --- a/app/views/new_user/dossiers/modifier.html.haml +++ b/app/views/new_user/dossiers/modifier.html.haml @@ -1,5 +1,8 @@ - content_for(:title, "Modifier · Dossier nº #{@dossier.id} (#{@dossier.procedure.libelle})") +- content_for :footer do + = render partial: "new_user/dossiers/dossier_footer", locals: { dossier: @dossier } + #dossier-show = render partial: 'new_user/dossiers/show/header', locals: { dossier: @dossier } diff --git a/app/views/new_user/dossiers/show.html.haml b/app/views/new_user/dossiers/show.html.haml index b94a0686f..57b944251 100644 --- a/app/views/new_user/dossiers/show.html.haml +++ b/app/views/new_user/dossiers/show.html.haml @@ -1,17 +1,13 @@ - content_for(:title, "Résumé · Dossier nº #{@dossier.id} (#{@dossier.procedure.libelle})") +- content_for :footer do + = render partial: "new_user/dossiers/dossier_footer", locals: { dossier: @dossier } + #dossier-show = render partial: 'new_user/dossiers/show/header', locals: { dossier: @dossier } .container = render partial: 'new_user/dossiers/show/status_overview', locals: { dossier: @dossier } - - latest_message = @dossier.commentaires.last - - if latest_message.present? - .latest-message-section - %h3.tab-title Dernier message - - .message.inverted-background - = render partial: "shared/dossiers/messages/message", locals: { commentaire: latest_message, connected_user: current_user, messagerie_seen_at: nil } - - = link_to commentaire_answer_action(latest_message, current_user), messagerie_dossier_url(@dossier, anchor: 'new_commentaire'), class: 'button send' + - if !@dossier.termine? + = render partial: 'new_user/dossiers/show/latest_message', locals: { dossier: @dossier } diff --git a/app/views/new_user/dossiers/show/_latest_message.html.haml b/app/views/new_user/dossiers/show/_latest_message.html.haml new file mode 100644 index 000000000..255e79696 --- /dev/null +++ b/app/views/new_user/dossiers/show/_latest_message.html.haml @@ -0,0 +1,9 @@ +- latest_message = dossier.commentaires.last +- if latest_message.present? + .latest-message-section + %h3.tab-title Dernier message + + .message.inverted-background + = render partial: "shared/dossiers/messages/message", locals: { commentaire: latest_message, connected_user: current_user, messagerie_seen_at: nil } + + = link_to commentaire_answer_action(latest_message, current_user), messagerie_dossier_url(dossier, anchor: 'new_commentaire'), class: 'button send' diff --git a/app/views/new_user/dossiers/show/_status_overview.html.haml b/app/views/new_user/dossiers/show/_status_overview.html.haml index 026020eec..2db5da04c 100644 --- a/app/views/new_user/dossiers/show/_status_overview.html.haml +++ b/app/views/new_user/dossiers/show/_status_overview.html.haml @@ -28,19 +28,25 @@ - elsif dossier.accepte? .accepte - %p + %p.decision %span.icon.accept Votre dossier a été = succeed '.' do %strong accepté - - if dossier.motivation.present? - %h3 Motif de l’acceptation - %blockquote= dossier.motivation + - if dossier.motivation.present? + %h3 Motif de l’acceptation + %blockquote= dossier.motivation + + - if dossier.attestation.present? + .action + = link_to attestation_dossier_path(dossier), target: '_blank', class: 'button primary' do + %span.icon.download + Télécharger l’attestation - elsif dossier.refuse? .refuse - %p + %p.decision %span.icon.refuse Nous sommes désolés, votre dossier a malheureusement été = succeed '.' do @@ -50,14 +56,17 @@ %h3 Motif du refus %blockquote= dossier.motivation + .action + = link_to 'Envoyer un message à l’administration', messagerie_dossier_url(dossier, anchor: 'new_commentaire'), class: 'button' + - elsif dossier.sans_suite? .sans-suite - %p + %p.decision %span.icon.without-continuation Votre dossier a été classé = succeed '.' do %strong sans suite - - if dossier.motivation.present? - %h3 Motif du classement sans suite - %blockquote= dossier.motivation + - if dossier.motivation.present? + %h3 Motif du classement sans suite + %blockquote= dossier.motivation diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index f0d8a02a1..35173bda4 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -23,6 +23,7 @@ %span.icon.search %span.icon.sign-out %span.icon.info + %span.icon.download %span.icon.frown %span.icon.meh %span.icon.smile diff --git a/config/routes.rb b/config/routes.rb index 12b5dab91..4651f88bd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -292,6 +292,7 @@ Rails.application.routes.draw do end end resource :feedback, only: [:create] + get 'demarches' => 'demarches#index' end # diff --git a/lib/tasks/2018_09_12_fix_templates.rake b/lib/tasks/2018_09_12_fix_templates.rake new file mode 100644 index 000000000..4d29f4035 --- /dev/null +++ b/lib/tasks/2018_09_12_fix_templates.rake @@ -0,0 +1,75 @@ +namespace :'2018_09_12_fix_templates' do + task run: :environment do + dossiers_with_invalid_attestations = find_dossiers_with_sent_and_invalid_attestations + fix_templates + fixed_attestations = regenerate_attestations(dossiers_with_invalid_attestations) + send_regenerated_attestations(dossiers_with_invalid_attestations) + end + + # 16:15 in Paris -> 14:15 UTC + DEPLOY_DATETIME = DateTime.new(2018, 9, 5, 14, 15, 0) + + def find_dossiers_with_sent_and_invalid_attestations + invalid_procedures_ids = AttestationTemplate + .where("body LIKE '%--libellé procédure--%'") + .pluck(:procedure_id) + + dossiers_with_invalid_template_ids = Dossier + .where(procedure_id: invalid_procedures_ids) + .where(processed_at: DEPLOY_DATETIME..Time.now) + .pluck(:id) + + Attestation + .includes(:dossier) + .where(created_at: DEPLOY_DATETIME..Time.now) + .where(dossier_id: dossiers_with_invalid_template_ids) + .map(&:dossier) + end + + def fix_templates + klasses = [ + Mails::ClosedMail, + Mails::InitiatedMail, + Mails::ReceivedMail, + Mails::RefusedMail, + Mails::WithoutContinuationMail, + AttestationTemplate + ] + + klasses.each do |klass| + klass + .where("body LIKE '%--libellé procédure--%'") + .each do |instance| + + instance.update(body: instance.body.gsub("--libellé procédure--", "--libellé démarche--")) + rake_puts "Body mis-à-jour pour #{klass.to_s}##{instance.id}" + end + end + end + + def delete_then_regenerate_attestations(dossiers_with_invalid_attestations) + dossiers_with_invalid_attestations.each do |dossier| + begin + dossier.attestation.destroy + + dossier.attestation = dossier.build_attestation + dossier.save + + rake_puts "Attestation regénérée pour le dossier #{dossier.id}" + rescue + rake_puts "Erreur lors de la régénération de l'attestation pour le dossier #{dossier.id}" + end + end + end + + def send_regenerated_attestations(dossiers_with_invalid_attestations) + dossiers_with_invalid_attestations.each do |dossier| + begin + ResendAttestationMailer.resend_attestation(dossier).deliver_later + rake_puts "Email envoyé à #{dossier.user.email} pour le dossier #{dossier.id}" + rescue + rake_puts "Erreur lors de l'envoi de l'email à #{dossier.user.email} pour le dossier #{dossier.id}" + end + end + end +end diff --git a/spec/factories/dossier.rb b/spec/factories/dossier.rb index cb159e899..ebadac8b2 100644 --- a/spec/factories/dossier.rb +++ b/spec/factories/dossier.rb @@ -136,5 +136,14 @@ FactoryBot.define do end end end + + trait :with_attestation do + after(:create) do |dossier, _evaluator| + if dossier.procedure.attestation_template.blank? + dossier.procedure.attestation_template = create(:attestation_template) + end + dossier.attestation = dossier.build_attestation + end + end end end diff --git a/spec/views/new_user/dossiers/_footer.html.haml_spec.rb b/spec/views/new_user/dossiers/_dossier_footer.html.haml_spec.rb similarity index 83% rename from spec/views/new_user/dossiers/_footer.html.haml_spec.rb rename to spec/views/new_user/dossiers/_dossier_footer.html.haml_spec.rb index d840c876e..21ef07687 100644 --- a/spec/views/new_user/dossiers/_footer.html.haml_spec.rb +++ b/spec/views/new_user/dossiers/_dossier_footer.html.haml_spec.rb @@ -1,4 +1,4 @@ -describe 'new_user/dossiers/_footer.html.haml', type: :view do +describe 'new_user/dossiers/_dossier_footer.html.haml', type: :view do let(:service) { create(:service) } let(:dossier) { dossier = create(:dossier) @@ -6,7 +6,7 @@ describe 'new_user/dossiers/_footer.html.haml', type: :view do return dossier } - subject { render 'new_user/dossiers/footer.html.haml', dossier: dossier } + subject { render 'new_user/dossiers/dossier_footer.html.haml', dossier: dossier } it "affiche les informations de contact" do expect(subject).to have_text(service.nom) diff --git a/spec/views/new_user/dossiers/show/_status_overview.html.haml_spec.rb b/spec/views/new_user/dossiers/show/_status_overview.html.haml_spec.rb index e239555ca..d98eecc4f 100644 --- a/spec/views/new_user/dossiers/show/_status_overview.html.haml_spec.rb +++ b/spec/views/new_user/dossiers/show/_status_overview.html.haml_spec.rb @@ -67,6 +67,11 @@ describe 'new_user/dossiers/show/_status_overview.html.haml', type: :view do it { is_expected.not_to have_selector('.status-timeline') } it { is_expected.to have_selector('.status-explanation .accepte') } it { is_expected.to have_text(dossier.motivation) } + + context 'with attestation' do + let(:dossier) { create :dossier, :accepte, :with_attestation } + it { is_expected.to have_link(nil, href: attestation_dossier_path(dossier)) } + end end context 'when refusé' do @@ -75,6 +80,7 @@ describe 'new_user/dossiers/show/_status_overview.html.haml', type: :view do it { is_expected.not_to have_selector('.status-timeline') } it { is_expected.to have_selector('.status-explanation .refuse') } it { is_expected.to have_text(dossier.motivation) } + it { is_expected.to have_link(nil, href: messagerie_dossier_url(dossier, anchor: 'new_commentaire')) } end context 'when classé sans suite' do