rename hidden_by_instructeur by hidden_by_administration

This commit is contained in:
Kara Diaby 2021-12-21 12:44:57 +01:00
parent ad4be3c482
commit 1ca553e088
8 changed files with 20 additions and 20 deletions

View file

@ -16,7 +16,7 @@ module Instructeurs
@dossiers_count_per_procedure = dossiers.all_state.group('groupe_instructeurs.procedure_id').reorder(nil).count
@dossiers_a_suivre_count_per_procedure = dossiers.without_followers.en_cours.group('groupe_instructeurs.procedure_id').reorder(nil).count
@dossiers_archived_count_per_procedure = dossiers.archived.group('groupe_instructeurs.procedure_id').count
@dossiers_termines_count_per_procedure = dossiers.termine.not_hidden_by_instructeur.group('groupe_instructeurs.procedure_id').reorder(nil).count
@dossiers_termines_count_per_procedure = dossiers.termine.not_hidden_by_administration.group('groupe_instructeurs.procedure_id').reorder(nil).count
@dossiers_expirant_count_per_procedure = dossiers.termine_or_en_construction_close_to_expiration.group('groupe_instructeurs.procedure_id').count
groupe_ids = current_instructeur.groupe_instructeurs.pluck(:id)
@ -69,7 +69,7 @@ module Instructeurs
@followed_dossiers_id = @followed_dossiers.pluck(:id)
@termines_dossiers = dossiers_visibles.termine.not_hidden_by_instructeur
@termines_dossiers = dossiers_visibles.termine.not_hidden_by_administration
@all_state_dossiers = dossiers_visibles.all_state
@archived_dossiers = dossiers_visibles.archived
@expirant_dossiers = dossiers_visibles.termine_or_en_construction_close_to_expiration

View file

@ -16,7 +16,7 @@
# en_instruction_at :datetime
# groupe_instructeur_updated_at :datetime
# hidden_at :datetime
# hidden_by_instructeur_at :datetime
# hidden_by_administration_at :datetime
# hidden_by_user_at :datetime
# identity_updated_at :datetime
# last_avis_updated_at :datetime
@ -206,9 +206,9 @@ class Dossier < ApplicationRecord
scope :archived, -> { where(archived: true) }
scope :not_archived, -> { where(archived: false) }
scope :hidden_by_instructeur, -> { where.not(hidden_by_instructeur_at: nil) }
scope :hidden_by_administration, -> { where.not(hidden_by_administration_at: nil) }
scope :not_hidden_by_user, -> { where(hidden_by_user_at: nil) }
scope :not_hidden_by_instructeur, -> { where(hidden_by_instructeur_at: nil) }
scope :not_hidden_by_administration, -> { where(hidden_by_administration_at: nil) }
scope :order_by_updated_at, -> (order = :desc) { order(updated_at: order) }
scope :order_by_created_at, -> (order = :asc) { order(depose_at: order, created_at: order, id: order) }
@ -237,7 +237,7 @@ class Dossier < ApplicationRecord
end
scope :downloadable_sorted, -> {
state_not_brouillon
.not_hidden_by_instructeur
.not_hidden_by_administration
.includes(
:user,
:individual,
@ -688,16 +688,16 @@ class Dossier < ApplicationRecord
hidden_by_user_at.present?
end
def hidden_by_instructeur?
hidden_by_instructeur_at.present?
def hidden_by_administration?
hidden_by_administration_at.present?
end
def deleted_by_instructeur_and_user?
termine? && hidden_by_instructeur? && hidden_by_user?
termine? && hidden_by_administration? && hidden_by_user?
end
def can_be_restored_by_manager?
hidden_by_instructeur? || discarded? && !procedure.discarded?
hidden_by_administration? || discarded? && !procedure.discarded?
end
def expose_legacy_carto_api?
@ -798,8 +798,8 @@ class Dossier < ApplicationRecord
def restore(author)
if discarded?
transaction do
if hidden_by_instructeur?
update(hidden_by_instructeur_at: nil)
if hidden_by_administration?
update(hidden_by_administration_at: nil)
elsif undiscard && keep_track_on_deletion?
deleted_dossier&.destroy!
log_dossier_operation(author, :restaurer, self)

View file

@ -29,7 +29,7 @@ class Expert < ApplicationRecord
@avis_summary
else
query = <<~EOF
COUNT(*) FILTER (where answer IS NULL AND dossiers.hidden_by_instructeur_at IS NULL) AS unanswered,
COUNT(*) FILTER (where answer IS NULL AND dossiers.hidden_by_administration_at IS NULL) AS unanswered,
COUNT(*) AS total
EOF
result = avis.select(query)[0]

View file

@ -256,7 +256,7 @@ class Instructeur < ApplicationRecord
ON follows.dossier_id = dossiers.id
AND follows.unfollowed_at IS NULL
WHERE "dossiers"."hidden_at" IS NULL
AND "dossiers"."hidden_by_instructeur_at" IS NULL
AND "dossiers"."hidden_by_administration_at" IS NULL
AND "dossiers"."state" != 'brouillon'
AND "dossiers"."groupe_instructeur_id" in (:groupe_instructeur_ids)
EOF

View file

@ -675,7 +675,7 @@ class Procedure < ApplicationRecord
dossiers.with_discarded.discarded.find_each do |dossier|
dossier.restore(author)
end
dossiers.hidden_by_instructeur.find_each do |dossier|
dossiers.hidden_by_administration.find_each do |dossier|
dossier.restore(author)
end
end

View file

@ -326,7 +326,7 @@ ActiveRecord::Schema.define(version: 2021_12_02_133139) do
t.datetime "hidden_by_user_at"
t.index "to_tsvector('french'::regconfig, (search_terms || private_search_terms))", name: "index_dossiers_on_search_terms_private_search_terms", using: :gin
t.index "to_tsvector('french'::regconfig, search_terms)", name: "index_dossiers_on_search_terms", using: :gin
t.datetime "hidden_by_instructeur_at"
t.datetime "hidden_by_administration_at"
t.index ["archived"], name: "index_dossiers_on_archived"
t.index ["dossier_transfer_id"], name: "index_dossiers_on_dossier_transfer_id"
t.index ["groupe_instructeur_id"], name: "index_dossiers_on_groupe_instructeur_id"

View file

@ -1056,7 +1056,7 @@ describe Users::DossiersController, type: :controller do
end
context 'when the dossier is already deleted by instructeur' do
let!(:dossier) { create(:dossier, :with_individual, state: :accepte, en_construction_at: Time.zone.yesterday.beginning_of_day.utc, user: user, autorisation_donnees: true, hidden_by_instructeur_at: Time.zone.now.beginning_of_day.utc) }
let!(:dossier) { create(:dossier, :with_individual, state: :accepte, en_construction_at: Time.zone.yesterday.beginning_of_day.utc, user: user, autorisation_donnees: true, hidden_by_administration_at: Time.zone.now.beginning_of_day.utc) }
before { subject }
it 'discard the dossier' do

View file

@ -15,15 +15,15 @@ describe 'experts/avis/index.html.haml', type: :view do
context 'when the dossier is deleted by instructeur' do
before do
avis.dossier.update!(state: "accepte", hidden_by_instructeur_at: Time.zone.now.beginning_of_day.utc)
assign(:avis_by_procedure, avis.expert.avis.includes(dossier: [groupe_instructeur: :procedure]).where(dossiers: { hidden_by_instructeur_at: nil }).to_a.group_by(&:procedure))
avis.dossier.update!(state: "accepte", hidden_by_administration_at: Time.zone.now.beginning_of_day.utc)
assign(:avis_by_procedure, avis.expert.avis.includes(dossier: [groupe_instructeur: :procedure]).where(dossiers: { hidden_by_administration_at: nil }).to_a.group_by(&:procedure))
end
it { is_expected.not_to have_text("avis à donner") }
end
context 'when the dossier is not deleted by instructeur' do
before do
assign(:avis_by_procedure, avis.expert.avis.includes(dossier: [groupe_instructeur: :procedure]).where(dossiers: { hidden_by_instructeur_at: nil }).to_a.group_by(&:procedure))
assign(:avis_by_procedure, avis.expert.avis.includes(dossier: [groupe_instructeur: :procedure]).where(dossiers: { hidden_by_administration_at: nil }).to_a.group_by(&:procedure))
end
it { is_expected.to have_text("avis à donner") }
end