From 13ab3b465e893d5d274493ec7f144023556c5836 Mon Sep 17 00:00:00 2001 From: pedong Date: Fri, 21 Feb 2020 11:29:17 +0100 Subject: [PATCH 1/5] add groupe_instructeur in dossier_type --- app/graphql/schema.graphql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index 15cdb6803..6ae3e2e90 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -1190,4 +1190,4 @@ type ValidationError { A description of the error """ message: String! -} \ No newline at end of file +} From 62f82cc83cb6fdb0f7bf7c815038976996885bc6 Mon Sep 17 00:00:00 2001 From: pedong Date: Fri, 21 Feb 2020 11:57:36 +0100 Subject: [PATCH 2/5] add dossierChangerGroupeInstructeur mutation --- app/graphql/api/v2/schema.rb | 2 + .../dossier_changer_groupe_instructeur.rb | 26 ++++++++++ app/graphql/schema.graphql | 39 ++++++++++++++- app/graphql/types/mutation_type.rb | 1 + .../api/v2/graphql_controller_spec.rb | 47 +++++++++++++++++++ 5 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 app/graphql/mutations/dossier_changer_groupe_instructeur.rb diff --git a/app/graphql/api/v2/schema.rb b/app/graphql/api/v2/schema.rb index 10b1bfa13..777f08014 100644 --- a/app/graphql/api/v2/schema.rb +++ b/app/graphql/api/v2/schema.rb @@ -30,6 +30,8 @@ class Api::V2::Schema < GraphQL::Schema Types::PersonnePhysiqueType when Etablissement Types::PersonneMoraleType + when GroupeInstructeur + Types::GroupeInstructeurType else raise GraphQL::ExecutionError.new("Unexpected object: #{obj}") end diff --git a/app/graphql/mutations/dossier_changer_groupe_instructeur.rb b/app/graphql/mutations/dossier_changer_groupe_instructeur.rb new file mode 100644 index 000000000..ccb2ca906 --- /dev/null +++ b/app/graphql/mutations/dossier_changer_groupe_instructeur.rb @@ -0,0 +1,26 @@ +module Mutations + class DossierChangerGroupeInstructeur < Mutations::BaseMutation + include DossierHelper + + description "Changer le grope instructeur du dossier." + + argument :dossier_id, ID, "Dossier ID", required: true, loads: Types::DossierType + argument :groupe_instructeur_id, ID, "Group instructeur a affecter", required: true, loads: Types::GroupeInstructeurType + + field :dossier, Types::DossierType, null: true + field :errors, [Types::ValidationErrorType], null: true + + def resolve(dossier:, groupe_instructeur:) + if dossier.groupe_instructeur == groupe_instructeur + { errors: ["Le dossier est déjà avec le grope instructeur: '#{groupe_instructeur.label}'"] } + else + dossier.update!(groupe_instructeur: groupe_instructeur) + { dossier: dossier } + end + end + + def authorized?(dossier:, groupe_instructeur:) + dossier.groupe_instructeur.procedure == groupe_instructeur.procedure + end + end +end diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index 6ae3e2e90..7558a5f8b 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -438,6 +438,38 @@ type DossierAccepterPayload { errors: [ValidationError!] } +""" +Autogenerated input type of DossierChangerGroupeInstructeur +""" +input DossierChangerGroupeInstructeurInput { + """ + A unique identifier for the client performing the mutation. + """ + clientMutationId: String + + """ + Dossier ID + """ + dossierId: ID! + + """ + Group instructeur a affecter + """ + groupeInstructeurId: ID! +} + +""" +Autogenerated return type of DossierChangerGroupeInstructeur +""" +type DossierChangerGroupeInstructeurPayload { + """ + A unique identifier for the client performing the mutation. + """ + clientMutationId: String + dossier: Dossier + errors: [ValidationError!] +} + """ Autogenerated input type of DossierClasserSansSuite """ @@ -790,6 +822,11 @@ type Mutation { """ dossierAccepter(input: DossierAccepterInput!): DossierAccepterPayload + """ + Changer le grope instructeur du dossier. + """ + dossierChangerGroupeInstructeur(input: DossierChangerGroupeInstructeurInput!): DossierChangerGroupeInstructeurPayload + """ Classer le dossier sans suite. """ @@ -1190,4 +1227,4 @@ type ValidationError { A description of the error """ message: String! -} +} \ No newline at end of file diff --git a/app/graphql/types/mutation_type.rb b/app/graphql/types/mutation_type.rb index 22ad55981..1a0e8e32f 100644 --- a/app/graphql/types/mutation_type.rb +++ b/app/graphql/types/mutation_type.rb @@ -7,5 +7,6 @@ module Types field :dossier_classer_sans_suite, mutation: Mutations::DossierClasserSansSuite field :dossier_refuser, mutation: Mutations::DossierRefuser field :dossier_accepter, mutation: Mutations::DossierAccepter + field :dossier_changer_groupe_instructeur, mutation: Mutations::DossierChangerGroupeInstructeur end end diff --git a/spec/controllers/api/v2/graphql_controller_spec.rb b/spec/controllers/api/v2/graphql_controller_spec.rb index feab5a789..57e5e4f7f 100644 --- a/spec/controllers/api/v2/graphql_controller_spec.rb +++ b/spec/controllers/api/v2/graphql_controller_spec.rb @@ -686,6 +686,53 @@ describe API::V2::GraphqlController do expect(data[:signedBlobId]).not_to be_nil end end + + describe 'dossierChangerGroupeInstructeur' do + let(:query) do + "mutation { + dossierChangerGroupeInstructeur(input: { + dossierId: \"#{dossier.to_typed_id}\", + groupeInstructeurId: \"#{dossier.groupe_instructeur.to_typed_id}\" + }) { + errors { + message + } + } + }" + end + + it "validation error" do + expect(gql_errors).to eq(nil) + + expect(gql_data).to eq(dossierChangerGroupeInstructeur: { + errors: [{ message: "Le dossier est déjà avec le grope instructeur: 'défaut'" }] + }) + end + + context "should changer groupe instructeur" do + let!(:new_groupe_instructeur) { procedure.groupe_instructeurs.create(label: 'new groupe instructeur') } + let(:query) do + "mutation { + dossierChangerGroupeInstructeur(input: { + dossierId: \"#{dossier.to_typed_id}\", + groupeInstructeurId: \"#{new_groupe_instructeur.to_typed_id}\" + }) { + errors { + message + } + } + }" + end + + it "change made" do + expect(gql_errors).to eq(nil) + + expect(gql_data).to eq(dossierChangerGroupeInstructeur: { + errors: nil + }) + end + end + end end end From 63328ffbcf33cd4863915f0c0a4b565384ff69b2 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Thu, 5 Mar 2020 11:06:45 +0100 Subject: [PATCH 3/5] fix error message during admin activation error --- app/controllers/administrateurs/activate_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/administrateurs/activate_controller.rb b/app/controllers/administrateurs/activate_controller.rb index b4bf8346d..a792b7f0a 100644 --- a/app/controllers/administrateurs/activate_controller.rb +++ b/app/controllers/administrateurs/activate_controller.rb @@ -31,7 +31,7 @@ class Administrateurs::ActivateController < ApplicationController flash.notice = "Mot de passe enregistré" redirect_to admin_procedures_path else - flash.alert = administrateur.errors.full_messages + flash.alert = user.administrateur.errors.full_messages redirect_to admin_activate_path(token: update_administrateur_params[:reset_password_token]) end end From e540dea9294b862bf8b2b962741413d45bee381f Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 5 Mar 2020 12:57:28 +0100 Subject: [PATCH 4/5] Fix administrate pagination by pinning to an old version of kaminari --- Gemfile | 2 +- Gemfile.lock | 22 +++++++++---------- .../manager/procedures_controller_spec.rb | 16 ++++++++++++++ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Gemfile b/Gemfile index d629ba148..6293849d7 100644 --- a/Gemfile +++ b/Gemfile @@ -41,7 +41,7 @@ gem 'groupdate' gem 'haml-rails' gem 'hashie' gem 'jquery-rails' # Use jquery as the JavaScript library -gem 'kaminari' # Pagination +gem 'kaminari', '= 1.1.1' # Pagination gem 'lograge' gem 'logstash-event' gem 'mailjet' diff --git a/Gemfile.lock b/Gemfile.lock index f15b8a2f4..da412fd65 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -325,18 +325,18 @@ GEM bindata jsonapi-renderer (0.2.2) jwt (2.1.0) - kaminari (1.2.0) + kaminari (1.1.1) activesupport (>= 4.1.0) - kaminari-actionview (= 1.2.0) - kaminari-activerecord (= 1.2.0) - kaminari-core (= 1.2.0) - kaminari-actionview (1.2.0) + kaminari-actionview (= 1.1.1) + kaminari-activerecord (= 1.1.1) + kaminari-core (= 1.1.1) + kaminari-actionview (1.1.1) actionview - kaminari-core (= 1.2.0) - kaminari-activerecord (1.2.0) + kaminari-core (= 1.1.1) + kaminari-activerecord (1.1.1) activerecord - kaminari-core (= 1.2.0) - kaminari-core (1.2.0) + kaminari-core (= 1.1.1) + kaminari-core (1.1.1) launchy (2.4.3) addressable (~> 2.3) letter_opener (1.7.0) @@ -384,7 +384,7 @@ GEM nenv (0.3.0) netrc (0.11.0) nio4r (2.5.2) - nokogiri (1.10.8) + nokogiri (1.10.9) mini_portile2 (~> 2.4.0) notiffany (0.1.1) nenv (~> 0.1) @@ -766,7 +766,7 @@ DEPENDENCIES haml-rails hashie jquery-rails - kaminari + kaminari (= 1.1.1) launchy letter_opener_web lograge diff --git a/spec/controllers/manager/procedures_controller_spec.rb b/spec/controllers/manager/procedures_controller_spec.rb index b546a93e6..e6a839dc7 100644 --- a/spec/controllers/manager/procedures_controller_spec.rb +++ b/spec/controllers/manager/procedures_controller_spec.rb @@ -25,4 +25,20 @@ describe Manager::ProceduresController, type: :controller do it { expect(response.body).to include('sub type de champ') } end + + describe '#index' do + render_views + + let(:administration) { create(:administration) } + let!(:dossier) { create(:dossier) } + + context 'sort by dossiers' do + before do + sign_in(administration) + get :index, params: { procedure: { direction: 'asc', order: 'dossiers' } } + end + + it { expect(response.body).to include('1 dossier') } + end + end end From 577d21de5c52c595c0cdc8be085bfba24c504382 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Fri, 13 Mar 2020 15:36:17 +0100 Subject: [PATCH 5/5] Use the new robot api id --- app/lib/pipedrive/person_adapter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lib/pipedrive/person_adapter.rb b/app/lib/pipedrive/person_adapter.rb index fe225fd33..1a874dc82 100644 --- a/app/lib/pipedrive/person_adapter.rb +++ b/app/lib/pipedrive/person_adapter.rb @@ -3,7 +3,7 @@ class Pipedrive::PersonAdapter PIPEDRIVE_SOURCE_ATTRIBUTE_ID = '2fa7864f467ffa97721cbcd08df5a3d591b15f50' PIPEDRIVE_NB_DOSSIERS_ATTRIBUTE_ID = '2734a3ff19f4b88bd0d7b4cf02c47c7545617207' PIPEDRIVE_DEADLINE_ATTRIBUTE_ID = 'ef766dd14de7da246fb5fc1704f45d1f1830f6c9' - PIPEDRIVE_ROBOT_ID = '2748449' + PIPEDRIVE_ROBOT_ID = '11381160' def self.get_demandes_from_persons_owned_by_robot Pipedrive::API.get_persons_owned_by_user(PIPEDRIVE_ROBOT_ID).map do |datum|