Merge pull request #8209 from tchak/fix-dossier-notifications
fix(dossier): send notifications on declarative dossiers
This commit is contained in:
commit
a4a308ec08
20 changed files with 36 additions and 57 deletions
|
@ -134,7 +134,7 @@ module Instructeurs
|
|||
|
||||
def repasser_en_construction
|
||||
begin
|
||||
dossier.repasser_en_construction!(current_instructeur)
|
||||
dossier.repasser_en_construction!(instructeur: current_instructeur)
|
||||
flash.notice = 'Dossier repassé en construction.'
|
||||
rescue AASM::InvalidTransition => e
|
||||
flash.alert = aasm_error_message(e, target_state: :en_construction)
|
||||
|
|
|
@ -14,9 +14,9 @@ module Mutations
|
|||
field :errors, [Types::ValidationErrorType], null: true
|
||||
|
||||
def resolve(dossier:, instructeur:, motivation: nil, justificatif: nil, disable_notification:)
|
||||
dossier.accepter!(instructeur: instructeur, motivation: motivation, justificatif: justificatif, disable_notification: disable_notification)
|
||||
dossier.accepter!(instructeur:, motivation:, justificatif:, disable_notification:)
|
||||
|
||||
{ dossier: dossier }
|
||||
{ dossier: }
|
||||
end
|
||||
|
||||
def ready?(justificatif: nil, **args)
|
||||
|
|
|
@ -11,7 +11,7 @@ module Mutations
|
|||
def resolve(dossier:, instructeur:)
|
||||
dossier.archiver!(instructeur)
|
||||
|
||||
{ dossier: dossier }
|
||||
{ dossier: }
|
||||
end
|
||||
|
||||
def authorized?(dossier:, instructeur:)
|
||||
|
|
|
@ -11,9 +11,9 @@ module Mutations
|
|||
field :errors, [Types::ValidationErrorType], null: true
|
||||
|
||||
def resolve(dossier:, groupe_instructeur:)
|
||||
dossier.update!(groupe_instructeur: groupe_instructeur)
|
||||
dossier.update!(groupe_instructeur:)
|
||||
|
||||
{ dossier: dossier }
|
||||
{ dossier: }
|
||||
end
|
||||
|
||||
def authorized?(dossier:, groupe_instructeur:)
|
||||
|
|
|
@ -14,9 +14,9 @@ module Mutations
|
|||
field :errors, [Types::ValidationErrorType], null: true
|
||||
|
||||
def resolve(dossier:, instructeur:, motivation:, justificatif: nil, disable_notification:)
|
||||
dossier.classer_sans_suite!(instructeur: instructeur, motivation: motivation, justificatif: justificatif, disable_notification: disable_notification)
|
||||
dossier.classer_sans_suite!(instructeur:, motivation:, justificatif:, disable_notification:)
|
||||
|
||||
{ dossier: dossier }
|
||||
{ dossier: }
|
||||
end
|
||||
|
||||
def ready?(justificatif: nil, **args)
|
||||
|
|
|
@ -14,7 +14,7 @@ module Mutations
|
|||
message = CommentaireService.create(instructeur, dossier, body: body, piece_jointe: attachment)
|
||||
|
||||
if message.errors.empty?
|
||||
{ message: message }
|
||||
{ message: }
|
||||
else
|
||||
{ errors: message.errors.full_messages }
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@ module Mutations
|
|||
if annotation.save
|
||||
dossier.log_modifier_annotation!(annotation, instructeur)
|
||||
|
||||
{ annotation: annotation }
|
||||
{ annotation: }
|
||||
else
|
||||
{ errors: annotation.errors.full_messages }
|
||||
end
|
||||
|
@ -44,9 +44,9 @@ module Mutations
|
|||
|
||||
Champ.joins(:type_de_champ).find_by(type_de_champ: {
|
||||
type_champ: annotation_type_champ,
|
||||
stable_id: stable_id,
|
||||
stable_id:,
|
||||
private: true
|
||||
}, private: true, row: row, dossier: dossier)
|
||||
}, private: true, row:, dossier:)
|
||||
end
|
||||
|
||||
def annotation_type_champ
|
||||
|
|
|
@ -16,7 +16,7 @@ module Mutations
|
|||
|
||||
annotation.add_row(dossier.revision)
|
||||
|
||||
{ annotation: annotation, errors: nil }
|
||||
{ annotation:, errors: nil }
|
||||
end
|
||||
|
||||
def authorized?(dossier:, instructeur:, **args)
|
||||
|
|
|
@ -5,12 +5,7 @@ module Mutations
|
|||
argument :value, Boolean, required: true
|
||||
|
||||
def resolve(dossier:, annotation_id:, instructeur:, value:)
|
||||
resolve_with_type(
|
||||
dossier: dossier,
|
||||
annotation_id: annotation_id,
|
||||
instructeur: instructeur,
|
||||
value: value
|
||||
) do |type_champ, value|
|
||||
resolve_with_type(dossier:, annotation_id:, instructeur:, value:) do |type_champ, value|
|
||||
if type_champ == TypeDeChamp.type_champs.fetch(:yes_no)
|
||||
value ? 'true' : 'false'
|
||||
else
|
||||
|
|
|
@ -5,12 +5,7 @@ module Mutations
|
|||
argument :value, GraphQL::Types::ISO8601Date, required: true
|
||||
|
||||
def resolve(dossier:, annotation_id:, instructeur:, value:)
|
||||
resolve_with_type(
|
||||
dossier: dossier,
|
||||
annotation_id: annotation_id,
|
||||
instructeur: instructeur,
|
||||
value: value
|
||||
)
|
||||
resolve_with_type(dossier:, annotation_id:, instructeur:, value:)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -5,12 +5,7 @@ module Mutations
|
|||
argument :value, GraphQL::Types::ISO8601DateTime, required: true
|
||||
|
||||
def resolve(dossier:, annotation_id:, instructeur:, value:)
|
||||
resolve_with_type(
|
||||
dossier: dossier,
|
||||
annotation_id: annotation_id,
|
||||
instructeur: instructeur,
|
||||
value: value
|
||||
)
|
||||
resolve_with_type(dossier:, annotation_id:, instructeur:, value:)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -5,12 +5,7 @@ module Mutations
|
|||
argument :value, Int, required: true
|
||||
|
||||
def resolve(dossier:, annotation_id:, instructeur:, value:)
|
||||
resolve_with_type(
|
||||
dossier: dossier,
|
||||
annotation_id: annotation_id,
|
||||
instructeur: instructeur,
|
||||
value: value
|
||||
)
|
||||
resolve_with_type(dossier:, annotation_id:, instructeur:, value:)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -5,12 +5,7 @@ module Mutations
|
|||
argument :value, String, required: true
|
||||
|
||||
def resolve(dossier:, annotation_id:, instructeur:, value:)
|
||||
resolve_with_type(
|
||||
dossier: dossier,
|
||||
annotation_id: annotation_id,
|
||||
instructeur: instructeur,
|
||||
value: value
|
||||
)
|
||||
resolve_with_type(dossier:, annotation_id:, instructeur:, value:)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -12,9 +12,9 @@ module Mutations
|
|||
field :errors, [Types::ValidationErrorType], null: true
|
||||
|
||||
def resolve(dossier:, instructeur:, disable_notification:)
|
||||
dossier.passer_en_instruction!(instructeur: instructeur, disable_notification: disable_notification)
|
||||
dossier.passer_en_instruction!(instructeur:, disable_notification:)
|
||||
|
||||
{ dossier: dossier }
|
||||
{ dossier: }
|
||||
end
|
||||
|
||||
def authorized?(dossier:, instructeur:, **args)
|
||||
|
|
|
@ -14,9 +14,9 @@ module Mutations
|
|||
field :errors, [Types::ValidationErrorType], null: true
|
||||
|
||||
def resolve(dossier:, instructeur:, motivation:, justificatif: nil, disable_notification:)
|
||||
dossier.refuser!(instructeur: instructeur, motivation: motivation, justificatif: justificatif, disable_notification: disable_notification)
|
||||
dossier.refuser!(instructeur:, motivation:, justificatif:, disable_notification:)
|
||||
|
||||
{ dossier: dossier }
|
||||
{ dossier: }
|
||||
end
|
||||
|
||||
def ready?(justificatif: nil, **args)
|
||||
|
|
|
@ -12,9 +12,9 @@ module Mutations
|
|||
field :errors, [Types::ValidationErrorType], null: true
|
||||
|
||||
def resolve(dossier:, instructeur:, disable_notification:)
|
||||
dossier.repasser_en_construction!(instructeur)
|
||||
dossier.repasser_en_construction!(instructeur:, disable_notification:)
|
||||
|
||||
{ dossier: dossier }
|
||||
{ dossier: }
|
||||
end
|
||||
|
||||
def authorized?(dossier:, instructeur:, **args)
|
||||
|
|
|
@ -12,9 +12,9 @@ module Mutations
|
|||
field :errors, [Types::ValidationErrorType], null: true
|
||||
|
||||
def resolve(dossier:, instructeur:, disable_notification:)
|
||||
dossier.repasser_en_instruction!(instructeur: instructeur, disable_notification: disable_notification)
|
||||
dossier.repasser_en_instruction!(instructeur:, disable_notification:)
|
||||
|
||||
{ dossier: dossier }
|
||||
{ dossier: }
|
||||
end
|
||||
|
||||
def authorized?(dossier:, instructeur:, **args)
|
||||
|
|
|
@ -10,8 +10,8 @@ module Mutations
|
|||
field :errors, [Types::ValidationErrorType], null: true
|
||||
|
||||
def resolve(groupe_instructeur:, label: nil, closed: nil)
|
||||
if groupe_instructeur.update({ label: label, closed: closed }.compact)
|
||||
{ groupe_instructeur: groupe_instructeur }
|
||||
if groupe_instructeur.update({ label:, closed: }.compact)
|
||||
{ groupe_instructeur: }
|
||||
else
|
||||
{ errors: groupe_instructeur.errors.full_messages }
|
||||
end
|
||||
|
|
|
@ -844,7 +844,7 @@ class Dossier < ApplicationRecord
|
|||
.processed_at
|
||||
save!
|
||||
|
||||
if !procedure.declarative_accepte? && !disable_notification
|
||||
if !disable_notification
|
||||
NotificationMailer.send_en_instruction_notification(self).deliver_later
|
||||
end
|
||||
log_dossier_operation(instructeur, :passer_en_instruction)
|
||||
|
@ -857,10 +857,14 @@ class Dossier < ApplicationRecord
|
|||
.passer_en_instruction
|
||||
.processed_at
|
||||
save!
|
||||
|
||||
NotificationMailer.send_en_instruction_notification(self).deliver_later
|
||||
log_automatic_dossier_operation(:passer_en_instruction)
|
||||
end
|
||||
|
||||
def after_repasser_en_construction(instructeur)
|
||||
def after_repasser_en_construction(h)
|
||||
instructeur = h[:instructeur]
|
||||
|
||||
create_missing_traitemets
|
||||
|
||||
self.en_construction_close_to_expiration_notice_sent_at = nil
|
||||
|
|
|
@ -493,7 +493,7 @@ describe Dossier do
|
|||
it 'should keep first en_construction_at date' do
|
||||
Timecop.return
|
||||
dossier.passer_en_instruction!(instructeur: instructeur)
|
||||
dossier.repasser_en_construction!(instructeur)
|
||||
dossier.repasser_en_construction!(instructeur: instructeur)
|
||||
|
||||
expect(dossier.traitements.size).to eq(3)
|
||||
expect(dossier.traitements.first.processed_at).to eq(beginning_of_day)
|
||||
|
@ -519,7 +519,7 @@ describe Dossier do
|
|||
|
||||
it 'should keep first en_instruction_at date if dossier is set to en_construction again' do
|
||||
Timecop.return
|
||||
dossier.repasser_en_construction!(instructeur)
|
||||
dossier.repasser_en_construction!(instructeur: instructeur)
|
||||
dossier.passer_en_instruction!(instructeur: instructeur)
|
||||
|
||||
expect(dossier.traitements.size).to eq(4)
|
||||
|
|
Loading…
Add table
Reference in a new issue