Merge branch 'main' into 6624/etq-instructeur-je-souhaite-supprimer-des-messages-envoyes-par-erreur

This commit is contained in:
mfo 2021-11-17 05:41:56 +01:00 committed by GitHub
commit 82b23b92c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 58 additions and 59 deletions

View file

@ -2,14 +2,24 @@ class Champs::PieceJustificativeController < ApplicationController
before_action :authenticate_logged_user! before_action :authenticate_logged_user!
def update def update
@champ = policy_scope(Champ).find(params[:champ_id]) if attach_piece_justificative_or_retry
@champ.piece_justificative_file.attach(params[:blob_signed_id])
if @champ.save
render :show render :show
else else
errors = @champ.errors.full_messages render json: { errors: @champ.errors.full_messages }, status: 422
render :json => { errors: errors }, :status => 422
end end
end end
private
def attach_piece_justificative
@champ = policy_scope(Champ).find(params[:champ_id])
@champ.piece_justificative_file.attach(params[:blob_signed_id])
@champ.save
end
def attach_piece_justificative_or_retry
attach_piece_justificative
rescue ActiveRecord::StaleObjectError
attach_piece_justificative
end
end end

View file

@ -251,11 +251,11 @@ module NewAdministrateur
end end
def procedure_params def procedure_params
editable_params = [:libelle, :description, :organisation, :direction, :lien_site_web, :cadre_juridique, :deliberation, :notice, :web_hook_url, :declarative_with_state, :euro_flag, :logo, :auto_archive_on, :monavis_embed, :api_entreprise_token] editable_params = [:libelle, :description, :organisation, :direction, :lien_site_web, :cadre_juridique, :deliberation, :notice, :web_hook_url, :declarative_with_state, :logo, :auto_archive_on, :monavis_embed, :api_entreprise_token, :duree_conservation_dossiers_dans_ds]
permited_params = if @procedure&.locked? permited_params = if @procedure&.locked?
params.require(:procedure).permit(*editable_params) params.require(:procedure).permit(*editable_params)
else else
params.require(:procedure).permit(*editable_params, :duree_conservation_dossiers_dans_ds, :duree_conservation_dossiers_hors_ds, :for_individual, :path) params.require(:procedure).permit(*editable_params, :for_individual, :path)
end end
if permited_params[:auto_archive_on].present? if permited_params[:auto_archive_on].present?
permited_params[:auto_archive_on] = Date.parse(permited_params[:auto_archive_on]) + 1.day permited_params[:auto_archive_on] = Date.parse(permited_params[:auto_archive_on]) + 1.day

View file

@ -1,10 +1,9 @@
module Users module Users
class ProfilController < UserController class ProfilController < UserController
before_action :ensure_update_email_is_authorized, only: :update_email before_action :ensure_update_email_is_authorized, only: :update_email
before_action :find_transfers, only: [:show, :renew_api_token]
def show def show
@waiting_merge_emails = waiting_merge_emails
@waiting_transfers = current_user.dossiers.joins(:transfer).group('dossier_transfers.email').count.to_a
end end
def renew_api_token def renew_api_token
@ -56,6 +55,11 @@ module Users
private private
def find_transfers
@waiting_merge_emails = waiting_merge_emails
@waiting_transfers = current_user.dossiers.joins(:transfer).group('dossier_transfers.email').count.to_a
end
def waiting_merge_emails def waiting_merge_emails
users_requesting_merge.pluck(:email) users_requesting_merge.pluck(:email)
end end

View file

@ -1,6 +1,6 @@
module ConservationDeDonneesHelper module ConservationDeDonneesHelper
def politiques_conservation_de_donnees(procedure) def politiques_conservation_de_donnees(procedure)
[conservation_dans_ds(procedure), conservation_hors_ds(procedure)].compact [conservation_dans_ds(procedure)].compact
end end
private private
@ -10,10 +10,4 @@ module ConservationDeDonneesHelper
"Dans #{APPLICATION_NAME} : #{procedure.duree_conservation_dossiers_dans_ds} mois" "Dans #{APPLICATION_NAME} : #{procedure.duree_conservation_dossiers_dans_ds} mois"
end end
end end
def conservation_hors_ds(procedure)
if procedure.duree_conservation_dossiers_hors_ds.present?
"Par ladministration : #{procedure.duree_conservation_dossiers_hors_ds} mois"
end
end
end end

View file

@ -83,14 +83,16 @@ class Dossier < ApplicationRecord
has_many :avis, inverse_of: :dossier, dependent: :destroy has_many :avis, inverse_of: :dossier, dependent: :destroy
has_many :experts, through: :avis has_many :experts, through: :avis
has_many :traitements, -> { order(:processed_at) }, inverse_of: :dossier, dependent: :destroy do has_many :traitements, -> { order(:processed_at) }, inverse_of: :dossier, dependent: :destroy do
def passer_en_construction(processed_at: Time.zone.now) def passer_en_construction(instructeur: nil, processed_at: Time.zone.now)
build(state: Dossier.states.fetch(:en_construction), build(state: Dossier.states.fetch(:en_construction),
instructeur_email: instructeur&.email,
process_expired: false, process_expired: false,
processed_at: processed_at) processed_at: processed_at)
end end
def passer_en_instruction(processed_at: Time.zone.now) def passer_en_instruction(instructeur: nil, processed_at: Time.zone.now)
build(state: Dossier.states.fetch(:en_instruction), build(state: Dossier.states.fetch(:en_instruction),
instructeur_email: instructeur&.email,
process_expired: false, process_expired: false,
processed_at: processed_at) processed_at: processed_at)
end end
@ -735,7 +737,7 @@ class Dossier < ApplicationRecord
self.en_construction_close_to_expiration_notice_sent_at = nil self.en_construction_close_to_expiration_notice_sent_at = nil
self.conservation_extension = 0.days self.conservation_extension = 0.days
self.en_instruction_at = self.traitements self.en_instruction_at = self.traitements
.passer_en_instruction .passer_en_instruction(instructeur: instructeur)
.processed_at .processed_at
save! save!
@ -759,7 +761,7 @@ class Dossier < ApplicationRecord
self.en_construction_close_to_expiration_notice_sent_at = nil self.en_construction_close_to_expiration_notice_sent_at = nil
self.conservation_extension = 0.days self.conservation_extension = 0.days
self.en_construction_at = self.traitements self.en_construction_at = self.traitements
.passer_en_construction .passer_en_construction(instructeur: instructeur)
.processed_at .processed_at
save! save!
log_dossier_operation(instructeur, :repasser_en_construction) log_dossier_operation(instructeur, :repasser_en_construction)
@ -770,7 +772,7 @@ class Dossier < ApplicationRecord
self.termine_close_to_expiration_notice_sent_at = nil self.termine_close_to_expiration_notice_sent_at = nil
self.conservation_extension = 0.days self.conservation_extension = 0.days
self.en_instruction_at = self.traitements self.en_instruction_at = self.traitements
.passer_en_instruction .passer_en_instruction(instructeur: instructeur)
.processed_at .processed_at
attestation&.destroy attestation&.destroy

View file

@ -51,6 +51,7 @@
# #
class Procedure < ApplicationRecord class Procedure < ApplicationRecord
self.ignored_columns = [:duree_conservation_dossiers_hors_ds]
include ProcedureStatsConcern include ProcedureStatsConcern
include EncryptableConcern include EncryptableConcern
include FileValidationConcern include FileValidationConcern
@ -238,7 +239,6 @@ class Procedure < ApplicationRecord
validate :check_juridique validate :check_juridique
validates :path, presence: true, format: { with: /\A[a-z0-9_\-]{3,200}\z/ }, uniqueness: { scope: [:path, :closed_at, :hidden_at, :unpublished_at], case_sensitive: false } validates :path, presence: true, format: { with: /\A[a-z0-9_\-]{3,200}\z/ }, uniqueness: { scope: [:path, :closed_at, :hidden_at, :unpublished_at], case_sensitive: false }
validates :duree_conservation_dossiers_dans_ds, allow_nil: false, numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: MAX_DUREE_CONSERVATION } validates :duree_conservation_dossiers_dans_ds, allow_nil: false, numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: MAX_DUREE_CONSERVATION }
validates :duree_conservation_dossiers_hors_ds, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
validates_with MonAvisEmbedValidator validates_with MonAvisEmbedValidator
FILE_MAX_SIZE = 20.megabytes FILE_MAX_SIZE = 20.megabytes

View file

@ -2,18 +2,12 @@
- if traitements.any? - if traitements.any?
%ul.tab-list %ul.tab-list
- traitements.each do |traitement| - traitements.each do |traitement|
- if traitement.instructeur_email.present? %li
%li - processed_at = l(traitement.processed_at, format: '%d %B %Y à %R')
= "Le #{l(traitement.processed_at, format: '%d %B %Y à %R')}, " - if traitement.instructeur_email.present?
= traitement.instructeur_email = t(".with_email.#{traitement.state}", processed_at: processed_at, email: traitement.instructeur_email)
a - else
%strong= t(traitement.state, scope: 'activerecord.attributes.traitement.state').downcase = t(".without_email.#{traitement.state}", processed_at: processed_at)
ce dossier
- else
%li
= "Le #{l(traitement.processed_at, format: '%d %B %Y à %R')}, "
ce dossier a été
%strong= t(traitement.state, scope: 'activerecord.attributes.traitement.state').downcase
- else - else
%p.tab-paragraph Aucune décision na été rendue %p.tab-paragraph Aucune décision na été rendue

View file

@ -5,7 +5,7 @@
#profil-page.container #profil-page.container
%h1 Profil %h1 Profil
- if @waiting_merge_emails&.any? - if @waiting_merge_emails.present?
.card .card
.card-title Demande de fusion de comptes .card-title Demande de fusion de comptes
%p %p
@ -37,7 +37,7 @@
application_name: APPLICATION_NAME, application_name: APPLICATION_NAME,
legit_admin_domains: LEGIT_ADMIN_DOMAINS.join(', ')) legit_admin_domains: LEGIT_ADMIN_DOMAINS.join(', '))
= form_for @current_user, url: update_email_path, method: :patch, html: { class: 'form' } do |f| = form_for current_user, url: update_email_path, method: :patch, html: { class: 'form' } do |f|
= f.email_field :email, value: nil, placeholder: 'Nouvelle adresse email', required: true = f.email_field :email, value: nil, placeholder: 'Nouvelle adresse email', required: true
= f.submit "Changer mon adresse", class: 'button primary' = f.submit "Changer mon adresse", class: 'button primary'
@ -50,7 +50,7 @@
= email_field_tag :next_owner, nil, required: true = email_field_tag :next_owner, nil, required: true
= submit_tag "Transférer tous mes dossiers", class: 'button primary', data: { confirm: t('.transfer_confirmation') } = submit_tag "Transférer tous mes dossiers", class: 'button primary', data: { confirm: t('.transfer_confirmation') }
- if @waiting_transfers.any? - if @waiting_transfers.present?
.card.warning .card.warning
.card-title= t('.waiting_transfers') .card-title= t('.waiting_transfers')
%ul %ul

View file

@ -17,3 +17,17 @@ fr:
download_archive: Télécharger une archive au format .zip de tous les dossiers et leurs pièces jointes download_archive: Télécharger une archive au format .zip de tous les dossiers et leurs pièces jointes
archive_pending_html: Archive en cours de création<br>(demandée il y a %{created_period}) archive_pending_html: Archive en cours de création<br>(demandée il y a %{created_period})
archive_ready_html: Télécharger larchive<br>(demandée il y a %{generated_period}) archive_ready_html: Télécharger larchive<br>(demandée il y a %{generated_period})
dossiers:
decisions_rendues_block:
without_email:
en_construction: Le %{processed_at} ce dossier a été passé en construction
en_instruction: Le %{processed_at} ce dossier a été passé en instruction
accepte: Le %{processed_at} ce dossier a été accepté
refuse: Le %{processed_at} ce dossier a été refusé
classe_sans_suite: Le %{processed_at} ce dossier a été classé sans suite
with_email:
en_construction: Le %{processed_at}, %{email} a passé ce dossier en construction
en_instruction: Le %{processed_at}, %{email} a passé ce dossier en instruction
accepte: Le %{processed_at}, %{email} a accepté ce dossier
refuse: Le %{processed_at}, %{email} a refusé ce dossier
classe_sans_suite: Le %{processed_at}, %{email} a classé ce dossier sans suite

View file

@ -9,7 +9,6 @@ describe NewAdministrateur::ProceduresController, type: :controller do
let(:direction) { 'Direction de test' } let(:direction) { 'Direction de test' }
let(:cadre_juridique) { 'cadre juridique' } let(:cadre_juridique) { 'cadre juridique' }
let(:duree_conservation_dossiers_dans_ds) { 3 } let(:duree_conservation_dossiers_dans_ds) { 3 }
let(:duree_conservation_dossiers_hors_ds) { 6 }
let(:monavis_embed) { nil } let(:monavis_embed) { nil }
let(:lien_site_web) { 'http://mon-site.gouv.fr' } let(:lien_site_web) { 'http://mon-site.gouv.fr' }
@ -33,7 +32,6 @@ describe NewAdministrateur::ProceduresController, type: :controller do
direction: direction, direction: direction,
cadre_juridique: cadre_juridique, cadre_juridique: cadre_juridique,
duree_conservation_dossiers_dans_ds: duree_conservation_dossiers_dans_ds, duree_conservation_dossiers_dans_ds: duree_conservation_dossiers_dans_ds,
duree_conservation_dossiers_hors_ds: duree_conservation_dossiers_hors_ds,
monavis_embed: monavis_embed, monavis_embed: monavis_embed,
lien_site_web: lien_site_web lien_site_web: lien_site_web
} }
@ -164,7 +162,6 @@ describe NewAdministrateur::ProceduresController, type: :controller do
it { expect(subject.direction).to eq(direction) } it { expect(subject.direction).to eq(direction) }
it { expect(subject.administrateurs).to eq([admin]) } it { expect(subject.administrateurs).to eq([admin]) }
it { expect(subject.duree_conservation_dossiers_dans_ds).to eq(duree_conservation_dossiers_dans_ds) } it { expect(subject.duree_conservation_dossiers_dans_ds).to eq(duree_conservation_dossiers_dans_ds) }
it { expect(subject.duree_conservation_dossiers_hors_ds).to eq(duree_conservation_dossiers_hors_ds) }
end end
it { is_expected.to redirect_to(champs_admin_procedure_path(Procedure.last)) } it { is_expected.to redirect_to(champs_admin_procedure_path(Procedure.last)) }
@ -234,7 +231,6 @@ describe NewAdministrateur::ProceduresController, type: :controller do
let(:organisation) { 'plop' } let(:organisation) { 'plop' }
let(:direction) { 'plap' } let(:direction) { 'plap' }
let(:duree_conservation_dossiers_dans_ds) { 7 } let(:duree_conservation_dossiers_dans_ds) { 7 }
let(:duree_conservation_dossiers_hors_ds) { 5 }
before { update_procedure } before { update_procedure }
@ -246,7 +242,6 @@ describe NewAdministrateur::ProceduresController, type: :controller do
it { expect(subject.organisation).to eq(organisation) } it { expect(subject.organisation).to eq(organisation) }
it { expect(subject.direction).to eq(direction) } it { expect(subject.direction).to eq(direction) }
it { expect(subject.duree_conservation_dossiers_dans_ds).to eq(duree_conservation_dossiers_dans_ds) } it { expect(subject.duree_conservation_dossiers_dans_ds).to eq(duree_conservation_dossiers_dans_ds) }
it { expect(subject.duree_conservation_dossiers_hors_ds).to eq(duree_conservation_dossiers_hors_ds) }
end end
it { is_expected.to redirect_to(edit_admin_procedure_path id: procedure.id) } it { is_expected.to redirect_to(edit_admin_procedure_path id: procedure.id) }

View file

@ -1,30 +1,16 @@
RSpec.describe ConservationDeDonneesHelper, type: :helper do RSpec.describe ConservationDeDonneesHelper, type: :helper do
let(:procedure) { build(:procedure, duree_conservation_dossiers_dans_ds: dans_ds, duree_conservation_dossiers_hors_ds: hors_ds) } let(:procedure) { build(:procedure, duree_conservation_dossiers_dans_ds: dans_ds) }
describe "politiques_conservation_de_donnees" do describe "politiques_conservation_de_donnees" do
subject { politiques_conservation_de_donnees(procedure) } subject { politiques_conservation_de_donnees(procedure) }
context "when both retention times are set" do context "when retention time is set" do
let(:dans_ds) { 3 } let(:dans_ds) { 3 }
let(:hors_ds) { 6 } let(:hors_ds) { 6 }
it { is_expected.to eq(["Dans #{APPLICATION_NAME} : 3 mois", "Par ladministration : 6 mois"]) }
end
context "when only in-app retention time is set" do
let(:dans_ds) { 3 }
let(:hors_ds) { nil }
it { is_expected.to eq(["Dans #{APPLICATION_NAME} : 3 mois"]) } it { is_expected.to eq(["Dans #{APPLICATION_NAME} : 3 mois"]) }
end end
context "when only out of app retention time is set" do
let(:dans_ds) { nil }
let(:hors_ds) { 6 }
it { is_expected.to eq(["Par ladministration : 6 mois"]) }
end
context "when the retention time is not set" do context "when the retention time is not set" do
let(:dans_ds) { nil } let(:dans_ds) { nil }
let(:hors_ds) { nil } let(:hors_ds) { nil }