commit
f6d6caf4d7
15 changed files with 249 additions and 76 deletions
|
@ -35,21 +35,6 @@
|
||||||
.card-admin-action {
|
.card-admin-action {
|
||||||
margin-top: auto;
|
margin-top: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-admin-action-btn {
|
|
||||||
width: 90px;
|
|
||||||
height: 36px;
|
|
||||||
border-radius: 30px;
|
|
||||||
border: solid 1px #BBBBBB;
|
|
||||||
background: #FFFFFF;
|
|
||||||
cursor: pointer;
|
|
||||||
padding-left: 10px;
|
|
||||||
padding-right: 10px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#test-procedure-link {
|
|
||||||
margin-right: 10px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media only screen and (max-width: 600px) {
|
@media only screen and (max-width: 600px) {
|
||||||
|
|
21
app/assets/stylesheets/new_design/procedure_admin.scss
Normal file
21
app/assets/stylesheets/new_design/procedure_admin.scss
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
.procedure-grid {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.procedure-admin-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
|
||||||
|
.button {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.procedure-admin-explanation {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 20px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
|
@ -1,5 +0,0 @@
|
||||||
|
|
||||||
.procedure-grid {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
|
@ -3,6 +3,7 @@ module Instructeurs
|
||||||
include CreateAvisConcern
|
include CreateAvisConcern
|
||||||
|
|
||||||
before_action :authenticate_instructeur!, except: [:sign_up, :create_instructeur]
|
before_action :authenticate_instructeur!, except: [:sign_up, :create_instructeur]
|
||||||
|
before_action :check_if_avis_revoked, only: [:show]
|
||||||
before_action :redirect_if_no_sign_up_needed, only: [:sign_up]
|
before_action :redirect_if_no_sign_up_needed, only: [:sign_up]
|
||||||
before_action :check_avis_exists_and_email_belongs_to_avis, only: [:sign_up, :create_instructeur]
|
before_action :check_avis_exists_and_email_belongs_to_avis, only: [:sign_up, :create_instructeur]
|
||||||
before_action :set_avis_and_dossier, only: [:show, :instruction, :messagerie, :create_commentaire, :update]
|
before_action :set_avis_and_dossier, only: [:show, :instruction, :messagerie, :create_commentaire, :update]
|
||||||
|
@ -114,6 +115,14 @@ module Instructeurs
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def revoquer
|
||||||
|
avis = Avis.find(params[:id])
|
||||||
|
if avis.revoke_by!(current_instructeur)
|
||||||
|
flash.notice = "#{avis.email_to_display} ne peut plus donner son avis sur ce dossier."
|
||||||
|
redirect_back(fallback_location: avis_instructeur_dossier_path(avis.procedure, avis.dossier))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_avis_and_dossier
|
def set_avis_and_dossier
|
||||||
|
@ -135,6 +144,14 @@ module Instructeurs
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_if_avis_revoked
|
||||||
|
avis = Avis.find(params[:id])
|
||||||
|
if avis.revoked?
|
||||||
|
flash.alert = "Vous n'avez plus accès à ce dossier."
|
||||||
|
redirect_to url_for(root_path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def check_avis_exists_and_email_belongs_to_avis
|
def check_avis_exists_and_email_belongs_to_avis
|
||||||
if !Avis.avis_exists_and_email_belongs_to_avis?(params[:id], params[:email])
|
if !Avis.avis_exists_and_email_belongs_to_avis?(params[:id], params[:email])
|
||||||
redirect_to url_for(root_path)
|
redirect_to url_for(root_path)
|
||||||
|
|
|
@ -30,15 +30,23 @@ class RootController < ApplicationController
|
||||||
.each { |champ| champ.type_de_champ.libelle = 'Un super titre de section' }
|
.each { |champ| champ.type_de_champ.libelle = 'Un super titre de section' }
|
||||||
|
|
||||||
all_champs
|
all_champs
|
||||||
.filter { |champ| [TypeDeChamp.type_champs.fetch(:drop_down_list), TypeDeChamp.type_champs.fetch(:multiple_drop_down_list)].include?(champ.type_champ) }
|
.filter { |champ| champ.type_de_champ.drop_down_list? }
|
||||||
.each do |champ|
|
.each do |champ|
|
||||||
champ.type_de_champ.drop_down_list = DropDownList.new(type_de_champ: champ.type_de_champ)
|
if champ.type_de_champ.linked_drop_down_list?
|
||||||
champ.drop_down_list.value =
|
champ.type_de_champ.drop_down_list_value =
|
||||||
"option A
|
"-- section 1 --
|
||||||
option B
|
option A
|
||||||
-- avant l'option C --
|
option B
|
||||||
option C"
|
-- section 2 --
|
||||||
champ.value = '["option B", "option C"]'
|
option C"
|
||||||
|
else
|
||||||
|
champ.type_de_champ.drop_down_list_value =
|
||||||
|
"option A
|
||||||
|
option B
|
||||||
|
-- avant l'option C --
|
||||||
|
option C"
|
||||||
|
champ.value = '["option B", "option C"]'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
all_champs
|
all_champs
|
||||||
|
|
|
@ -15,14 +15,22 @@ class ActiveStorage::DownloadableFile
|
||||||
pjs = PiecesJustificativesService.liste_pieces_justificatives(dossier)
|
pjs = PiecesJustificativesService.liste_pieces_justificatives(dossier)
|
||||||
pjs.map do |piece_justificative|
|
pjs.map do |piece_justificative|
|
||||||
[
|
[
|
||||||
ActiveStorage::DownloadableFile.new(piece_justificative),
|
piece_justificative,
|
||||||
piece_justificative.filename.to_s
|
self.timestamped_filename(piece_justificative)
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def self.timestamped_filename(piece_justificative)
|
||||||
|
extension = File.extname(piece_justificative.filename.to_s)
|
||||||
|
basename = File.basename(piece_justificative.filename.to_s, extension)
|
||||||
|
timestamp = piece_justificative.created_at.strftime("%d-%m-%Y-%H-%S")
|
||||||
|
|
||||||
|
"#{basename}-#{timestamp}#{extension}"
|
||||||
|
end
|
||||||
|
|
||||||
def using_local_backend?
|
def using_local_backend?
|
||||||
[:local, :local_test, :test].include?(Rails.application.config.active_storage.service)
|
[:local, :local_test, :test].include?(Rails.application.config.active_storage.service)
|
||||||
end
|
end
|
||||||
|
|
|
@ -56,6 +56,24 @@ class Avis < ApplicationRecord
|
||||||
dossier.procedure
|
dossier.procedure
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def revoked?
|
||||||
|
revoked_at.present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def revokable_by?(revocator)
|
||||||
|
revocator.dossiers.include?(dossier) || revocator == claimant
|
||||||
|
end
|
||||||
|
|
||||||
|
def revoke_by!(revocator)
|
||||||
|
return false if !revokable_by?(revocator)
|
||||||
|
|
||||||
|
if answer.present?
|
||||||
|
update!(revoked_at: Time.zone.now)
|
||||||
|
else
|
||||||
|
destroy!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def try_to_assign_instructeur
|
def try_to_assign_instructeur
|
||||||
|
|
|
@ -24,10 +24,19 @@
|
||||||
%h2.instructeur
|
%h2.instructeur
|
||||||
= (avis.email_to_display == current_instructeur.email) ? 'Vous' : avis.email_to_display
|
= (avis.email_to_display == current_instructeur.email) ? 'Vous' : avis.email_to_display
|
||||||
- if avis.answer.present?
|
- if avis.answer.present?
|
||||||
|
- if avis.revoked?
|
||||||
|
%span.waiting{ class: highlight_if_unseen_class(avis_seen_at, avis.revoked_at) }
|
||||||
|
Demande d'avis révoquée le #{l(avis.revoked_at, format: '%d/%m/%y à %H:%M')}
|
||||||
|
- else
|
||||||
|
- if avis.revokable_by?(current_instructeur)
|
||||||
|
%span.waiting= link_to("Révoquer l'avis", revoquer_instructeur_avis_path(avis.procedure, avis), data: { confirm: "Souhaitez-vous révoquer la demande d'avis à #{avis.email_to_display} ?" }, method: :patch)
|
||||||
%span.date{ class: highlight_if_unseen_class(avis_seen_at, avis.updated_at) }
|
%span.date{ class: highlight_if_unseen_class(avis_seen_at, avis.updated_at) }
|
||||||
Réponse donnée le #{l(avis.updated_at, format: '%d/%m/%y à %H:%M')}
|
Réponse donnée le #{l(avis.updated_at, format: '%d/%m/%y à %H:%M')}
|
||||||
- else
|
- else
|
||||||
%span.waiting En attente de réponse
|
%span.waiting
|
||||||
|
En attente de réponse
|
||||||
|
- if avis.revokable_by?(current_instructeur)
|
||||||
|
= link_to("Révoquer l'avis", revoquer_instructeur_avis_path(avis.procedure, avis), data: { confirm: "Souhaitez-vous révoquer la demande d'avis à #{avis.email_to_display} ?" }, method: :patch)
|
||||||
- if avis.piece_justificative_file.attached?
|
- if avis.piece_justificative_file.attached?
|
||||||
= render partial: 'shared/attachment/show', locals: { attachment: avis.piece_justificative_file.attachment }
|
= render partial: 'shared/attachment/show', locals: { attachment: avis.piece_justificative_file.attachment }
|
||||||
.answer-body
|
.answer-body
|
||||||
|
|
|
@ -29,10 +29,10 @@
|
||||||
%ul.header-tabs
|
%ul.header-tabs
|
||||||
- if current_instructeur.procedures.count > 0
|
- if current_instructeur.procedures.count > 0
|
||||||
%li
|
%li
|
||||||
= active_link_to "Démarches", instructeur_procedures_path, active: /^((?!avis).)*$/, class: 'tab-link'
|
= active_link_to "Démarches", instructeur_procedures_path, active: controller_name == 'dossiers', class: 'tab-link'
|
||||||
- if current_instructeur.avis.count > 0
|
- if current_instructeur.avis.count > 0
|
||||||
%li
|
%li
|
||||||
= active_link_to instructeur_all_avis_path, active: /avis/, class: 'tab-link' do
|
= active_link_to instructeur_all_avis_path, active: controller_name == 'avis', class: 'tab-link' do
|
||||||
Avis
|
Avis
|
||||||
- avis_counter = current_instructeur.avis.without_answer.count
|
- avis_counter = current_instructeur.avis.without_answer.count
|
||||||
- if avis_counter > 0
|
- if avis_counter > 0
|
||||||
|
|
|
@ -1,14 +1,27 @@
|
||||||
= render partial: 'new_administrateur/breadcrumbs',
|
= render partial: 'new_administrateur/breadcrumbs',
|
||||||
locals: { steps: [link_to('Démarches', admin_procedures_path),
|
locals: { steps: [link_to('Démarches', admin_procedures_path),
|
||||||
"#{@procedure.libelle} (crée le #{@procedure.created_at.strftime('%d/%m/%Y')})"] }
|
"#{@procedure.libelle} (crée le #{@procedure.created_at.strftime('%d/%m/%Y')})", "#{@procedure.locked? ? "Publiée" : "Brouillon" }"] }
|
||||||
|
|
||||||
|
.container.procedure-admin-container
|
||||||
|
= link_to apercu_admin_procedure_path(@procedure), class: 'button' do
|
||||||
|
%span.icon.preview
|
||||||
|
Prévisualiser
|
||||||
|
|
||||||
.container{ style: "display: flex; justify-content: flex-end; margin-bottom: 20px" }
|
|
||||||
- if @procedure.brouillon?
|
- if @procedure.brouillon?
|
||||||
= link_to "Tester la démarche", sanitize_url(@procedure_lien), target: :blank, rel: :noopener, class: 'button primary', id: 'test-procedure-link'
|
= link_to sanitize_url(@procedure_lien), target: :blank, rel: :noopener, class: 'button' do
|
||||||
= button_to 'Publier la démarche', admin_procedure_publication_path(@procedure), method: :get, class: 'button primary', id: 'publish-procedure-link', disabled: @procedure.publiee? ? true : false
|
%span.icon.in-progress
|
||||||
|
Tester
|
||||||
|
|
||||||
|
- if !@procedure.publiee?
|
||||||
|
= link_to 'Publier', admin_procedure_publication_path(@procedure), class: 'button primary', id: 'publish-procedure-link', data: { disable_with: "Publication..." }
|
||||||
|
|
||||||
|
- if @procedure.locked?
|
||||||
|
= link_to admin_procedure_archive_path(procedure_id: @procedure.id), method: :put, class: 'button', data: { confirm: "Voulez-vous vraiment archiver la démarche ? \nLes dossiers en cours pourront être instruits, mais aucun nouveau dossier ne pourra plus être déposé.", disable_with: "Archivage..."} do
|
||||||
|
%span.icon.archive
|
||||||
|
Archiver
|
||||||
|
|
||||||
.container
|
.container
|
||||||
%h2.explication-libelle{ style: "font-weight: bold; font-size: 20px; margin-bottom: 20px;" } Indispensable avant publication
|
%h2.procedure-admin-explanation Indispensable avant publication
|
||||||
.procedure-grid
|
.procedure-grid
|
||||||
.card-admin
|
.card-admin
|
||||||
%div
|
%div
|
||||||
|
@ -18,7 +31,7 @@
|
||||||
%p.card-admin-title Présentation
|
%p.card-admin-title Présentation
|
||||||
%p.card-admin-subtitle Logo, nom, description
|
%p.card-admin-subtitle Logo, nom, description
|
||||||
.card-admin-action
|
.card-admin-action
|
||||||
= button_to 'Modifier', edit_admin_procedure_path(@procedure), method: :get, class: 'card-admin-action-btn', id: "presentation"
|
= link_to 'Modifier', edit_admin_procedure_path(@procedure), class: 'button', id: "presentation"
|
||||||
|
|
||||||
- if !@procedure.locked?
|
- if !@procedure.locked?
|
||||||
.card-admin
|
.card-admin
|
||||||
|
@ -29,7 +42,7 @@
|
||||||
%p.card-admin-title Formulaire
|
%p.card-admin-title Formulaire
|
||||||
%p.card-admin-subtitle Champs à remplir par les usagers
|
%p.card-admin-subtitle Champs à remplir par les usagers
|
||||||
.card-admin-action
|
.card-admin-action
|
||||||
= button_to 'Modifier', champs_admin_procedure_path(@procedure), method: :get, class: 'card-admin-action-btn'
|
= link_to 'Modifier', champs_admin_procedure_path(@procedure), class: 'button'
|
||||||
|
|
||||||
.card-admin
|
.card-admin
|
||||||
- if @procedure.service_id.present?
|
- if @procedure.service_id.present?
|
||||||
|
@ -42,9 +55,16 @@
|
||||||
%p.card-admin-status-todo À faire
|
%p.card-admin-status-todo À faire
|
||||||
%div
|
%div
|
||||||
%p.card-admin-title Service
|
%p.card-admin-title Service
|
||||||
%p.card-admin-subtitle Choix du service de la démarche
|
%p.card-admin-subtitle
|
||||||
|
- if @procedure.service_id.present?
|
||||||
|
= @procedure.service.nom
|
||||||
|
- else
|
||||||
|
Choix du service administratif
|
||||||
.card-admin-action
|
.card-admin-action
|
||||||
= button_to 'Modifier', new_admin_service_path, params: { procedure_id: @procedure.id }, method: :get, class: 'card-admin-action-btn'
|
- if @procedure.service_id.present?
|
||||||
|
= link_to 'Modifier', edit_admin_service_path(@procedure.service, procedure_id: @procedure.id), class: 'button'
|
||||||
|
- else
|
||||||
|
= link_to 'Remplir', new_admin_service_path(procedure_id: @procedure.id), class: 'button'
|
||||||
|
|
||||||
.card-admin
|
.card-admin
|
||||||
%div
|
%div
|
||||||
|
@ -52,15 +72,19 @@
|
||||||
%p.card-admin-status-accept Validé
|
%p.card-admin-status-accept Validé
|
||||||
%div
|
%div
|
||||||
%p.card-admin-title
|
%p.card-admin-title
|
||||||
Administrateurs
|
%span.badge.baseline= @procedure.administrateurs.count
|
||||||
%span.badge.baseline
|
#{"Administrateur".pluralize(@procedure.administrateurs.count)}
|
||||||
= @procedure.administrateurs.count
|
|
||||||
%p.card-admin-subtitle Gestion de la démarche
|
%p.card-admin-subtitle Gestion de la démarche
|
||||||
.card-admin-action
|
.card-admin-action
|
||||||
= button_to 'Modifier', admin_procedure_administrateurs_path(@procedure), method: :get, class: 'card-admin-action-btn', id: "administrateurs"
|
= link_to 'Modifier', admin_procedure_administrateurs_path(@procedure), class: 'button', id: "administrateurs"
|
||||||
|
|
||||||
.card-admin
|
.card-admin
|
||||||
- if @procedure.instructeurs.count > 1
|
- if feature_enabled?(:administrateur_routage)
|
||||||
|
%div
|
||||||
|
%span.icon.accept
|
||||||
|
%p.card-admin-status-accept Validé
|
||||||
|
- elsif @procedure.instructeurs.count > 1
|
||||||
%div
|
%div
|
||||||
%span.icon.accept
|
%span.icon.accept
|
||||||
%p.card-admin-status-accept Validé
|
%p.card-admin-status-accept Validé
|
||||||
|
@ -70,32 +94,20 @@
|
||||||
%p.card-admin-status-todo À faire
|
%p.card-admin-status-todo À faire
|
||||||
%div
|
%div
|
||||||
%p.card-admin-title
|
%p.card-admin-title
|
||||||
= feature_enabled?(:administrateur_routage) ? "Groupe Instructeurs" : "Instructeurs"
|
|
||||||
- if feature_enabled?(:administrateur_routage)
|
- if feature_enabled?(:administrateur_routage)
|
||||||
%span.badge.baseline
|
%span.badge.baseline= @procedure.groupe_instructeurs.count
|
||||||
= @procedure.groupe_instructeurs.count
|
|
||||||
- else
|
- else
|
||||||
%span.badge.baseline
|
%span.badge.baseline= @procedure.instructeurs.count
|
||||||
= @procedure.instructeurs.count
|
|
||||||
|
= feature_enabled?(:administrateur_routage) ? "Groupe Instructeurs" : "#{"Instructeur".pluralize(@procedure.instructeurs.count)}"
|
||||||
%p.card-admin-subtitle Suivi des dossiers
|
%p.card-admin-subtitle Suivi des dossiers
|
||||||
.card-admin-action
|
.card-admin-action
|
||||||
- if feature_enabled?(:administrateur_routage)
|
- if feature_enabled?(:administrateur_routage)
|
||||||
= button_to 'Modifier', admin_procedure_groupe_instructeurs_path(@procedure), method: :get, class: 'card-admin-action-btn', id: "groupe-instructeurs"
|
= link_to 'Modifier', admin_procedure_groupe_instructeurs_path(@procedure), class: 'button', id: "groupe-instructeurs"
|
||||||
- else
|
- else
|
||||||
= button_to 'Modifier', admin_procedure_groupe_instructeur_path(@procedure, @procedure.defaut_groupe_instructeur), method: :get, class: 'card-admin-action-btn', id: "instructeurs"
|
= link_to 'Modifier', admin_procedure_groupe_instructeur_path(@procedure, @procedure.defaut_groupe_instructeur), class: 'button', id: "instructeurs"
|
||||||
|
|
||||||
.card-admin
|
%h2.procedure-admin-explanation Pour aller plus loin
|
||||||
%div
|
|
||||||
%span.icon.preview
|
|
||||||
%p.card-admin-status-todo À visualiser
|
|
||||||
%div
|
|
||||||
%p.card-admin-title
|
|
||||||
Prévisualisation
|
|
||||||
%p.card-admin-subtitle Apperçu de la démarche
|
|
||||||
.card-admin-action
|
|
||||||
= button_to 'Voir', apercu_admin_procedure_path(@procedure), method: :get, class: 'card-admin-action-btn'
|
|
||||||
|
|
||||||
%h2.explication-libelle{ style: "font-weight: bold; font-size: 20px; margin-bottom: 20px;" } Pour aller plus loin
|
|
||||||
.procedure-grid
|
.procedure-grid
|
||||||
.card-admin
|
.card-admin
|
||||||
- if @procedure.attestation_template.present?
|
- if @procedure.attestation_template.present?
|
||||||
|
@ -110,7 +122,7 @@
|
||||||
%p.card-admin-title Attestation
|
%p.card-admin-title Attestation
|
||||||
%p.card-admin-subtitle Délivrance automatique pour les dossiers acceptés
|
%p.card-admin-subtitle Délivrance automatique pour les dossiers acceptés
|
||||||
.card-admin-action
|
.card-admin-action
|
||||||
= button_to 'Modifier', edit_admin_procedure_attestation_template_path(@procedure), method: :get, class: 'card-admin-action-btn'
|
= link_to 'Modifier', edit_admin_procedure_attestation_template_path(@procedure), class: 'button'
|
||||||
|
|
||||||
.card-admin
|
.card-admin
|
||||||
%div
|
%div
|
||||||
|
@ -120,7 +132,7 @@
|
||||||
%p.card-admin-title Configuration des emails
|
%p.card-admin-title Configuration des emails
|
||||||
%p.card-admin-subtitle Notifications automatiques
|
%p.card-admin-subtitle Notifications automatiques
|
||||||
.card-admin-action
|
.card-admin-action
|
||||||
= button_to 'Modifier', admin_procedure_mail_templates_path(@procedure), method: :get, class: 'card-admin-action-btn'
|
= link_to 'Modifier', admin_procedure_mail_templates_path(@procedure), class: 'button'
|
||||||
|
|
||||||
- if !@procedure.locked?
|
- if !@procedure.locked?
|
||||||
.card-admin
|
.card-admin
|
||||||
|
@ -136,7 +148,7 @@
|
||||||
%p.card-admin-title Annotations privées
|
%p.card-admin-title Annotations privées
|
||||||
%p.card-admin-subtitle Champs à remplir par l’administration
|
%p.card-admin-subtitle Champs à remplir par l’administration
|
||||||
.card-admin-action
|
.card-admin-action
|
||||||
= button_to 'Modifier', annotations_admin_procedure_path(@procedure), method: :get, class: 'card-admin-action-btn'
|
= link_to 'Modifier', annotations_admin_procedure_path(@procedure), class: 'button'
|
||||||
|
|
||||||
.card-admin
|
.card-admin
|
||||||
- if @procedure.api_entreprise_token.present?
|
- if @procedure.api_entreprise_token.present?
|
||||||
|
@ -151,7 +163,7 @@
|
||||||
%p.card-admin-title Jeton
|
%p.card-admin-title Jeton
|
||||||
%p.card-admin-subtitle Configurer le jeton API entreprise
|
%p.card-admin-subtitle Configurer le jeton API entreprise
|
||||||
.card-admin-action
|
.card-admin-action
|
||||||
= button_to 'Modifier', jeton_admin_procedure_path(@procedure), method: :get, class: 'card-admin-action-btn'
|
= link_to 'Modifier', jeton_admin_procedure_path(@procedure), class: 'button'
|
||||||
|
|
||||||
.card-admin
|
.card-admin
|
||||||
- if @procedure.monavis_embed.present?
|
- if @procedure.monavis_embed.present?
|
||||||
|
@ -166,4 +178,4 @@
|
||||||
%p.card-admin-title MonAvis
|
%p.card-admin-title MonAvis
|
||||||
%p.card-admin-subtitle Avis des usagers sur votre démarche
|
%p.card-admin-subtitle Avis des usagers sur votre démarche
|
||||||
.card-admin-action
|
.card-admin-action
|
||||||
= button_to 'Modifier', monavis_admin_procedure_path(@procedure), method: :get, class: 'card-admin-action-btn'
|
= link_to 'Modifier', monavis_admin_procedure_path(@procedure), class: 'button'
|
||||||
|
|
|
@ -318,6 +318,7 @@ Rails.application.routes.draw do
|
||||||
get 'messagerie'
|
get 'messagerie'
|
||||||
post 'commentaire' => 'avis#create_commentaire'
|
post 'commentaire' => 'avis#create_commentaire'
|
||||||
post 'avis' => 'avis#create_avis'
|
post 'avis' => 'avis#create_avis'
|
||||||
|
patch 'revoquer'
|
||||||
get 'bilans_bdf'
|
get 'bilans_bdf'
|
||||||
|
|
||||||
get 'sign_up/email/:email' => 'avis#sign_up', constraints: { email: /.*/ }, as: 'sign_up'
|
get 'sign_up/email/:email' => 'avis#sign_up', constraints: { email: /.*/ }, as: 'sign_up'
|
||||||
|
|
5
db/migrate/20200715143010_add_revoked_at_to_avis.rb
Normal file
5
db/migrate/20200715143010_add_revoked_at_to_avis.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class AddRevokedAtToAvis < ActiveRecord::Migration[6.0]
|
||||||
|
def change
|
||||||
|
add_column :avis, :revoked_at, :datetime
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2020_07_07_082256) do
|
ActiveRecord::Schema.define(version: 2020_07_15_143010) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -141,6 +141,7 @@ ActiveRecord::Schema.define(version: 2020_07_07_082256) do
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.integer "claimant_id", null: false
|
t.integer "claimant_id", null: false
|
||||||
t.boolean "confidentiel", default: false, null: false
|
t.boolean "confidentiel", default: false, null: false
|
||||||
|
t.datetime "revoked_at"
|
||||||
t.index ["claimant_id"], name: "index_avis_on_claimant_id"
|
t.index ["claimant_id"], name: "index_avis_on_claimant_id"
|
||||||
t.index ["dossier_id"], name: "index_avis_on_dossier_id"
|
t.index ["dossier_id"], name: "index_avis_on_dossier_id"
|
||||||
t.index ["instructeur_id"], name: "index_avis_on_instructeur_id"
|
t.index ["instructeur_id"], name: "index_avis_on_instructeur_id"
|
||||||
|
|
|
@ -36,11 +36,24 @@ describe Instructeurs::AvisController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#show' do
|
describe '#show' do
|
||||||
before { get :show, params: { id: avis_without_answer.id, procedure_id: procedure.id } }
|
subject { get :show, params: { id: avis_with_answer.id, procedure_id: procedure.id } }
|
||||||
|
|
||||||
it { expect(response).to have_http_status(:success) }
|
context 'with a valid avis' do
|
||||||
it { expect(assigns(:avis)).to eq(avis_without_answer) }
|
before { subject }
|
||||||
it { expect(assigns(:dossier)).to eq(dossier) }
|
|
||||||
|
it { expect(response).to have_http_status(:success) }
|
||||||
|
it { expect(assigns(:avis)).to eq(avis_with_answer) }
|
||||||
|
it { expect(assigns(:dossier)).to eq(dossier) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with a revoked avis' do
|
||||||
|
it "refuse l'accès au dossier" do
|
||||||
|
avis_with_answer.update!(revoked_at: Time.zone.now)
|
||||||
|
subject
|
||||||
|
expect(flash.alert).to eq("Vous n'avez plus accès à ce dossier.")
|
||||||
|
expect(response).to redirect_to(root_path)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#instruction' do
|
describe '#instruction' do
|
||||||
|
@ -258,6 +271,17 @@ describe Instructeurs::AvisController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#revoker" do
|
||||||
|
let(:avis) { create(:avis, claimant: instructeur) }
|
||||||
|
let(:procedure) { avis.procedure }
|
||||||
|
|
||||||
|
it "revoke the dossier" do
|
||||||
|
patch :revoquer, params: { procedure_id: procedure.id, id: avis.id }
|
||||||
|
|
||||||
|
expect(flash.notice).to eq("#{avis.email} ne peut plus donner son avis sur ce dossier.")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'without a instructeur signed in' do
|
context 'without a instructeur signed in' do
|
||||||
|
|
|
@ -131,4 +131,73 @@ RSpec.describe Avis, type: :model do
|
||||||
it { expect(subject.email).to eq("toto@tps.fr") }
|
it { expect(subject.email).to eq("toto@tps.fr") }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe ".revoke_by!" do
|
||||||
|
let(:claimant) { create(:instructeur) }
|
||||||
|
|
||||||
|
context "when no answer" do
|
||||||
|
let(:avis) { create(:avis, claimant: claimant) }
|
||||||
|
|
||||||
|
it "supprime l'avis" do
|
||||||
|
avis.revoke_by!(claimant)
|
||||||
|
expect(avis).to be_destroyed
|
||||||
|
expect(Avis.count).to eq 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with answer" do
|
||||||
|
let(:avis) { create(:avis, :with_answer, claimant: claimant) }
|
||||||
|
|
||||||
|
it "revoque l'avis" do
|
||||||
|
avis.revoke_by!(claimant)
|
||||||
|
expect(avis).not_to be_destroyed
|
||||||
|
expect(avis).to be_revoked
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "by an instructeur who can't revoke" do
|
||||||
|
let(:avis) { create(:avis, :with_answer, claimant: claimant) }
|
||||||
|
let(:expert) { create(:instructeur) }
|
||||||
|
|
||||||
|
it "doesn't revoke avis and returns false" do
|
||||||
|
result = avis.revoke_by!(expert)
|
||||||
|
expect(result).to be_falsey
|
||||||
|
expect(avis).not_to be_destroyed
|
||||||
|
expect(avis).not_to be_revoked
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "revokable_by?" do
|
||||||
|
let(:instructeur) { create(:instructeur) }
|
||||||
|
let(:instructeurs) { [instructeur] }
|
||||||
|
let(:procedure) { create(:procedure, :published, instructeurs: instructeurs) }
|
||||||
|
let(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
|
||||||
|
let(:claimant_expert) { create(:instructeur) }
|
||||||
|
let(:expert) { create(:instructeur) }
|
||||||
|
let(:another_expert) { create(:instructeur) }
|
||||||
|
|
||||||
|
context "when avis claimed by an expert" do
|
||||||
|
let(:avis) { create(:avis, dossier: dossier, claimant: claimant_expert, instructeur: expert) }
|
||||||
|
let(:another_avis) { create(:avis, dossier: dossier, claimant: instructeur, instructeur: another_expert) }
|
||||||
|
it "is revokable by this expert or any instructeurs of the dossier" do
|
||||||
|
expect(avis.revokable_by?(claimant_expert)).to be_truthy
|
||||||
|
expect(avis.revokable_by?(another_expert)).to be_falsy
|
||||||
|
expect(avis.revokable_by?(instructeur)).to be_truthy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when avis claimed by an instructeur" do
|
||||||
|
let(:avis) { create(:avis, dossier: dossier, claimant: instructeur, instructeur: expert) }
|
||||||
|
let(:another_avis) { create(:avis, dossier: dossier, claimant: expert, instructeur: another_expert) }
|
||||||
|
let(:another_instructeur) { create(:instructeur) }
|
||||||
|
let(:instructeurs) { [instructeur, another_instructeur] }
|
||||||
|
|
||||||
|
it "is revokable by any instructeur of the dossier, not by an expert" do
|
||||||
|
expect(avis.revokable_by?(instructeur)).to be_truthy
|
||||||
|
expect(avis.revokable_by?(another_expert)).to be_falsy
|
||||||
|
expect(avis.revokable_by?(another_instructeur)).to be_truthy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue