remove dossier termine from avis views

This commit is contained in:
Lisa Durand 2023-04-03 17:05:17 +02:00
parent 8945777b56
commit 2f012578eb
4 changed files with 14 additions and 3 deletions

View file

@ -13,7 +13,7 @@ module Experts
DONNES_STATUS = 'donnes' DONNES_STATUS = 'donnes'
def index def index
avis = current_expert.avis.not_revoked.includes(dossier: [groupe_instructeur: :procedure]).not_hidden_by_administration avis = current_expert.avis.not_revoked.not_termine.includes(dossier: [groupe_instructeur: :procedure]).not_hidden_by_administration
@avis_by_procedure = avis.to_a.group_by(&:procedure) @avis_by_procedure = avis.to_a.group_by(&:procedure)
end end
@ -35,7 +35,7 @@ module Experts
redirect_to(expert_all_avis_path, flash: { alert: "Vous navez pas accès à cette démarche." }) and return redirect_to(expert_all_avis_path, flash: { alert: "Vous navez pas accès à cette démarche." }) and return
end end
@avis_a_donner = expert_avis.without_answer @avis_a_donner = expert_avis.not_termine.without_answer
@avis_donnes = expert_avis.with_answer @avis_donnes = expert_avis.with_answer
@statut = params[:statut].presence || A_DONNER_STATUS @statut = params[:statut].presence || A_DONNER_STATUS

View file

@ -59,6 +59,8 @@ class Avis < ApplicationRecord
scope :en_construction_expired, -> { unscope(:joins).where(dossier: Dossier.en_construction_expired) } scope :en_construction_expired, -> { unscope(:joins).where(dossier: Dossier.en_construction_expired) }
scope :not_hidden_by_administration, -> { where(dossiers: { hidden_by_administration_at: nil }) } scope :not_hidden_by_administration, -> { where(dossiers: { hidden_by_administration_at: nil }) }
scope :not_revoked, -> { where(revoked_at: nil) } scope :not_revoked, -> { where(revoked_at: nil) }
scope :not_termine, -> { where.not(dossiers: { state: Dossier::TERMINE }) }
# The form allows subtmitting avis requests to several emails at once, # The form allows subtmitting avis requests to several emails at once,
# hence this virtual attribute. # hence this virtual attribute.
attr_accessor :emails attr_accessor :emails

View file

@ -30,7 +30,7 @@ class Expert < ApplicationRecord
@avis_summary @avis_summary
else else
query = <<~EOF query = <<~EOF
COUNT(*) FILTER (where answer IS NULL AND dossiers.hidden_by_administration_at IS NULL) AS unanswered, COUNT(*) FILTER (where answer IS NULL AND dossiers.hidden_by_administration_at IS NULL AND dossiers.state not in ('accepte', 'refuse', 'sans_suite')) AS unanswered,
COUNT(*) AS total COUNT(*) AS total
EOF EOF
result = avis.select(query)[0] result = avis.select(query)[0]

View file

@ -11,6 +11,8 @@ describe 'Inviting an expert:' do
let(:champ) { dossier.champs_public.first } let(:champ) { dossier.champs_public.first }
let(:avis) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure, confidentiel: true) } let(:avis) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure, confidentiel: true) }
let(:avis_with_question) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure, confidentiel: true, question_label: 'Question ?') } let(:avis_with_question) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure, confidentiel: true, question_label: 'Question ?') }
let(:dossier_accepte) { create(:dossier, :accepte, procedure: procedure) }
let(:avis_on_dossier_accepte) { create(:avis, dossier: dossier_accepte, claimant: instructeur, experts_procedure: experts_procedure, confidentiel: true) }
context 'when I dont already have an account' do context 'when I dont already have an account' do
let(:password) { 'This is an expert password' } let(:password) { 'This is an expert password' }
@ -58,12 +60,16 @@ describe 'Inviting an expert:' do
scenario 'I can give an answer' do scenario 'I can give an answer' do
avis # create avis avis # create avis
avis_on_dossier_accepte # create avis
login_as expert.user, scope: :user login_as expert.user, scope: :user
visit expert_all_avis_path visit expert_all_avis_path
expect(page).to have_text('1 avis à donner') expect(page).to have_text('1 avis à donner')
expect(page).to have_text('0 avis donnés') expect(page).to have_text('0 avis donnés')
expect(page).to have_selector('.badge', text: 1)
expect(page).to have_selector('.notifications')
click_on '1 avis à donner' click_on '1 avis à donner'
click_on avis.dossier.user.email click_on avis.dossier.user.email
within('.tabs') { click_on 'Avis' } within('.tabs') { click_on 'Avis' }
@ -81,6 +87,9 @@ describe 'Inviting an expert:' do
within('.fr-breadcrumb__list') { click_on 'Avis' } within('.fr-breadcrumb__list') { click_on 'Avis' }
expect(page).to have_text('0 avis à donner') expect(page).to have_text('0 avis à donner')
expect(page).to have_text('1 avis donné') expect(page).to have_text('1 avis donné')
expect(page).not_to have_selector('.badge', text: 1)
expect(page).not_to have_selector('.notifications')
end end
scenario 'I can give a yes/no answer to a question' do scenario 'I can give a yes/no answer to a question' do