Merge pull request #6030 from betagouv/main

2021-03-29-01
This commit is contained in:
Kara Diaby 2021-03-29 11:10:57 +02:00 committed by GitHub
commit 667880db9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 35 deletions

View file

@ -175,8 +175,16 @@ class Dossier < ApplicationRecord
:user,
:individual,
:followers_instructeurs,
:avis,
:traitements,
:groupe_instructeur,
procedure: [
:groupe_instructeurs,
:draft_types_de_champ,
:draft_types_de_champ_private,
:published_types_de_champ,
:published_types_de_champ_private
],
avis: [:claimant, :expert],
etablissement: :champ,
champs: {
type_de_champ: [],
@ -195,8 +203,7 @@ class Dossier < ApplicationRecord
type_de_champ: [],
piece_justificative_file_attachment: :blob
]
},
procedure: :groupe_instructeurs
}
).order(en_construction_at: 'asc')
}
scope :en_cours, -> { not_archived.state_en_construction_ou_instruction }

View file

@ -66,9 +66,6 @@ class Procedure < ApplicationRecord
has_many :draft_types_de_champ, through: :draft_revision, source: :types_de_champ
has_many :draft_types_de_champ_private, through: :draft_revision, source: :types_de_champ_private
has_many :all_types_de_champ, -> { joins(:procedure).where('types_de_champ.revision_id != procedures.draft_revision_id') }, through: :revisions, source: :types_de_champ
has_many :all_types_de_champ_private, -> { joins(:procedure).where('types_de_champ.revision_id != procedures.draft_revision_id') }, through: :revisions, source: :types_de_champ_private
has_many :experts_procedures, dependent: :destroy
has_many :experts, through: :experts_procedures
@ -92,31 +89,11 @@ class Procedure < ApplicationRecord
end
def types_de_champ_for_export
if brouillon?
draft_types_de_champ.reject(&:exclude_from_export?)
else
all_types_de_champ
.uniq
.reject(&:exclude_from_export?)
.filter(&:active_revision?)
.group_by(&:stable_id).values.map do |types_de_champ|
types_de_champ.sort_by(&:created_at).last
end
end
types_de_champ.reject(&:exclude_from_export?)
end
def types_de_champ_private_for_export
if brouillon?
draft_types_de_champ_private
else
all_types_de_champ_private
.uniq
.reject(&:exclude_from_export?)
.filter(&:active_revision?)
.group_by(&:stable_id).values.map do |types_de_champ|
types_de_champ.sort_by(&:created_at).last
end
end
types_de_champ_private.reject(&:exclude_from_export?)
end
has_many :administrateurs_procedures
@ -596,7 +573,7 @@ class Procedure < ApplicationRecord
end
def routee?
groupe_instructeurs.count > 1
groupe_instructeurs.size > 1
end
def defaut_groupe_instructeur_for_new_dossier

View file

@ -206,10 +206,6 @@ class TypeDeChamp < ApplicationRecord
!private?
end
def active_revision?
revisions.include?(procedure.active_revision)
end
def self.type_champ_to_class_name(type_champ)
"TypesDeChamp::#{type_champ.classify}TypeDeChamp"
end

View file

@ -32,9 +32,21 @@
- if current_instructeur.procedures.count > 0
%li
= active_link_to "Démarches", instructeur_procedures_path, active: ['dossiers','procedures'].include?(controller_name), class: 'tab-link'
- if current_instructeur.user.expert && current_expert.avis.count > 0
%li
= active_link_to expert_all_avis_path, active: controller_name == 'avis', class: 'tab-link' do
Avis
- avis_counter = current_expert.avis.without_answer.count
- if avis_counter > 0
%span.badge.warning= avis_counter
- if nav_bar_profile == :expert && expert_signed_in?
- if current_expert.avis.count > 0
%ul.header-tabs
- if current_expert.user.instructeur && current_instructeur.procedures.count > 0
%li
= active_link_to "Démarches", instructeur_procedures_path, active: ['dossiers','procedures'].include?(controller_name), class: 'tab-link'
- if current_expert.avis.count > 0
%li
= active_link_to expert_all_avis_path, active: controller_name == 'avis', class: 'tab-link' do
Avis