commit
c8d7d1f199
25 changed files with 612 additions and 40 deletions
1
app/assets/images/icons/lock.svg
Normal file
1
app/assets/images/icons/lock.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="640.5 640.5 512 512"><path d="M820.864 861.591h151.273v-56.727c0-20.879-7.387-38.705-22.159-53.478-14.773-14.772-32.599-22.159-53.478-22.159s-38.705 7.387-53.477 22.159c-14.773 14.773-22.159 32.599-22.159 53.478v56.727zm245.818 28.364v170.182c0 7.879-2.758 14.575-8.272 20.091-5.516 5.515-12.212 8.272-20.091 8.272H754.682c-7.879 0-14.576-2.758-20.091-8.272-5.515-5.516-8.272-12.212-8.272-20.091V889.955c0-7.879 2.757-14.576 8.272-20.091s12.212-8.273 20.091-8.273h9.455v-56.727c0-36.243 13-67.364 39-93.364s57.121-39 93.364-39c36.242 0 67.363 13 93.363 39s39 57.121 39 93.364v56.727h9.455c7.879 0 14.575 2.758 20.091 8.273 5.514 5.515 8.272 12.212 8.272 20.091z" fill="#999999"/></svg>
|
After Width: | Height: | Size: 760 B |
|
@ -2,6 +2,42 @@
|
|||
@import "common";
|
||||
@import "constants";
|
||||
|
||||
.give-avis {
|
||||
h1 {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
margin-bottom: $default-padding;
|
||||
}
|
||||
|
||||
.lock {
|
||||
margin-right: $default-spacer;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin-bottom: $default-padding;
|
||||
|
||||
.email {
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.introduction {
|
||||
margin-bottom: $default-padding;
|
||||
}
|
||||
|
||||
.confidentiel {
|
||||
color: $grey;
|
||||
font-weight: normal;
|
||||
margin-bottom: 2 * $default-padding;
|
||||
}
|
||||
|
||||
.date {
|
||||
font-size: 12px;
|
||||
color: $grey;
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
|
||||
.ask-avis {
|
||||
h1 {
|
||||
font-size: 18px;
|
||||
|
@ -10,7 +46,7 @@
|
|||
}
|
||||
|
||||
.avis-notice {
|
||||
font-size: 12px;
|
||||
font-size: 14px;
|
||||
color: $grey;
|
||||
margin-bottom: 2 * $default-padding;
|
||||
}
|
||||
|
@ -18,6 +54,23 @@
|
|||
input[type=email] {
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
form > label {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.confidentiel {
|
||||
color: $grey;
|
||||
font-weight: normal;
|
||||
margin-bottom: 2 * $default-padding;
|
||||
}
|
||||
|
||||
.confidentiel-wrapper {
|
||||
label,
|
||||
select {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.list-avis {
|
||||
|
@ -43,12 +96,15 @@
|
|||
border-top: 1px solid $grey;
|
||||
padding: $default-padding 0;
|
||||
|
||||
.lock {
|
||||
margin-right: $default-spacer;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-weight: bold;
|
||||
margin-bottom: $default-spacer;
|
||||
|
||||
span {
|
||||
font-weight: normal;
|
||||
.email {
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,6 +115,18 @@
|
|||
.avis-icon {
|
||||
margin-right: $default-spacer;
|
||||
}
|
||||
|
||||
.confidentiel {
|
||||
color: $grey;
|
||||
font-size: 12px;
|
||||
|
||||
.lock {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
background-size: 12px 12px;
|
||||
vertical-align: sub;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.date,
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
align-items: flex-start;
|
||||
}
|
||||
|
||||
&.align-baseline {
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
&.justify-between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
|
|
@ -52,4 +52,8 @@ i {
|
|||
&.attachment {
|
||||
background-image: image-url("icons/attachment.svg");
|
||||
}
|
||||
|
||||
&.lock {
|
||||
background-image: image-url("icons/lock.svg");
|
||||
}
|
||||
}
|
||||
|
|
72
app/controllers/new_gestionnaire/avis_controller.rb
Normal file
72
app/controllers/new_gestionnaire/avis_controller.rb
Normal file
|
@ -0,0 +1,72 @@
|
|||
module NewGestionnaire
|
||||
class AvisController < ApplicationController
|
||||
layout 'new_application'
|
||||
|
||||
A_DONNER_STATUS = 'a-donner'
|
||||
DONNES_STATUS = 'donnes'
|
||||
|
||||
def index
|
||||
gestionnaire_avis = current_gestionnaire.avis.includes(dossier: [:procedure, :user])
|
||||
@avis_a_donner, @avis_donnes = gestionnaire_avis.partition { |avis| avis.answer.nil? }
|
||||
|
||||
@statut = params[:statut].present? ? params[:statut] : A_DONNER_STATUS
|
||||
|
||||
@avis = case @statut
|
||||
when A_DONNER_STATUS
|
||||
@avis_a_donner
|
||||
when DONNES_STATUS
|
||||
@avis_donnes
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@avis = avis
|
||||
@dossier = avis.dossier
|
||||
end
|
||||
|
||||
def instruction
|
||||
@avis = avis
|
||||
@dossier = avis.dossier
|
||||
end
|
||||
|
||||
def update
|
||||
avis.update_attributes(avis_params)
|
||||
flash.notice = 'Votre réponse est enregistrée.'
|
||||
redirect_to instruction_avis_path(avis)
|
||||
end
|
||||
|
||||
def messagerie
|
||||
@avis = avis
|
||||
@dossier = avis.dossier
|
||||
end
|
||||
|
||||
def create_commentaire
|
||||
Commentaire.create(commentaire_params.merge(email: current_gestionnaire.email, dossier: avis.dossier))
|
||||
redirect_to messagerie_avis_path(avis)
|
||||
end
|
||||
|
||||
def create_avis
|
||||
confidentiel = avis.confidentiel || params[:avis][:confidentiel]
|
||||
Avis.create(create_avis_params.merge(claimant: current_gestionnaire, dossier: avis.dossier, confidentiel: confidentiel))
|
||||
redirect_to instruction_avis_path(avis)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def avis
|
||||
current_gestionnaire.avis.includes(dossier: [:avis, :commentaires]).find(params[:id])
|
||||
end
|
||||
|
||||
def avis_params
|
||||
params.require(:avis).permit(:answer)
|
||||
end
|
||||
|
||||
def commentaire_params
|
||||
params.require(:commentaire).permit(:body)
|
||||
end
|
||||
|
||||
def create_avis_params
|
||||
params.require(:avis).permit(:email, :introduction)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -87,7 +87,7 @@ module NewGestionnaire
|
|||
end
|
||||
|
||||
def avis_params
|
||||
params.require(:avis).permit(:email, :introduction)
|
||||
params.require(:avis).permit(:email, :introduction, :confidentiel)
|
||||
end
|
||||
|
||||
def champs_private_params
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
module NewGestionnaire
|
||||
class ProceduresController < GestionnaireController
|
||||
before_action :ensure_ownership!, except: [:index]
|
||||
before_action :redirect_to_avis_if_needed, only: [:index]
|
||||
|
||||
def index
|
||||
@procedures = current_gestionnaire.procedures.order(archived_at: :desc, published_at: :desc)
|
||||
|
@ -76,5 +77,11 @@ module NewGestionnaire
|
|||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
def redirect_to_avis_if_needed
|
||||
if current_gestionnaire.procedures.count == 0 && current_gestionnaire.avis.count > 0
|
||||
redirect_to avis_index_path
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -348,6 +348,18 @@ class Dossier < ActiveRecord::Base
|
|||
parts.join
|
||||
end
|
||||
|
||||
def avis_for(gestionnaire)
|
||||
if gestionnaire.dossiers.include?(self)
|
||||
avis.order(created_at: :asc)
|
||||
else
|
||||
avis
|
||||
.where(confidentiel: false)
|
||||
.or(avis.where(claimant: gestionnaire))
|
||||
.or(avis.where(gestionnaire: gestionnaire))
|
||||
.order(created_at: :asc)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def build_attestation
|
||||
|
|
|
@ -7,9 +7,14 @@
|
|||
%img{ src: image_url("header/logo-tps.svg") }
|
||||
|
||||
- if gestionnaire_signed_in?
|
||||
- current_url = request.path_info
|
||||
%ul.header-tabs
|
||||
%li
|
||||
= link_to "Procédures", procedures_path, class: "active"
|
||||
- if current_gestionnaire.procedures.count > 0
|
||||
%li
|
||||
= link_to "Procédures", procedures_path, class: (controller_name != 'avis') ? "active" : nil
|
||||
- if current_gestionnaire.avis.count > 0
|
||||
%li
|
||||
= link_to "Avis", avis_index_path, class: (controller_name == 'avis') ? "active" : nil
|
||||
%li
|
||||
= link_to "Ancienne interface", backoffice_dossiers_path
|
||||
|
||||
|
|
30
app/views/new_gestionnaire/avis/_avis_list.html.haml
Normal file
30
app/views/new_gestionnaire/avis/_avis_list.html.haml
Normal file
|
@ -0,0 +1,30 @@
|
|||
- if avis.present?
|
||||
%section.list-avis
|
||||
%h1.title
|
||||
Avis des invités
|
||||
%span.count= avis.count
|
||||
|
||||
%ul
|
||||
- avis.each do |avis|
|
||||
%li.one-avis.flex.align-start
|
||||
.width-100
|
||||
%h2.claimant
|
||||
Demandeur :
|
||||
%span.email= (avis.claimant.email == current_gestionnaire.email) ? 'Vous' : avis.claimant.email
|
||||
- if avis.confidentiel?
|
||||
%span.confidentiel
|
||||
confidentiel
|
||||
%i.lock{ title: "Cet avis n'est pas affiché avec les autres experts consultés" }
|
||||
%span.date Demande d'avis envoyée le #{I18n.l(avis.created_at.localtime, format: '%d/%m/%y')}
|
||||
%p= avis.introduction
|
||||
|
||||
.answer.flex.align-start
|
||||
%i.bubble.avis-icon
|
||||
.width-100
|
||||
%h2.gestionnaire
|
||||
= (avis.gestionnaire.email == current_gestionnaire.email) ? 'Vous' : avis.gestionnaire.email
|
||||
- if avis.answer.present?
|
||||
%span.date Réponse donnée le #{I18n.l(avis.updated_at.localtime, format: '%d/%m/%y')}
|
||||
- else
|
||||
%span.waiting En attente de réponse
|
||||
%p= avis.answer
|
13
app/views/new_gestionnaire/avis/_header.html.haml
Normal file
13
app/views/new_gestionnaire/avis/_header.html.haml
Normal file
|
@ -0,0 +1,13 @@
|
|||
.backoffice-header
|
||||
.container
|
||||
%ul.breadcrumbs
|
||||
%li= link_to('Avis', avis_index_path)
|
||||
%li= "#{dossier.procedure.libelle}, dossier nº #{dossier.id}"
|
||||
|
||||
%ul.tabs
|
||||
%li{ class: current_page?(avis_path(avis)) ? 'active' : nil }
|
||||
= link_to 'Demande', avis_path(avis)
|
||||
%li{ class: current_page?(instruction_avis_path(avis)) ? 'active' : nil }
|
||||
= link_to 'Instruction', instruction_avis_path(avis)
|
||||
%li{ class: current_page?(messagerie_avis_path(avis)) ? 'active' : nil }
|
||||
= link_to 'Messagerie', messagerie_avis_path(avis)
|
35
app/views/new_gestionnaire/avis/index.html.haml
Normal file
35
app/views/new_gestionnaire/avis/index.html.haml
Normal file
|
@ -0,0 +1,35 @@
|
|||
#avis-index
|
||||
.backoffice-header
|
||||
.container.flex
|
||||
.width-100
|
||||
%h1 Avis
|
||||
%ul.tabs
|
||||
%li{ class: (@statut == NewGestionnaire::AvisController::A_DONNER_STATUS) ? 'active' : nil }>
|
||||
= link_to(avis_index_path(statut: NewGestionnaire::AvisController::A_DONNER_STATUS)) do
|
||||
avis à donner
|
||||
%span.badge= @avis_a_donner.count
|
||||
|
||||
%li{ class: (@statut == NewGestionnaire::AvisController::DONNES_STATUS) ? 'active' : nil }>
|
||||
= link_to(avis_index_path(statut: NewGestionnaire::AvisController::DONNES_STATUS)) do
|
||||
avis #{'donné'.pluralize(@avis_donnes.count)}
|
||||
%span.badge= @avis_donnes.count
|
||||
|
||||
.container
|
||||
- if @avis.present?
|
||||
%table.table.dossiers-table.hoverable
|
||||
%thead
|
||||
%tr
|
||||
%th.number-col Nº dossier
|
||||
%th Demandeur
|
||||
%th Procédure
|
||||
%tbody
|
||||
- @avis.each do |avis|
|
||||
%tr
|
||||
%td.number-col
|
||||
= link_to(avis_path(avis), class: 'cell-link') do
|
||||
%i.folder
|
||||
#{avis.dossier.id}
|
||||
%td= link_to(avis.dossier.user.email, avis_path(avis), class: 'cell-link')
|
||||
%td= link_to(avis.dossier.procedure.libelle, avis_path(avis), class: 'cell-link')
|
||||
- else
|
||||
%h2 Aucun avis
|
43
app/views/new_gestionnaire/avis/instruction.html.haml
Normal file
43
app/views/new_gestionnaire/avis/instruction.html.haml
Normal file
|
@ -0,0 +1,43 @@
|
|||
#avis-show
|
||||
= render partial: 'header', locals: { avis: @avis, dossier: @dossier }
|
||||
|
||||
.container
|
||||
%section.give-avis
|
||||
%h1 Donner votre avis
|
||||
%h2.claimant
|
||||
Demandeur :
|
||||
%span.email= @avis.claimant.email
|
||||
%span.date Demande d'avis envoyée le #{I18n.l(@avis.created_at.localtime, format: '%d/%m/%y')}
|
||||
%p.introduction= @avis.introduction
|
||||
|
||||
= form_for @avis, url: avis_path(@avis), html: { class: 'form' } do |f|
|
||||
= f.text_area :answer, rows: 3, placeholder: 'Votre avis', required: true
|
||||
.flex.justify-between.align-baseline
|
||||
%p.confidentiel
|
||||
%i.lock
|
||||
Cet avis est confidentiel et n'est pas affiché aux autres experts consultés
|
||||
.send-wrapper
|
||||
= f.submit 'Envoyer votre avis', class: 'button send'
|
||||
|
||||
%section.ask-avis
|
||||
%h1 Inviter une personne à donner son avis
|
||||
%p.avis-notice L'invité pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais il ne pourra le modifier.
|
||||
|
||||
= form_for Avis.new, url: avis_avis_path(@avis), html: { class: 'form' } do |f|
|
||||
= f.email_field :email, placeholder: 'Adresse email', required: true
|
||||
= f.text_area :introduction, rows: 3, value: 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true
|
||||
.flex.justify-between.align-baseline
|
||||
- if @avis.confidentiel?
|
||||
%p.confidentiel
|
||||
%i.lock
|
||||
Cet avis est confidentiel et n'est pas affiché aux autres experts consultés
|
||||
.send-wrapper
|
||||
= f.submit 'Demander un avis', class: 'button send'
|
||||
- else
|
||||
.confidentiel-wrapper
|
||||
= f.label :confidentiel, 'Cet avis est'
|
||||
= f.select :confidentiel, [['partagé avec les autres experts', false], ['confidentiel', true]]
|
||||
.send-wrapper
|
||||
= f.submit 'Demander un avis', class: 'button send'
|
||||
|
||||
= render partial: 'avis_list', locals: { avis: @dossier.avis_for(current_gestionnaire) }
|
21
app/views/new_gestionnaire/avis/messagerie.html.haml
Normal file
21
app/views/new_gestionnaire/avis/messagerie.html.haml
Normal file
|
@ -0,0 +1,21 @@
|
|||
= render partial: 'header', locals: { avis: @avis, dossier: @dossier }
|
||||
|
||||
.messagerie.container
|
||||
%ul
|
||||
- @dossier.commentaires.ordered.each do |commentaire|
|
||||
%li
|
||||
= render partial: 'new_gestionnaire/dossiers/commentaire_icon', locals: { commentaire: commentaire, current_gestionnaire: current_gestionnaire }
|
||||
|
||||
.width-100
|
||||
%h2
|
||||
%span.mail
|
||||
= render partial: 'new_gestionnaire/dossiers/commentaire_issuer', locals: { commentaire: commentaire, current_gestionnaire: current_gestionnaire }
|
||||
- if ![current_gestionnaire.email, @dossier.user.email, 'contact@tps.apientreprise.fr'].include?(commentaire.email)
|
||||
%span.guest Invité
|
||||
%span.date= I18n.l(commentaire.created_at.localtime, format: '%H:%M le %d/%m/%Y')
|
||||
%p= sanitize(commentaire.body)
|
||||
|
||||
= form_for(Commentaire.new, url: commentaire_avis_path(@avis), html: { class: 'form' }) do |f|
|
||||
= f.text_area :body, rows: 5, placeholder: 'Répondre ici', required: true
|
||||
.send-wrapper
|
||||
= f.submit 'Envoyer', class: 'button send'
|
47
app/views/new_gestionnaire/avis/show.html.haml
Normal file
47
app/views/new_gestionnaire/avis/show.html.haml
Normal file
|
@ -0,0 +1,47 @@
|
|||
#avis-show
|
||||
= render partial: 'header', locals: { avis: @avis, dossier: @dossier }
|
||||
|
||||
.container
|
||||
.card
|
||||
.card-title Identité du demandeur
|
||||
- if @dossier.entreprise.present?
|
||||
= render partial: 'new_gestionnaire/dossiers/identite_entreprise', locals: { entreprise: @dossier.entreprise }
|
||||
|
||||
- if @dossier.individual.present?
|
||||
= render partial: 'new_gestionnaire/dossiers/identite_individual', locals: { individual: @dossier.individual }
|
||||
|
||||
.backoffice-title Formulaire
|
||||
|
||||
- champs = @dossier.ordered_champs.decorate
|
||||
- if champs.any?
|
||||
.card.featured
|
||||
= render partial: 'new_gestionnaire/dossiers/champs', locals: { champs: champs }
|
||||
|
||||
- if @dossier.procedure.use_api_carto
|
||||
= render partial: 'new_gestionnaire/dossiers/map', locals: { dossier: @dossier }
|
||||
|
||||
- if @dossier.procedure.cerfa_flag? || @dossier.types_de_piece_justificative.any?
|
||||
.card.featured
|
||||
.card-title Pièces jointes
|
||||
|
||||
%table.table.vertical
|
||||
%tbody
|
||||
- if @dossier.procedure.cerfa_flag?
|
||||
%tr
|
||||
%th Formulaire :
|
||||
%td
|
||||
- if @dossier.cerfa_available?
|
||||
= link_to 'Télécharger', @dossier.cerfa.last.content_url, class: 'button', target: :blank
|
||||
- else
|
||||
Pièce non fournie
|
||||
|
||||
- @dossier.procedure.types_de_piece_justificative.each do |type_de_piece_justificative|
|
||||
%tr
|
||||
%th= "#{type_de_piece_justificative.libelle} :"
|
||||
%td
|
||||
- pj = @dossier.retrieve_last_piece_justificative_by_type(type_de_piece_justificative.id)
|
||||
- if pj.present?
|
||||
Pièce fournie -
|
||||
= link_to "Consulter", pj.content_url, class: "link", target: :blank
|
||||
- else
|
||||
Pièce non fournie
|
|
@ -3,38 +3,19 @@
|
|||
#dossier-instruction.container
|
||||
%section.ask-avis
|
||||
%h1 Inviter une personne à donner son avis
|
||||
%p.avis-notice Elle pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais elle ne pourra le modifier.
|
||||
%p.avis-notice L'invité pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais il ne pourra le modifier.
|
||||
|
||||
= form_for Avis.new, url: avis_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' } do |f|
|
||||
= f.email_field :email, placeholder: 'Adresse email', required: true
|
||||
= f.text_area :introduction, rows: 3, value: 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true
|
||||
.send-wrapper
|
||||
= f.submit 'Demander un avis', class: 'button send'
|
||||
.flex.justify-between.align-baseline
|
||||
.confidentiel-wrapper
|
||||
= f.label :confidentiel, 'Cet avis est'
|
||||
= f.select :confidentiel, [['partagé avec les autres experts', false], ['confidentiel', true]]
|
||||
.send-wrapper
|
||||
= f.submit 'Demander un avis', class: 'button send'
|
||||
|
||||
- if @dossier.avis.present?
|
||||
%section.list-avis
|
||||
%h1.title
|
||||
Avis des invités
|
||||
%span.count= @dossier.avis.count
|
||||
|
||||
%ul
|
||||
- @dossier.avis.each do |avis|
|
||||
%li.one-avis
|
||||
%h2.claimant
|
||||
= (avis.claimant.email == current_gestionnaire.email) ? 'Vous' : avis.claimant.email
|
||||
%span.date Demande d'avis envoyée le #{I18n.l(avis.created_at.localtime, format: '%d/%m/%y')}
|
||||
%p= avis.introduction
|
||||
|
||||
.answer.flex.align-start
|
||||
%i.bubble.avis-icon
|
||||
.width-100
|
||||
%h2.gestionnaire
|
||||
= avis.gestionnaire.email
|
||||
- if avis.answer.present?
|
||||
%span.date Réponse donnée le #{I18n.l(avis.updated_at.localtime, format: '%d/%m/%y')}
|
||||
- else
|
||||
%span.waiting En attente de réponse
|
||||
%p= avis.answer
|
||||
= render partial: 'new_gestionnaire/avis/avis_list', locals: { avis: @dossier.avis }
|
||||
|
||||
- if @dossier.ordered_champs_private.present?
|
||||
%section
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
%i.in-progress
|
||||
%i.bubble
|
||||
%i.attachment
|
||||
%i.lock
|
||||
|
||||
%h1 Formulaires
|
||||
|
||||
|
@ -161,7 +162,7 @@
|
|||
.container
|
||||
%section.ask-avis
|
||||
%h1 Inviter une personne à donner son avis
|
||||
%p.avis-notice Elle pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais elle ne pourra le modifier.
|
||||
%p.avis-notice L'invité pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais il ne pourra le modifier.
|
||||
|
||||
= form_for Avis.new, url: '/', html: { class: 'form' } do |f|
|
||||
= f.email_field :email, placeholder: 'Adresse email', required: true
|
||||
|
|
|
@ -258,6 +258,14 @@ Rails.application.routes.draw do
|
|||
end
|
||||
end
|
||||
end
|
||||
resources :avis, only: [:index, :show, :update] do
|
||||
member do
|
||||
get 'instruction'
|
||||
get 'messagerie'
|
||||
post 'commentaire' => 'avis#create_commentaire'
|
||||
post 'avis' => 'avis#create_avis'
|
||||
end
|
||||
end
|
||||
get "recherche" => "recherches#index"
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddConfidentielFieldToAvis < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :avis, :confidentiel, :boolean, default: false, null: false
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20170801083632) do
|
||||
ActiveRecord::Schema.define(version: 20170908101023) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -99,9 +99,10 @@ ActiveRecord::Schema.define(version: 20170801083632) do
|
|||
t.text "answer"
|
||||
t.integer "gestionnaire_id"
|
||||
t.integer "dossier_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "claimant_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "claimant_id", null: false
|
||||
t.boolean "confidentiel", default: false, null: false
|
||||
t.index ["claimant_id"], name: "index_avis_on_claimant_id", using: :btree
|
||||
t.index ["dossier_id"], name: "index_avis_on_dossier_id", using: :btree
|
||||
t.index ["gestionnaire_id"], name: "index_avis_on_gestionnaire_id", using: :btree
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
namespace :'2017_09_19_set_confidentialite_to_old_avis' do
|
||||
task set: :environment do
|
||||
Avis.unscoped.update_all(confidentiel: true)
|
||||
end
|
||||
end
|
115
spec/controllers/new_gestionnaire/avis_controller_spec.rb
Normal file
115
spec/controllers/new_gestionnaire/avis_controller_spec.rb
Normal file
|
@ -0,0 +1,115 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe NewGestionnaire::AvisController, type: :controller do
|
||||
render_views
|
||||
|
||||
let(:claimant) { create(:gestionnaire) }
|
||||
let(:gestionnaire) { create(:gestionnaire) }
|
||||
let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
|
||||
let(:dossier) { create(:dossier, :replied, procedure: procedure) }
|
||||
let!(:avis_without_answer) { Avis.create(dossier: dossier, claimant: claimant, gestionnaire: gestionnaire) }
|
||||
let!(:avis_with_answer) { Avis.create(dossier: dossier, claimant: claimant, gestionnaire: gestionnaire, answer: 'yop') }
|
||||
|
||||
before { sign_in(gestionnaire) }
|
||||
|
||||
describe '#index' do
|
||||
before { get :index }
|
||||
|
||||
it { expect(response).to have_http_status(:success) }
|
||||
it { expect(assigns(:avis_a_donner)).to match([avis_without_answer]) }
|
||||
it { expect(assigns(:avis_donnes)).to match([avis_with_answer]) }
|
||||
it { expect(assigns(:statut)).to eq('a-donner') }
|
||||
|
||||
context 'with a statut equal to donnes' do
|
||||
before { get :index, statut: 'donnes' }
|
||||
|
||||
it { expect(assigns(:statut)).to eq('donnes') }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#show' do
|
||||
before { get :show, { id: avis_without_answer.id } }
|
||||
|
||||
it { expect(response).to have_http_status(:success) }
|
||||
it { expect(assigns(:avis)).to eq(avis_without_answer) }
|
||||
it { expect(assigns(:dossier)).to eq(dossier) }
|
||||
end
|
||||
|
||||
describe '#instruction' do
|
||||
before { get :instruction, { id: avis_without_answer.id } }
|
||||
|
||||
it { expect(response).to have_http_status(:success) }
|
||||
it { expect(assigns(:avis)).to eq(avis_without_answer) }
|
||||
it { expect(assigns(:dossier)).to eq(dossier) }
|
||||
end
|
||||
|
||||
describe '#messagerie' do
|
||||
before { get :messagerie, { id: avis_without_answer.id } }
|
||||
|
||||
it { expect(response).to have_http_status(:success) }
|
||||
it { expect(assigns(:avis)).to eq(avis_without_answer) }
|
||||
it { expect(assigns(:dossier)).to eq(dossier) }
|
||||
end
|
||||
|
||||
describe '#update' do
|
||||
before do
|
||||
patch :update, { id: avis_without_answer.id, avis: { answer: 'answer' } }
|
||||
avis_without_answer.reload
|
||||
end
|
||||
|
||||
it { expect(response).to redirect_to(instruction_avis_path(avis_without_answer)) }
|
||||
it { expect(avis_without_answer.answer).to eq('answer') }
|
||||
it { expect(flash.notice).to eq('Votre réponse est enregistrée.') }
|
||||
end
|
||||
|
||||
describe '#create_commentaire' do
|
||||
before do
|
||||
post :create_commentaire, { id: avis_without_answer.id, commentaire: { body: 'commentaire body' } }
|
||||
end
|
||||
|
||||
it { expect(response).to redirect_to(messagerie_avis_path(avis_without_answer)) }
|
||||
it { expect(dossier.commentaires.map(&:body)).to match(['commentaire body']) }
|
||||
end
|
||||
|
||||
describe '#create_avis' do
|
||||
let!(:previous_avis) { Avis.create(dossier: dossier, claimant: claimant, gestionnaire: gestionnaire, confidentiel: previous_avis_confidentiel) }
|
||||
let(:email) { 'a@b.com' }
|
||||
let(:intro) { 'introduction' }
|
||||
let(:created_avis) { Avis.last }
|
||||
|
||||
before do
|
||||
post :create_avis, { id: previous_avis.id, avis: { email: email, introduction: intro, confidentiel: asked_confidentiel } }
|
||||
end
|
||||
|
||||
context 'when the previous avis is public' do
|
||||
let(:previous_avis_confidentiel) { false }
|
||||
|
||||
context 'when the user asked for a public avis' do
|
||||
let(:asked_confidentiel) { false }
|
||||
|
||||
it { expect(created_avis.confidentiel).to be(false) }
|
||||
it { expect(created_avis.email).to eq(email) }
|
||||
it { expect(created_avis.introduction).to eq(intro) }
|
||||
it { expect(created_avis.dossier).to eq(previous_avis.dossier) }
|
||||
it { expect(created_avis.claimant).to eq(gestionnaire) }
|
||||
it { expect(response).to redirect_to(instruction_avis_path(previous_avis)) }
|
||||
end
|
||||
|
||||
context 'when the user asked for a confidentiel avis' do
|
||||
let(:asked_confidentiel) { true }
|
||||
|
||||
it { expect(created_avis.confidentiel).to be(true) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the preivous avis is confidentiel' do
|
||||
let(:previous_avis_confidentiel) { true }
|
||||
|
||||
context 'when the user asked for a public avis' do
|
||||
let(:asked_confidentiel) { false }
|
||||
|
||||
it { expect(created_avis.confidentiel).to be(true) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,8 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe NewGestionnaire::DossiersController, type: :controller do
|
||||
render_views
|
||||
|
||||
let(:gestionnaire) { create(:gestionnaire) }
|
||||
let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
|
||||
let(:dossier) { create(:dossier, :replied, procedure: procedure) }
|
||||
|
@ -122,12 +124,13 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
post :create_avis, params: {
|
||||
procedure_id: procedure.id,
|
||||
dossier_id: dossier.id,
|
||||
avis: { email: 'email@a.com', introduction: 'intro' }
|
||||
avis: { email: 'email@a.com', introduction: 'intro', confidentiel: true }
|
||||
}
|
||||
end
|
||||
|
||||
it { expect(saved_avis.email).to eq('email@a.com') }
|
||||
it { expect(saved_avis.introduction).to eq('intro') }
|
||||
it { expect(saved_avis.confidentiel).to eq(true) }
|
||||
it { expect(saved_avis.dossier).to eq(dossier) }
|
||||
it { expect(saved_avis.claimant).to eq(gestionnaire) }
|
||||
it { expect(response).to redirect_to(instruction_dossier_path(dossier.procedure, dossier)) }
|
||||
|
|
|
@ -42,6 +42,47 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe "before_action: redirect_to_avis_if_needed" do
|
||||
it "is present" do
|
||||
before_actions = NewGestionnaire::ProceduresController
|
||||
._process_action_callbacks
|
||||
.find_all{|process_action_callbacks| process_action_callbacks.kind == :before}
|
||||
.map(&:filter)
|
||||
|
||||
expect(before_actions).to include(:redirect_to_avis_if_needed)
|
||||
end
|
||||
end
|
||||
|
||||
describe "redirect_to_avis_if_needed" do
|
||||
let(:gestionnaire) { create(:gestionnaire) }
|
||||
|
||||
before do
|
||||
expect(@controller).to receive(:current_gestionnaire).at_least(:once).and_return(gestionnaire)
|
||||
allow(@controller).to receive(:redirect_to)
|
||||
end
|
||||
|
||||
context "when a gestionnaire has some procedures" do
|
||||
let!(:some_procedure) { create(:procedure, gestionnaires: [gestionnaire]) }
|
||||
|
||||
before { @controller.send(:redirect_to_avis_if_needed) }
|
||||
|
||||
it "does not redirects nor flash" do
|
||||
expect(@controller).not_to have_received(:redirect_to)
|
||||
end
|
||||
end
|
||||
|
||||
context "when a gestionnaire has no procedure and some avis" do
|
||||
before do
|
||||
Avis.create!(dossier: create(:dossier), claimant: create(:gestionnaire), gestionnaire: gestionnaire)
|
||||
@controller.send(:redirect_to_avis_if_needed)
|
||||
end
|
||||
|
||||
it "redirects avis" do
|
||||
expect(@controller).to have_received(:redirect_to).with(avis_index_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#index" do
|
||||
let(:gestionnaire) { create(:gestionnaire) }
|
||||
subject { get :index }
|
||||
|
|
|
@ -695,6 +695,56 @@ describe Dossier do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#avis_for' do
|
||||
let!(:procedure) { create(:procedure, :published) }
|
||||
let!(:dossier) { create(:dossier, procedure: procedure, state: :initiated) }
|
||||
|
||||
let!(:gestionnaire) { create(:gestionnaire, procedures: [procedure]) }
|
||||
let!(:expert_1) { create(:gestionnaire) }
|
||||
let!(:expert_2) { create(:gestionnaire) }
|
||||
|
||||
context 'when there is a public advice asked from the dossiers gestionnaire' do
|
||||
let!(:avis) { Avis.create(dossier: dossier, claimant: gestionnaire, gestionnaire: expert_1, confidentiel: false) }
|
||||
|
||||
it { expect(dossier.avis_for(gestionnaire)).to match([avis]) }
|
||||
it { expect(dossier.avis_for(expert_1)).to match([avis]) }
|
||||
it { expect(dossier.avis_for(expert_2)).to match([avis]) }
|
||||
end
|
||||
|
||||
context 'when there is a private advice asked from the dossiers gestionnaire' do
|
||||
let!(:avis) { Avis.create(dossier: dossier, claimant: gestionnaire, gestionnaire: expert_1, confidentiel: true) }
|
||||
|
||||
it { expect(dossier.avis_for(gestionnaire)).to match([avis]) }
|
||||
it { expect(dossier.avis_for(expert_1)).to match([avis]) }
|
||||
it { expect(dossier.avis_for(expert_2)).to match([]) }
|
||||
end
|
||||
|
||||
context 'when there is a public advice asked from one expert to another' do
|
||||
let!(:avis) { Avis.create(dossier: dossier, claimant: expert_1, gestionnaire: expert_2, confidentiel: false) }
|
||||
|
||||
it { expect(dossier.avis_for(gestionnaire)).to match([avis]) }
|
||||
it { expect(dossier.avis_for(expert_1)).to match([avis]) }
|
||||
it { expect(dossier.avis_for(expert_2)).to match([avis]) }
|
||||
end
|
||||
|
||||
context 'when there is a private advice asked from one expert to another' do
|
||||
let!(:avis) { Avis.create(dossier: dossier, claimant: expert_1, gestionnaire: expert_2, confidentiel: true) }
|
||||
|
||||
it { expect(dossier.avis_for(gestionnaire)).to match([avis]) }
|
||||
it { expect(dossier.avis_for(expert_1)).to match([avis]) }
|
||||
it { expect(dossier.avis_for(expert_2)).to match([avis]) }
|
||||
end
|
||||
|
||||
context 'when they are a lot of advice' do
|
||||
let!(:avis_1) { Avis.create(dossier: dossier, claimant: expert_1, gestionnaire: expert_2, confidentiel: false, created_at: DateTime.parse('10/01/2010')) }
|
||||
let!(:avis_2) { Avis.create(dossier: dossier, claimant: expert_1, gestionnaire: expert_2, confidentiel: false, created_at: DateTime.parse('9/01/2010')) }
|
||||
let!(:avis_3) { Avis.create(dossier: dossier, claimant: expert_1, gestionnaire: expert_2, confidentiel: false, created_at: DateTime.parse('11/01/2010')) }
|
||||
|
||||
it { expect(dossier.avis_for(gestionnaire)).to match([avis_2, avis_1, avis_3]) }
|
||||
it { expect(dossier.avis_for(expert_1)).to match([avis_2, avis_1, avis_3]) }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#update_state_dates' do
|
||||
let(:state) { 'draft' }
|
||||
let(:dossier) { create(:dossier, state: state) }
|
||||
|
|
Loading…
Add table
Reference in a new issue