Merge pull request #7041 from betagouv/main

2022-03-15-01
This commit is contained in:
Paul Chavard 2022-03-15 10:20:15 +01:00 committed by GitHub
commit bd4b2e3d47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 237 additions and 114 deletions

View file

@ -43,7 +43,7 @@ module Instructeurs
end end
def show def show
@demande_seen_at = current_instructeur.follows.find_by(dossier: dossier)&.demande_seen_at @demande_seen_at = current_instructeur.follows.find_by(dossier: dossier_with_champs)&.demande_seen_at
respond_to do |format| respond_to do |format|
format.pdf do format.pdf do
@ -96,24 +96,24 @@ module Instructeurs
def follow def follow
current_instructeur.follow(dossier) current_instructeur.follow(dossier)
flash.notice = 'Dossier suivi' flash.notice = 'Dossier suivi'
redirect_back(fallback_location: instructeur_procedures_url) redirect_back(fallback_location: instructeur_procedure_path(procedure))
end end
def unfollow def unfollow
current_instructeur.unfollow(dossier) current_instructeur.unfollow(dossier)
flash.notice = "Vous ne suivez plus le dossier nº #{dossier.id}" flash.notice = "Vous ne suivez plus le dossier nº #{dossier.id}"
redirect_back(fallback_location: instructeur_procedures_url) redirect_back(fallback_location: instructeur_procedure_path(procedure))
end end
def archive def archive
dossier.archiver!(current_instructeur) dossier.archiver!(current_instructeur)
redirect_back(fallback_location: instructeur_procedures_url) redirect_back(fallback_location: instructeur_procedure_path(procedure))
end end
def unarchive def unarchive
dossier.desarchiver!(current_instructeur) dossier.desarchiver!(current_instructeur)
redirect_back(fallback_location: instructeur_procedures_url) redirect_back(fallback_location: instructeur_procedure_path(procedure))
end end
def passer_en_instruction def passer_en_instruction
@ -226,14 +226,25 @@ module Instructeurs
zipline(files, "dossier-#{dossier.id}.zip") zipline(files, "dossier-#{dossier.id}.zip")
end end
def delete_dossier def destroy
if dossier.termine? if dossier.termine?
dossier.hide_and_keep_track!(current_instructeur, :instructeur_request) dossier.hide_and_keep_track!(current_instructeur, :instructeur_request)
flash.notice = t('instructeurs.dossiers.deleted_by_instructeur') flash.notice = t('instructeurs.dossiers.deleted_by_instructeur')
redirect_to instructeur_procedure_path(procedure)
else else
flash.alert = t('instructeurs.dossiers.impossible_deletion') flash.alert = t('instructeurs.dossiers.impossible_deletion')
redirect_back(fallback_location: instructeur_procedures_url) end
redirect_back(fallback_location: instructeur_procedure_path(procedure))
end
def restore
dossier = current_instructeur.dossiers.find(params[:dossier_id])
dossier.restore(current_instructeur)
flash.notice = t('instructeurs.dossiers.restore')
if dossier.termine?
redirect_to instructeur_procedure_path(procedure, statut: :traites)
else
redirect_back(fallback_location: instructeur_procedure_path(procedure))
end end
end end
@ -243,7 +254,15 @@ module Instructeurs
@dossier ||= current_instructeur @dossier ||= current_instructeur
.dossiers .dossiers
.visible_by_administration .visible_by_administration
.includes(champs: :type_de_champ) .find(params[:dossier_id])
end
def dossier_with_champs
@dossier ||= current_instructeur
.dossiers
.visible_by_administration
.with_champs
.with_annotations
.find(params[:dossier_id]) .find(params[:dossier_id])
end end
@ -259,19 +278,19 @@ module Instructeurs
end end
def mark_demande_as_read def mark_demande_as_read
current_instructeur.mark_tab_as_seen(dossier, :demande) current_instructeur.mark_tab_as_seen(@dossier, :demande)
end end
def mark_messagerie_as_read def mark_messagerie_as_read
current_instructeur.mark_tab_as_seen(dossier, :messagerie) current_instructeur.mark_tab_as_seen(@dossier, :messagerie)
end end
def mark_avis_as_read def mark_avis_as_read
current_instructeur.mark_tab_as_seen(dossier, :avis) current_instructeur.mark_tab_as_seen(@dossier, :avis)
end end
def mark_annotations_privees_as_read def mark_annotations_privees_as_read
current_instructeur.mark_tab_as_seen(dossier, :annotations_privees) current_instructeur.mark_tab_as_seen(@dossier, :annotations_privees)
end end
def aasm_error_message(exception, target_state:) def aasm_error_message(exception, target_state:)

View file

@ -39,7 +39,7 @@ module Instructeurs
'dossiers' => @dossiers_count_per_procedure.sum { |_, v| v }, 'dossiers' => @dossiers_count_per_procedure.sum { |_, v| v },
'expirant' => @dossiers_expirant_count_per_procedure.sum { |_, v| v }, 'expirant' => @dossiers_expirant_count_per_procedure.sum { |_, v| v },
'archivés' => @dossiers_archived_count_per_procedure.sum { |_, v| v }, 'archivés' => @dossiers_archived_count_per_procedure.sum { |_, v| v },
'supprimes_recemment' => @dossiers_supprimes_recemment_count_per_procedure.sum { |_, v| v } 'supprimés récemment' => @dossiers_supprimes_recemment_count_per_procedure.sum { |_, v| v }
} }
@procedure_ids_en_cours_with_notifications = current_instructeur.procedure_ids_with_notifications(:en_cours) @procedure_ids_en_cours_with_notifications = current_instructeur.procedure_ids_with_notifications(:en_cours)
@ -137,15 +137,18 @@ module Instructeurs
.order(:dossier_id) .order(:dossier_id)
.page params[:page] .page params[:page]
@a_suivre_count, @suivis_count, @traites_count, @tous_count, @archives_count = current_instructeur @a_suivre_count, @suivis_count, @traites_count, @tous_count, @archives_count, @supprimes_recemment_count, @expirant_count = current_instructeur
.dossiers_count_summary(groupe_instructeur_ids) .dossiers_count_summary(groupe_instructeur_ids)
.fetch_values('a_suivre', 'suivis', 'traites', 'tous', 'archives') .fetch_values('a_suivre', 'suivis', 'traites', 'tous', 'archives', 'supprimes_recemment', 'expirant')
@can_download_dossiers = (@tous_count + @archives_count) > 0
notifications = current_instructeur.notifications_for_groupe_instructeurs(groupe_instructeur_ids) notifications = current_instructeur.notifications_for_groupe_instructeurs(groupe_instructeur_ids)
@has_en_cours_notifications = notifications[:en_cours].present? @has_en_cours_notifications = notifications[:en_cours].present?
@has_termine_notifications = notifications[:termines].present? @has_termine_notifications = notifications[:termines].present?
@statut = 'supprime' @statut = 'supprime'
assign_exports
end end
def update_displayed_fields def update_displayed_fields
@ -278,6 +281,8 @@ module Instructeurs
redirect_to instructeur_procedure_path(@procedure) redirect_to instructeur_procedure_path(@procedure)
end end
private
def create_bulk_message_mail(dossier_count, dossier_state) def create_bulk_message_mail(dossier_count, dossier_state)
BulkMessage.create( BulkMessage.create(
dossier_count: dossier_count, dossier_count: dossier_count,
@ -290,15 +295,6 @@ module Instructeurs
) )
end end
def restore
dossier = current_instructeur.dossiers.find(params[:dossier_id])
dossier.restore(current_instructeur)
flash.notice = t('instructeurs.dossiers.restore')
redirect_to instructeur_procedure_path(procedure)
end
private
def assign_to_params def assign_to_params
params.require(:assign_to) params.require(:assign_to)
.permit(:instant_email_dossier_notifications_enabled, :instant_email_message_notifications_enabled, :daily_email_notifications_enabled, :weekly_email_notifications_enabled) .permit(:instant_email_dossier_notifications_enabled, :instant_email_message_notifications_enabled, :daily_email_notifications_enabled, :weekly_email_notifications_enabled)

View file

@ -727,6 +727,11 @@ type Dossier {
""" """
dateDerniereModification: ISO8601DateTime! dateDerniereModification: ISO8601DateTime!
"""
Date dexpiration.
"""
dateExpiration: ISO8601DateTime
""" """
Date du dernier passage en construction. Date du dernier passage en construction.
""" """
@ -737,6 +742,16 @@ type Dossier {
""" """
datePassageEnInstruction: ISO8601DateTime datePassageEnInstruction: ISO8601DateTime
"""
Date de la suppression par ladministration.
"""
dateSuppressionParAdministration: ISO8601DateTime
"""
Date de la suppression par lusager.
"""
dateSuppressionParUsager: ISO8601DateTime
""" """
Date du dernier traitement. Date du dernier traitement.
""" """
@ -770,6 +785,7 @@ type Dossier {
Létat du dossier. Létat du dossier.
""" """
state: DossierState! state: DossierState!
traitements: [Traitement!]!
usager: Profile! usager: Profile!
} }
@ -1877,6 +1893,14 @@ enum TitreIdentiteGrantType {
piece_justificative piece_justificative
} }
type Traitement {
dateTraitement: ISO8601DateTime!
emailAgentTraitant: String
id: ID!
motivation: String
state: DossierState!
}
enum TypeDeChamp { enum TypeDeChamp {
""" """
Adresse Adresse

View file

@ -20,6 +20,10 @@ module Types
field :date_traitement, GraphQL::Types::ISO8601DateTime, "Date du dernier traitement.", null: true, method: :processed_at field :date_traitement, GraphQL::Types::ISO8601DateTime, "Date du dernier traitement.", null: true, method: :processed_at
field :date_derniere_modification, GraphQL::Types::ISO8601DateTime, "Date de la dernière modification.", null: false, method: :updated_at field :date_derniere_modification, GraphQL::Types::ISO8601DateTime, "Date de la dernière modification.", null: false, method: :updated_at
field :date_suppression_par_usager, GraphQL::Types::ISO8601DateTime, "Date de la suppression par lusager.", null: true, method: :hidden_by_user_at
field :date_suppression_par_administration, GraphQL::Types::ISO8601DateTime, "Date de la suppression par ladministration.", null: true, method: :hidden_by_administration_at
field :date_expiration, GraphQL::Types::ISO8601DateTime, "Date dexpiration.", null: true
field :archived, Boolean, null: false field :archived, Boolean, null: false
field :motivation, String, null: true field :motivation, String, null: true
@ -51,11 +55,18 @@ module Types
field :annotations, [Types::ChampType], null: false do field :annotations, [Types::ChampType], null: false do
argument :id, ID, required: false argument :id, ID, required: false
end end
field :traitements, [Types::TraitementType], null: false
def state def state
object.state object.state
end end
def date_expiration
if !object.en_instruction?
object.expiration_date.presence || object.approximative_expiration_date
end
end
def usager def usager
if object.user_deleted? if object.user_deleted?
{ email: object.user_email_for(:display), id: -1 } { email: object.user_email_for(:display), id: -1 }
@ -84,6 +95,10 @@ module Types
Loaders::Association.for(object.class, :followers_instructeurs).load(object) Loaders::Association.for(object.class, :followers_instructeurs).load(object)
end end
def traitements
Loaders::Association.for(object.class, :traitements).load(object)
end
def messages(id: nil) def messages(id: nil)
if id.present? if id.present?
Loaders::Record Loaders::Record

View file

@ -0,0 +1,9 @@
module Types
class TraitementType < Types::BaseObject
global_id_field :id
field :state, Types::DossierType::DossierState, null: false
field :date_traitement, GraphQL::Types::ISO8601DateTime, null: false, method: :processed_at
field :email_agent_traitant, String, null: true, method: :instructeur_email
field :motivation, String, null: true
end
end

View file

@ -81,18 +81,8 @@ class Champ < ApplicationRecord
!private? !private?
end end
def siblings
if parent
parent&.champs
elsif public?
dossier&.champs
else
dossier&.champs_private
end
end
def sections def sections
siblings&.filter(&:header_section?) @sections ||= dossier.sections_for(self)
end end
def mandatory_and_blank? def mandatory_and_blank?

View file

@ -261,25 +261,26 @@ class Dossier < ApplicationRecord
} }
scope :en_cours, -> { not_archived.state_en_construction_ou_instruction } scope :en_cours, -> { not_archived.state_en_construction_ou_instruction }
scope :without_followers, -> { left_outer_joins(:follows).where(follows: { id: nil }) } scope :without_followers, -> { left_outer_joins(:follows).where(follows: { id: nil }) }
scope :with_champs, -> { includes(champs: :type_de_champ) } scope :with_champs, -> {
includes(champs: [
:type_de_champ,
:geo_areas,
piece_justificative_file_attachment: :blob,
champs: [:type_de_champ, piece_justificative_file_attachment: :blob]
])
}
scope :with_annotations, -> {
includes(champs_private: [
:type_de_champ,
:geo_areas,
piece_justificative_file_attachment: :blob,
champs: [:type_de_champ, piece_justificative_file_attachment: :blob]
])
}
scope :for_api, -> { scope :for_api, -> {
includes(commentaires: { piece_jointe_attachment: :blob }, with_champs
champs: [ .with_annotations
:geo_areas, .includes(commentaires: { piece_jointe_attachment: :blob },
:etablissement,
piece_justificative_file_attachment: :blob,
champs: [
piece_justificative_file_attachment: :blob
]
],
champs_private: [
:geo_areas,
:etablissement,
piece_justificative_file_attachment: :blob,
champs: [
piece_justificative_file_attachment: :blob
]
],
justificatif_motivation_attachment: :blob, justificatif_motivation_attachment: :blob,
attestation: [], attestation: [],
avis: { piece_justificative_file_attachment: :blob }, avis: { piece_justificative_file_attachment: :blob },
@ -1122,6 +1123,20 @@ class Dossier < ApplicationRecord
termine_expired_to_delete.find_each(&:purge_discarded) termine_expired_to_delete.find_each(&:purge_discarded)
end end
def sections_for(champ)
@sections = Hash.new do |hash, parent|
case parent
when :public
hash[parent] = champs.filter(&:header_section?)
when :private
hash[parent] = champs_private.filter(&:header_section?)
else
hash[parent] = parent.champs.filter(&:header_section?)
end
end
@sections[champ.parent || (champ.public? ? :public : :private)]
end
private private
def create_missing_traitemets def create_missing_traitemets
@ -1143,7 +1158,7 @@ class Dossier < ApplicationRecord
end end
def geo_areas def geo_areas
champs.includes(:geo_areas).flat_map(&:geo_areas) + champs_private.includes(:geo_areas).flat_map(&:geo_areas) champs.flat_map(&:geo_areas) + champs_private.flat_map(&:geo_areas)
end end
def bounding_box def bounding_box

View file

@ -140,6 +140,7 @@ class Instructeur < ApplicationRecord
def notifications_for_groupe_instructeurs(groupe_instructeurs) def notifications_for_groupe_instructeurs(groupe_instructeurs)
Dossier Dossier
.visible_by_administration
.not_archived .not_archived
.where(groupe_instructeur: groupe_instructeurs) .where(groupe_instructeur: groupe_instructeurs)
.merge(followed_dossiers) .merge(followed_dossiers)
@ -180,8 +181,8 @@ class Instructeur < ApplicationRecord
nb_notification = notifications[:en_cours].count + notifications[:termines].count nb_notification = notifications[:en_cours].count + notifications[:termines].count
h = { h = {
nb_en_construction: groupe.dossiers.en_construction.count, nb_en_construction: groupe.dossiers.visible_by_administration.en_construction.count,
nb_en_instruction: groupe.dossiers.en_instruction.count, nb_en_instruction: groupe.dossiers.visible_by_administration.en_instruction.count,
nb_accepted: Traitement.where(dossier: groupe.dossiers.accepte, processed_at: Time.zone.yesterday.beginning_of_day..Time.zone.yesterday.end_of_day).count, nb_accepted: Traitement.where(dossier: groupe.dossiers.accepte, processed_at: Time.zone.yesterday.beginning_of_day..Time.zone.yesterday.end_of_day).count,
nb_notification: nb_notification nb_notification: nb_notification
} }

View file

@ -74,6 +74,8 @@ class SerializerService
datePassageEnConstruction datePassageEnConstruction
datePassageEnInstruction datePassageEnInstruction
dateTraitement dateTraitement
dateSuppressionParUsager
dateSuppressionParAdministration
instructeurs { instructeurs {
email email
} }

View file

@ -28,7 +28,8 @@
state: dossier.state, state: dossier.state,
archived: dossier.archived, archived: dossier.archived,
dossier_is_followed: current_instructeur&.follow?(dossier), dossier_is_followed: current_instructeur&.follow?(dossier),
close_to_expiration: dossier.close_to_expiration? } close_to_expiration: dossier.close_to_expiration?,
hidden_by_administration: dossier.hidden_by_administration? }
.state-button .state-button

View file

@ -114,8 +114,7 @@
Lusager a supprimé son compte. Vous pouvez archiver puis supprimer le dossier. Lusager a supprimé son compte. Vous pouvez archiver puis supprimer le dossier.
%li %li
= link_to supprimer_dossier_instructeur_dossier_path(dossier.procedure, dossier), method: :patch, data: { confirm: "Voulez vous vraiment supprimer le dossier #{dossier.id} ? Cette action est irréversible. \nNous vous suggérons de télécharger le dossier au format PDF au préalable." } do = link_to instructeur_dossier_path(dossier.procedure, dossier), method: :delete do
%span.icon.delete %span.icon.delete
.dropdown-description .dropdown-description
%h4 Supprimer le dossier %h4 Supprimer le dossier
Lusager sera notifié que son dossier est supprimé.

View file

@ -1,4 +1,7 @@
- if close_to_expiration || Dossier::TERMINE.include?(state) - if hidden_by_administration
= link_to restore_instructeur_dossier_path(procedure_id, dossier_id), method: :patch, class: "button" do
= t('views.instructeurs.dossiers.restore')
- elsif close_to_expiration || Dossier::TERMINE.include?(state)
.dropdown.user-dossier-actions .dropdown.user-dossier-actions
%button.button.dropdown-button{ 'aria-expanded' => 'false', 'aria-controls' => 'actions-menu' } %button.button.dropdown-button{ 'aria-expanded' => 'false', 'aria-controls' => 'actions-menu' }
Actions Actions
@ -23,7 +26,7 @@
Archiver le dossier Archiver le dossier
%li.danger %li.danger
= link_to supprimer_dossier_instructeur_dossier_path(procedure_id, dossier_id), method: :patch, data: { confirm: "Voulez vous vraiment supprimer le dossier #{dossier_id} ? Cette action est irréversible. \nNous vous suggérons de télécharger le dossier au format PDF au préalable." } do = link_to instructeur_dossier_path(procedure_id, dossier_id), method: :delete do
%span.icon.delete %span.icon.delete
.dropdown-description .dropdown-description
= t('views.instructeurs.dossiers.delete_dossier') = t('views.instructeurs.dossiers.delete_dossier')

View file

@ -7,13 +7,21 @@
.procedure-logo{ style: "background-image: url(#{@procedure.logo_url})", .procedure-logo{ style: "background-image: url(#{@procedure.logo_url})",
role: 'img', 'aria-label': "logo de la démarche #{@procedure.libelle}" } role: 'img', 'aria-label': "logo de la démarche #{@procedure.libelle}" }
= render partial: 'header', locals: { procedure: @procedure, = render partial: 'header', locals: { procedure: @procedure, statut: @statut }
.procedure-actions
- if @can_download_dossiers
= render partial: "download_dossiers", locals: { procedure: @procedure, exports: @exports }
.container.flex= render partial: "tabs", locals: { procedure: @procedure,
statut: @statut, statut: @statut,
a_suivre_count: @a_suivre_count, a_suivre_count: @a_suivre_count,
suivis_count: @suivis_count, suivis_count: @suivis_count,
traites_count: @traites_count, traites_count: @traites_count,
tous_count: @tous_count, tous_count: @tous_count,
supprimes_recemment_count: @supprimes_recemment_count,
archives_count: @archives_count, archives_count: @archives_count,
expirant_count: @expirant_count,
has_en_cours_notifications: @has_en_cours_notifications, has_en_cours_notifications: @has_en_cours_notifications,
has_termine_notifications: @has_termine_notifications } has_termine_notifications: @has_termine_notifications }

View file

@ -12,6 +12,7 @@
.procedure-actions .procedure-actions
- if @can_download_dossiers - if @can_download_dossiers
= render partial: "download_dossiers", locals: { procedure: @procedure, exports: @exports } = render partial: "download_dossiers", locals: { procedure: @procedure, exports: @exports }
.container.flex= render partial: "tabs", locals: { procedure: @procedure, .container.flex= render partial: "tabs", locals: { procedure: @procedure,
statut: @statut, statut: @statut,
a_suivre_count: @a_suivre_count, a_suivre_count: @a_suivre_count,
@ -116,36 +117,46 @@
- path = instructeur_dossier_path(@procedure, p.dossier_id) - path = instructeur_dossier_path(@procedure, p.dossier_id)
%tr{ class: [p.hidden_by_user_at.present? && "file-hidden-by-user"] } %tr{ class: [p.hidden_by_user_at.present? && "file-hidden-by-user"] }
%td.folder-col %td.folder-col
- if p.hidden_by_administration_at.present?
%span.cell-link
%span.icon.folder
- else
%a.cell-link{ href: path } %a.cell-link{ href: path }
%span.icon.folder %span.icon.folder
- if @not_archived_notifications_dossier_ids.include?(p.dossier_id) - if @not_archived_notifications_dossier_ids.include?(p.dossier_id)
%span.notifications{ 'aria-label': 'notifications' } %span.notifications{ 'aria-label': 'notifications' }
%td.number-col %td.number-col
- if p.hidden_by_administration_at.present?
%span.cell-link= p.dossier_id
- else
%a.cell-link{ href: path }= p.dossier_id %a.cell-link{ href: path }= p.dossier_id
- p.columns.each do |column| - p.columns.each do |column|
%td %td
- if p.hidden_by_administration_at.present?
%span.cell-link
= column
= "- #{t('views.instructeurs.dossiers.deleted_by_user')}" if p.hidden_by_user_at.present?
- else
%a.cell-link{ href: path } %a.cell-link{ href: path }
= column = column
= "- #{t('views.instructeurs.dossiers.deleted_by_user')}" if p.hidden_by_user_at.present? = "- #{t('views.instructeurs.dossiers.deleted_by_user')}" if p.hidden_by_user_at.present?
%td.status-col %td.status-col
- if p.hidden_by_administration_at.present?
%span.cell-link= status_badge(p.state)
- else
%a.cell-link{ href: path }= status_badge(p.state) %a.cell-link{ href: path }= status_badge(p.state)
- if @statut == 'supprimes_recemment'
%td.action-col.follow-col
= link_to restore_instructeur_dossier_path(@procedure, p.dossier_id), method: :patch, class: "button primary" do
= t('views.instructeurs.dossiers.restore')
- else
%td.action-col.follow-col= render partial: 'dossier_actions', %td.action-col.follow-col= render partial: 'dossier_actions',
locals: { procedure_id: @procedure.id, locals: { procedure_id: @procedure.id,
dossier_id: p.dossier_id, dossier_id: p.dossier_id,
state: p.state, state: p.state,
archived: p.archived, archived: p.archived,
dossier_is_followed: @followed_dossiers_id.include?(p.dossier_id), dossier_is_followed: @followed_dossiers_id.include?(p.dossier_id),
close_to_expiration: @statut == 'expirant' } close_to_expiration: @statut == 'expirant',
hidden_by_administration: @statut == 'supprimes_recemment' }
= pagination = pagination
- else - else

View file

@ -93,7 +93,8 @@
state: p.state, state: p.state,
archived: p.archived, archived: p.archived,
dossier_is_followed: @followed_dossiers_id.include?(p.dossier_id), dossier_is_followed: @followed_dossiers_id.include?(p.dossier_id),
close_to_expiration: nil } close_to_expiration: nil,
hidden_by_administration: nil }
- else - else
%td %td

View file

@ -359,7 +359,7 @@ Rails.application.routes.draw do
get 'email_usagers' get 'email_usagers'
post 'create_multiple_commentaire' post 'create_multiple_commentaire'
resources :dossiers, only: [:show], param: :dossier_id do resources :dossiers, only: [:show, :destroy], param: :dossier_id do
member do member do
resources :commentaires, only: [:destroy] resources :commentaires, only: [:destroy]
post 'repousser-expiration' => 'dossiers#extend_conservation' post 'repousser-expiration' => 'dossiers#extend_conservation'
@ -375,7 +375,7 @@ Rails.application.routes.draw do
patch 'unfollow' patch 'unfollow'
patch 'archive' patch 'archive'
patch 'unarchive' patch 'unarchive'
patch 'supprimer-dossier' => 'dossiers#delete_dossier' patch 'restore'
patch 'annotations' => 'dossiers#update_annotations' patch 'annotations' => 'dossiers#update_annotations'
post 'commentaire' => 'dossiers#create_commentaire' post 'commentaire' => 'dossiers#create_commentaire'
post 'passer-en-instruction' => 'dossiers#passer_en_instruction' post 'passer-en-instruction' => 'dossiers#passer_en_instruction'
@ -386,7 +386,6 @@ Rails.application.routes.draw do
post 'avis' => 'dossiers#create_avis' post 'avis' => 'dossiers#create_avis'
get 'print' => 'dossiers#print' get 'print' => 'dossiers#print'
get 'telecharger_pjs' => 'dossiers#telecharger_pjs' get 'telecharger_pjs' => 'dossiers#telecharger_pjs'
patch 'restore'
end end
end end

View file

@ -0,0 +1,13 @@
namespace :after_party do
desc 'Deployment task: null_exports_key_to_uuid'
task null_exports_key_to_uuid: :environment do
puts "Running deploy task 'null_exports_key_to_uuid'"
Export.where(key: nil).update_all(key: SecureRandom.uuid)
# Update task as completed. If you remove the line below, the task will
# run with every deploy (or every time you call after_party:run).
AfterParty::TaskRecord
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
end
end

View file

@ -56,7 +56,7 @@ describe Instructeurs::DossiersController, type: :controller do
it { expect(instructeur.followed_dossiers).to match([dossier]) } it { expect(instructeur.followed_dossiers).to match([dossier]) }
it { expect(flash.notice).to eq('Dossier suivi') } it { expect(flash.notice).to eq('Dossier suivi') }
it { expect(response).to redirect_to(instructeur_procedures_url) } it { expect(response).to redirect_to(instructeur_procedure_path(dossier.procedure)) }
end end
describe '#unfollow' do describe '#unfollow' do
@ -68,7 +68,7 @@ describe Instructeurs::DossiersController, type: :controller do
it { expect(instructeur.followed_dossiers).to match([]) } it { expect(instructeur.followed_dossiers).to match([]) }
it { expect(flash.notice).to eq("Vous ne suivez plus le dossier nº #{dossier.id}") } it { expect(flash.notice).to eq("Vous ne suivez plus le dossier nº #{dossier.id}") }
it { expect(response).to redirect_to(instructeur_procedures_url) } it { expect(response).to redirect_to(instructeur_procedure_path(dossier.procedure)) }
end end
describe '#archive' do describe '#archive' do
@ -80,7 +80,7 @@ describe Instructeurs::DossiersController, type: :controller do
end end
it { expect(dossier.archived).to be true } it { expect(dossier.archived).to be true }
it { expect(response).to redirect_to(instructeur_procedures_url) } it { expect(response).to redirect_to(instructeur_procedure_path(dossier.procedure)) }
end end
describe '#unarchive' do describe '#unarchive' do
@ -91,7 +91,7 @@ describe Instructeurs::DossiersController, type: :controller do
end end
it { expect(dossier.archived).to be false } it { expect(dossier.archived).to be false }
it { expect(response).to redirect_to(instructeur_procedures_url) } it { expect(response).to redirect_to(instructeur_procedure_path(dossier.procedure)) }
end end
describe '#passer_en_instruction' do describe '#passer_en_instruction' do
@ -740,9 +740,9 @@ describe Instructeurs::DossiersController, type: :controller do
end end
end end
describe "#delete_dossier" do describe "#destroy" do
subject do subject do
patch :delete_dossier, params: { delete :destroy, params: {
procedure_id: procedure.id, procedure_id: procedure.id,
dossier_id: dossier.id dossier_id: dossier.id
} }

View file

@ -14,6 +14,8 @@ RSpec.describe Types::DossierType, type: :graphql do
let(:variables) { { number: dossier.id } } let(:variables) { { number: dossier.id } }
it { expect(data[:dossier][:attestation]).not_to be_nil } it { expect(data[:dossier][:attestation]).not_to be_nil }
it { expect(data[:dossier][:traitements]).to eq([{ state: 'accepte' }]) }
it { expect(data[:dossier][:dateExpiration]).not_to be_nil }
context 'when attestation is nil' do context 'when attestation is nil' do
before do before do
@ -39,6 +41,10 @@ RSpec.describe Types::DossierType, type: :graphql do
attestation { attestation {
url url
} }
traitements {
state
}
dateExpiration
} }
} }
GRAPHQL GRAPHQL

View file

@ -69,19 +69,32 @@ describe Champ do
end end
end end
describe '#siblings' do describe '#sections' do
let(:procedure) { create(:procedure, :with_type_de_champ, :with_type_de_champ_private, :with_repetition, types_de_champ_count: 1, types_de_champ_private_count: 1) } let(:procedure) do
create(:procedure, :with_type_de_champ, :with_type_de_champ_private, :with_repetition, types_de_champ_count: 1, types_de_champ_private_count: 1).tap do |procedure|
create(:type_de_champ_header_section, procedure: procedure)
create(:type_de_champ_header_section, procedure: procedure, private: true)
create(:type_de_champ_header_section, parent: procedure.types_de_champ.find(&:repetition?))
end
end
let(:dossier) { create(:dossier, procedure: procedure) } let(:dossier) { create(:dossier, procedure: procedure) }
let(:public_champ) { dossier.champs.first } let(:public_champ) { dossier.champs.first }
let(:private_champ) { dossier.champs_private.first } let(:private_champ) { dossier.champs_private.first }
let(:champ_in_repetition) { dossier.champs.find(&:repetition?).champs.first } let(:champ_in_repetition) { dossier.champs.find(&:repetition?).champs.first }
let(:standalone_champ) { build(:champ, type_de_champ: build(:type_de_champ), dossier: nil) } let(:standalone_champ) { build(:champ, type_de_champ: build(:type_de_champ), dossier: build(:dossier)) }
let(:public_sections) { dossier.champs.filter(&:header_section?) }
let(:private_sections) { dossier.champs_private.filter(&:header_section?) }
let(:sections_in_repetition) { champ_in_repetition.parent.champs.filter(&:header_section?) }
it 'returns the sibling champs of a champ' do it 'returns the sibling sections of a champ' do
expect(public_champ.siblings).to eq(dossier.champs) expect(public_sections).not_to be_empty
expect(private_champ.siblings).to eq(dossier.champs_private) expect(private_sections).not_to be_empty
expect(champ_in_repetition.siblings).to eq(champ_in_repetition.parent.champs) expect(sections_in_repetition).not_to be_empty
expect(standalone_champ.siblings).to be_nil
expect(public_champ.sections).to eq(public_sections)
expect(private_champ.sections).to eq(private_sections)
expect(champ_in_repetition.sections).to eq(sections_in_repetition)
expect(standalone_champ.sections).to eq([])
end end
end end

View file

@ -70,9 +70,7 @@ describe 'Instructing a dossier:', js: true do
click_on procedure.libelle click_on procedure.libelle
click_on 'traité' click_on 'traité'
click_on 'Actions' click_on 'Actions'
accept_confirm do
click_on 'Supprimer le dossier' click_on 'Supprimer le dossier'
end
click_on 'traité' click_on 'traité'
expect(page).not_to have_button('Actions') expect(page).not_to have_button('Actions')
end end