Merge branch 'dev'

This commit is contained in:
gregoirenovel 2018-09-18 09:55:49 +02:00
commit 7ed975fd71
27 changed files with 264 additions and 46 deletions

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="20" viewBox="0 0 16 20"><g fill="none" fill-rule="evenodd"><path d="M11.5 8H15l-7 7-7-7h3.5V1h7zM1 19h14" stroke="#FFF" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/><path d="M-4-2h24v24H-4z"/></g></svg>

After

Width:  |  Height:  |  Size: 281 B

View file

@ -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;
}
}

View file

@ -2,6 +2,8 @@
@import "constants"; @import "constants";
#dossier-show { #dossier-show {
margin-bottom: 30px;
.sub-header { .sub-header {
.label { .label {
float: right; float: right;

View file

@ -53,6 +53,10 @@
background-image: image-url("icons/attachment.svg"); background-image: image-url("icons/attachment.svg");
} }
&.download {
background-image: image-url("icons/download-white.svg");
}
&.lock { &.lock {
background-image: image-url("icons/lock.svg"); background-image: image-url("icons/lock.svg");
} }

View file

@ -1,7 +1,12 @@
@import "placeholders"; @import "colors";
.patron { .patron {
p { p {
margin-bottom: 20px; margin-bottom: 20px;
} }
.icon.download {
background-color: $blue;
box-shadow: 0px 0px 1px 2px $blue;
}
} }

View file

@ -55,18 +55,28 @@
margin: auto; margin: auto;
} }
h3 {
font-size: 1.1em;
font-weight: bold;
margin-bottom: $default-spacer;
}
p { p {
margin-bottom: $default-padding; 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 { blockquote {
quotes: "« " " »" "" ""; quotes: "« " " »" "" "";
margin-bottom: $default-padding * 3;
} }
blockquote::before { blockquote::before {
@ -77,7 +87,7 @@
content: close-quote; content: close-quote;
} }
.icon { .action {
margin-right: $default-spacer; margin-bottom: $default-padding * 3;
} }
} }

View file

@ -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

View file

@ -2,8 +2,6 @@ module NewUser
class DossiersController < UserController class DossiersController < UserController
include DossierHelper 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!, 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_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] before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update_brouillon, :modifier, :update]
@ -177,10 +175,6 @@ module NewUser
end end
end end
def new_demarche_url
"https://doc.demarches-simplifiees.fr/listes-des-demarches"
end
private private
def ensure_dossier_can_be_updated def ensure_dossier_can_be_updated

View file

@ -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")

View file

@ -36,10 +36,4 @@
%p= politique %p= politique
.footer-row.footer-bottom-line .footer-row.footer-bottom-line
= link_to "Accessibilité", accessibilite_index_path, :class => "footer-link" = render partial: "new_user/dossiers/general_footer_row", locals: { dossier: @dossier }
= 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

View file

@ -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

View file

@ -0,0 +1,4 @@
%footer.dossier-footer
.container
.footer-row.footer-bottom-line
= render partial: "new_user/dossiers/general_footer_row", locals: { dossier: nil }

View file

@ -1,7 +1,7 @@
- content_for(:title, "Modification du brouillon nº #{@dossier.id} (#{@dossier.procedure.libelle})") - content_for(:title, "Modification du brouillon nº #{@dossier.id} (#{@dossier.procedure.libelle})")
- content_for :footer do - 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-edit
.dossier-header.sub-header .dossier-header.sub-header

View file

@ -1,5 +1,8 @@
- content_for(:title, "Demande · Dossier nº #{@dossier.id} (#{@dossier.procedure.libelle})") - 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 #dossier-show
= render partial: 'new_user/dossiers/show/header', locals: { dossier: @dossier } = render partial: 'new_user/dossiers/show/header', locals: { dossier: @dossier }
@ -8,3 +11,4 @@
.container .container
- if !@dossier.read_only? - if !@dossier.read_only?
= link_to "Modifier le dossier", modifier_dossier_path(@dossier), class: 'button primary edit-form' = link_to "Modifier le dossier", modifier_dossier_path(@dossier), class: 'button primary edit-form'
.clearfix

View file

@ -1,7 +1,7 @@
- content_for(:title, "Nouveau dossier (#{@dossier.procedure.libelle})") - content_for(:title, "Nouveau dossier (#{@dossier.procedure.libelle})")
- content_for :footer do - 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 .two-columns
.columns-container .columns-container

View file

@ -1,8 +1,11 @@
- content_for(:title, "Dossiers") - content_for(:title, "Dossiers")
- content_for :footer do
= render partial: "new_user/dossiers/index_footer"
.dossiers-headers.sub-header .dossiers-headers.sub-header
.container .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 - if @dossiers_invites.count == 0
%h1.page-title Mes dossiers %h1.page-title Mes dossiers
@ -63,4 +66,4 @@
.dossiers-table-empty .dossiers-table-empty
%h2.empty-text Aucun dossier. %h2.empty-text Aucun dossier.
%p.empty-text-details Vous navez pas encore commencé de démarche. %p.empty-text-details Vous navez 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"

View file

@ -1,5 +1,8 @@
- content_for(:title, "Messagerie · Dossier nº #{@dossier.id} (#{@dossier.procedure.libelle})") - 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 #dossier-show
= render partial: 'new_user/dossiers/show/header', locals: { dossier: @dossier } = render partial: 'new_user/dossiers/show/header', locals: { dossier: @dossier }

View file

@ -1,5 +1,8 @@
- content_for(:title, "Modifier · Dossier nº #{@dossier.id} (#{@dossier.procedure.libelle})") - 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 #dossier-show
= render partial: 'new_user/dossiers/show/header', locals: { dossier: @dossier } = render partial: 'new_user/dossiers/show/header', locals: { dossier: @dossier }

View file

@ -1,17 +1,13 @@
- content_for(:title, "Résumé · Dossier nº #{@dossier.id} (#{@dossier.procedure.libelle})") - 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 #dossier-show
= render partial: 'new_user/dossiers/show/header', locals: { dossier: @dossier } = render partial: 'new_user/dossiers/show/header', locals: { dossier: @dossier }
.container .container
= render partial: 'new_user/dossiers/show/status_overview', locals: { dossier: @dossier } = render partial: 'new_user/dossiers/show/status_overview', locals: { dossier: @dossier }
- latest_message = @dossier.commentaires.last - if !@dossier.termine?
- if latest_message.present? = render partial: 'new_user/dossiers/show/latest_message', locals: { dossier: @dossier }
.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'

View file

@ -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'

View file

@ -28,7 +28,7 @@
- elsif dossier.accepte? - elsif dossier.accepte?
.accepte .accepte
%p %p.decision
%span.icon.accept %span.icon.accept
Votre dossier a été Votre dossier a été
= succeed '.' do = succeed '.' do
@ -38,9 +38,15 @@
%h3 Motif de lacceptation %h3 Motif de lacceptation
%blockquote= dossier.motivation %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 lattestation
- elsif dossier.refuse? - elsif dossier.refuse?
.refuse .refuse
%p %p.decision
%span.icon.refuse %span.icon.refuse
Nous sommes désolés, votre dossier a malheureusement été Nous sommes désolés, votre dossier a malheureusement été
= succeed '.' do = succeed '.' do
@ -50,9 +56,12 @@
%h3 Motif du refus %h3 Motif du refus
%blockquote= dossier.motivation %blockquote= dossier.motivation
.action
= link_to 'Envoyer un message à ladministration', messagerie_dossier_url(dossier, anchor: 'new_commentaire'), class: 'button'
- elsif dossier.sans_suite? - elsif dossier.sans_suite?
.sans-suite .sans-suite
%p %p.decision
%span.icon.without-continuation %span.icon.without-continuation
Votre dossier a été classé Votre dossier a été classé
= succeed '.' do = succeed '.' do

View file

@ -23,6 +23,7 @@
%span.icon.search %span.icon.search
%span.icon.sign-out %span.icon.sign-out
%span.icon.info %span.icon.info
%span.icon.download
%span.icon.frown %span.icon.frown
%span.icon.meh %span.icon.meh
%span.icon.smile %span.icon.smile

View file

@ -292,6 +292,7 @@ Rails.application.routes.draw do
end end
end end
resource :feedback, only: [:create] resource :feedback, only: [:create]
get 'demarches' => 'demarches#index'
end end
# #

View file

@ -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

View file

@ -136,5 +136,14 @@ FactoryBot.define do
end end
end 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
end end

View file

@ -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(:service) { create(:service) }
let(:dossier) { let(:dossier) {
dossier = create(:dossier) dossier = create(:dossier)
@ -6,7 +6,7 @@ describe 'new_user/dossiers/_footer.html.haml', type: :view do
return dossier 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 it "affiche les informations de contact" do
expect(subject).to have_text(service.nom) expect(subject).to have_text(service.nom)

View file

@ -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.not_to have_selector('.status-timeline') }
it { is_expected.to have_selector('.status-explanation .accepte') } it { is_expected.to have_selector('.status-explanation .accepte') }
it { is_expected.to have_text(dossier.motivation) } 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 end
context 'when refusé' do 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.not_to have_selector('.status-timeline') }
it { is_expected.to have_selector('.status-explanation .refuse') } it { is_expected.to have_selector('.status-explanation .refuse') }
it { is_expected.to have_text(dossier.motivation) } it { is_expected.to have_text(dossier.motivation) }
it { is_expected.to have_link(nil, href: messagerie_dossier_url(dossier, anchor: 'new_commentaire')) }
end end
context 'when classé sans suite' do context 'when classé sans suite' do