From 71973de17cef37291ee2d1568a65df622a227dda Mon Sep 17 00:00:00 2001 From: kara Diaby Date: Mon, 22 Mar 2021 10:02:38 +0100 Subject: [PATCH 1/8] remove useless columns from the db --- app/models/avis.rb | 23 ++--------------------- db/schema.rb | 2 +- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/app/models/avis.rb b/app/models/avis.rb index bbb9e462c..e9b0aaaff 100644 --- a/app/models/avis.rb +++ b/app/models/avis.rb @@ -9,7 +9,7 @@ # email :string # introduction :text # revoked_at :datetime -# tmp_expert_migrated :boolean default(FALSE) +# tmp_expert_migrated :boolean default(FALSE) # created_at :datetime not null # updated_at :datetime not null # claimant_id :integer not null @@ -57,26 +57,7 @@ class Avis < ApplicationRecord attr_accessor :emails attr_accessor :invite_linked_dossiers - def claimant - claimant_id = read_attribute(:claimant_id) - claimant_type = read_attribute(:claimant_type) - if claimant_type == 'Instructeur' || !tmp_expert_migrated - Instructeur.find(claimant_id) - else - Expert.find(claimant_id) - end - end - - def claimant=(claimant) - self.claimant_id = claimant.id - - if claimant.is_a? Instructeur - self.claimant_type = 'Instructeur' - else - self.claimant_type = 'Expert' - self.tmp_expert_migrated = true - end - end + self.ignored_columns = [:instructeur_id, :tmp_expert_migrated] def email_to_display expert&.email diff --git a/db/schema.rb b/db/schema.rb index be8f20e8a..6637fb0d9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -123,7 +123,7 @@ ActiveRecord::Schema.define(version: 2021_03_11_141956) do t.datetime "revoked_at" t.bigint "experts_procedure_id" t.string "claimant_type" - t.boolean "tmp_expert_migrated", default: false + t.boolean "tmp_expert_migrated" t.index ["claimant_id"], name: "index_avis_on_claimant_id" t.index ["dossier_id"], name: "index_avis_on_dossier_id" t.index ["experts_procedure_id"], name: "index_avis_on_experts_procedure_id" From fe7fb882c84f4c079b105d947a2c9126badf4c4f Mon Sep 17 00:00:00 2001 From: kara Diaby Date: Mon, 22 Mar 2021 10:03:37 +0100 Subject: [PATCH 2/8] remove useless routes --- config/routes.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 049667606..2490cc07a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -320,8 +320,6 @@ Rails.application.routes.draw do # scope module: 'instructeurs', as: 'instructeur' do - get 'avis', to: 'avis#index', as: 'all_avis' - # this redirections are ephemeral, to ensure that emails sent to experts before are still valid # TODO : they will be removed in September, 2020 get 'avis/:id', to: redirect('/procedures/old/avis/%{id}') @@ -339,12 +337,8 @@ Rails.application.routes.draw do resources :avis, only: [:show, :update] do get '', action: 'procedure', on: :collection, as: :procedure member do - get 'messagerie' - post 'commentaire' => 'avis#create_commentaire' - post 'avis' => 'avis#create_avis' patch 'revoquer' get 'revive' - get 'bilans_bdf' end end From 2930de1015dd93c1bd208915a3e012c2d8c7206f Mon Sep 17 00:00:00 2001 From: kara Diaby Date: Mon, 22 Mar 2021 10:05:04 +0100 Subject: [PATCH 3/8] remove useless code in models --- app/models/avis.rb | 5 ++--- app/models/instructeur.rb | 2 -- app/services/dossier_search_service.rb | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/models/avis.rb b/app/models/avis.rb index e9b0aaaff..8d52d9bf6 100644 --- a/app/models/avis.rb +++ b/app/models/avis.rb @@ -9,7 +9,7 @@ # email :string # introduction :text # revoked_at :datetime -# tmp_expert_migrated :boolean default(FALSE) +# tmp_expert_migrated :boolean default(FALSE) # created_at :datetime not null # updated_at :datetime not null # claimant_id :integer not null @@ -21,9 +21,8 @@ class Avis < ApplicationRecord include EmailSanitizableConcern belongs_to :dossier, inverse_of: :avis, touch: true, optional: false - belongs_to :instructeur, optional: true belongs_to :experts_procedure, optional: false - belongs_to :claimant, class_name: 'Instructeur', optional: false + belongs_to :claimant, polymorphic: true, optional: false has_one_attached :piece_justificative_file has_one_attached :introduction_file diff --git a/app/models/instructeur.rb b/app/models/instructeur.rb index 4d340f058..09733ffaf 100644 --- a/app/models/instructeur.rb +++ b/app/models/instructeur.rb @@ -23,8 +23,6 @@ class Instructeur < ApplicationRecord has_many :previous_follows, -> { inactive }, class_name: 'Follow', inverse_of: :instructeur has_many :followed_dossiers, through: :follows, source: :dossier has_many :previously_followed_dossiers, -> { distinct }, through: :previous_follows, source: :dossier - has_many :avis - has_many :dossiers_from_avis, through: :avis, source: :dossier has_many :trusted_device_tokens, dependent: :destroy has_one :user, dependent: :nullify diff --git a/app/services/dossier_search_service.rb b/app/services/dossier_search_service.rb index 93ac8993e..59c674fc1 100644 --- a/app/services/dossier_search_service.rb +++ b/app/services/dossier_search_service.rb @@ -21,7 +21,7 @@ class DossierSearchService end def self.dossiers_by_id(id, instructeur) - (instructeur.dossiers.where(id: id) + instructeur.dossiers_from_avis.where(id: id)).uniq + instructeur.dossiers.where(id: id).uniq end def self.id_compatible?(number) From d17fdfec774adcca4cbde027b588811d3d79bd3e Mon Sep 17 00:00:00 2001 From: kara Diaby Date: Mon, 22 Mar 2021 10:07:51 +0100 Subject: [PATCH 4/8] modify layout --- app/views/layouts/_header.haml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/layouts/_header.haml b/app/views/layouts/_header.haml index b823b60bc..c4e56e7a3 100644 --- a/app/views/layouts/_header.haml +++ b/app/views/layouts/_header.haml @@ -32,11 +32,13 @@ - if current_instructeur.procedures.count > 0 %li = active_link_to "Démarches", instructeur_procedures_path, active: ['dossiers','procedures'].include?(controller_name), class: 'tab-link' - - if current_instructeur.avis.count > 0 + - if nav_bar_profile == :expert && expert_signed_in? + - if current_expert.avis.count > 0 + %ul.header-tabs %li - = active_link_to instructeur_all_avis_path, active: controller_name == 'avis', class: 'tab-link' do + = active_link_to expert_all_avis_path, active: controller_name == 'avis', class: 'tab-link' do Avis - - avis_counter = current_instructeur.avis.without_answer.count + - avis_counter = current_expert.avis.without_answer.count - if avis_counter > 0 %span.badge.warning= avis_counter From fff6725799e0421ada21542026ebe297604cb9c0 Mon Sep 17 00:00:00 2001 From: kara Diaby Date: Mon, 22 Mar 2021 10:25:47 +0100 Subject: [PATCH 5/8] modify api and serializer --- app/graphql/schema.graphql | 3 ++- app/graphql/types/avis_type.rb | 3 ++- app/graphql/types/dossier_type.rb | 4 ++-- app/services/serializer_service.rb | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index 25d372289..c81a8d142 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -113,11 +113,12 @@ type Association { type Avis { attachment: File + claimant: Profile dateQuestion: ISO8601DateTime! dateReponse: ISO8601DateTime expert: Profile id: ID! - instructeur: Profile! + instructeur: Profile! @deprecated(reason: "Utilisez le champ claimant à la place.") question: String! reponse: String } diff --git a/app/graphql/types/avis_type.rb b/app/graphql/types/avis_type.rb index de29a8e19..b9c282758 100644 --- a/app/graphql/types/avis_type.rb +++ b/app/graphql/types/avis_type.rb @@ -11,7 +11,8 @@ module Types { Extensions::Attachment => { attachment: :piece_justificative_file } } ] - field :instructeur, Types::ProfileType, null: false, method: :claimant + field :instructeur, Types::ProfileType, null: false, method: :claimant, deprecation_reason: "Utilisez le champ claimant à la place." + field :claimant, Types::ProfileType, null: true field :expert, Types::ProfileType, null: true end end diff --git a/app/graphql/types/dossier_type.rb b/app/graphql/types/dossier_type.rb index 7eecf2b18..9d611166d 100644 --- a/app/graphql/types/dossier_type.rb +++ b/app/graphql/types/dossier_type.rb @@ -90,10 +90,10 @@ module Types def avis(id: nil) if id.present? Loaders::Record - .for(Avis, where: { dossier: object }, includes: [:instructeur, :claimant], array: true) + .for(Avis, where: { dossier: object }, includes: [:expert, :claimant], array: true) .load(ApplicationRecord.id_from_typed_id(id)) else - Loaders::Association.for(object.class, avis: [:instructeur, :claimant]).load(object) + Loaders::Association.for(object.class, avis: [:expert, :claimant]).load(object) end end diff --git a/app/services/serializer_service.rb b/app/services/serializer_service.rb index 4f3b8dabe..ef501d8e6 100644 --- a/app/services/serializer_service.rb +++ b/app/services/serializer_service.rb @@ -109,7 +109,7 @@ class SerializerService reponse dateQuestion dateReponse - instructeur { + claimant { email } expert { From 18f89b0d837a47aa751ccdac830173c514486c9f Mon Sep 17 00:00:00 2001 From: kara Diaby Date: Wed, 24 Mar 2021 16:43:01 +0100 Subject: [PATCH 6/8] adjust tests --- spec/models/dossier_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index d904cf131..d9189944d 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -345,9 +345,9 @@ describe Dossier do end context 'when they are a lot of advice' do - let!(:avis_1) { create(:avis, dossier: dossier, claimant: expert_1, experts_procedure: experts_procedure_2, confidentiel: false, created_at: Time.zone.parse('10/01/2010'), tmp_expert_migrated: true) } - let!(:avis_2) { create(:avis, dossier: dossier, claimant: expert_1, experts_procedure: experts_procedure_2, confidentiel: false, created_at: Time.zone.parse('9/01/2010'), tmp_expert_migrated: true) } - let!(:avis_3) { create(:avis, dossier: dossier, claimant: expert_1, experts_procedure: experts_procedure_2, confidentiel: false, created_at: Time.zone.parse('11/01/2010'), tmp_expert_migrated: true) } + let!(:avis_1) { create(:avis, dossier: dossier, claimant: expert_1, experts_procedure: experts_procedure_2, confidentiel: false, created_at: Time.zone.parse('10/01/2010')) } + let!(:avis_2) { create(:avis, dossier: dossier, claimant: expert_1, experts_procedure: experts_procedure_2, confidentiel: false, created_at: Time.zone.parse('9/01/2010')) } + let!(:avis_3) { create(:avis, dossier: dossier, claimant: expert_1, experts_procedure: experts_procedure_2, confidentiel: false, created_at: Time.zone.parse('11/01/2010')) } it { expect(dossier.avis_for_instructeur(instructeur)).to match([avis_2, avis_1, avis_3]) } it { expect(dossier.avis_for_expert(expert_1)).to match([avis_2, avis_1, avis_3]) } From 2165b5bcc64450959bdc07d3172c64808a3171f6 Mon Sep 17 00:00:00 2001 From: kara Diaby Date: Thu, 25 Mar 2021 11:48:19 +0100 Subject: [PATCH 7/8] fix tmp expert migrated on schema --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index 6637fb0d9..be8f20e8a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -123,7 +123,7 @@ ActiveRecord::Schema.define(version: 2021_03_11_141956) do t.datetime "revoked_at" t.bigint "experts_procedure_id" t.string "claimant_type" - t.boolean "tmp_expert_migrated" + t.boolean "tmp_expert_migrated", default: false t.index ["claimant_id"], name: "index_avis_on_claimant_id" t.index ["dossier_id"], name: "index_avis_on_dossier_id" t.index ["experts_procedure_id"], name: "index_avis_on_experts_procedure_id" From 8dce3e5d2aca61413c94b1619bb049a11e82c2aa Mon Sep 17 00:00:00 2001 From: lydiasan <> Date: Wed, 17 Mar 2021 09:43:44 +0100 Subject: [PATCH 8/8] i18n: localize users/sign_in page --- .../layouts/commencer/_no_procedure.html.haml | 6 +++--- app/views/users/sessions/new.html.haml | 16 +++++++------- config/locales/en.yml | 21 ++++++++++++++----- config/locales/fr.yml | 21 ++++++++++++++----- config/locales/views/shared/en.yml | 9 ++++++++ 5 files changed, 52 insertions(+), 21 deletions(-) create mode 100644 config/locales/views/shared/en.yml diff --git a/app/views/layouts/commencer/_no_procedure.html.haml b/app/views/layouts/commencer/_no_procedure.html.haml index 8394cd9f9..cc6dd73c5 100644 --- a/app/views/layouts/commencer/_no_procedure.html.haml +++ b/app/views/layouts/commencer/_no_procedure.html.haml @@ -2,8 +2,8 @@ = image_tag "landing/hero/dematerialiser.svg", class: "paperless-logo", alt: "moins de papier" .baseline.center %p - %span.simple Un outil simple + %span.simple= t('views.commencer.no_procedure.ligne1') %br - pour gérer les formulaires + = t('views.commencer.no_procedure.ligne2') %br - administratifs dématérialisés. + = t('views.commencer.no_procedure.ligne3') diff --git a/app/views/users/sessions/new.html.haml b/app/views/users/sessions/new.html.haml index 5305f9e8d..5dc8a35d4 100644 --- a/app/views/users/sessions/new.html.haml +++ b/app/views/users/sessions/new.html.haml @@ -3,29 +3,29 @@ .auth-form.sign-in-form = form_for User.new, url: user_session_path, html: { class: "form" } do |f| - %h1.huge-title Connectez-vous + %h1.huge-title= t('views.sessions.new.title') = render partial: 'shared/france_connect_login', locals: { url: france_connect_particulier_path } - = f.label :email, "Email (nom@site.com)" + = f.label :email, t('views.sessions.new.email') = f.text_field :email, type: :email, autocomplete: 'username', autofocus: true - = f.label :password, "Mot de passe (#{PASSWORD_MIN_LENGTH} caractères minimum)" + = f.label :password, t('views.sessions.new.password', min_length: PASSWORD_MIN_LENGTH) = f.password_field :password, autocomplete: 'current-password' .auth-options %div = f.check_box :remember_me - = f.label :remember_me, "Se souvenir de moi", class: 'remember-me' + = f.label :remember_me, t('views.sessions.new.remember_me'), class: 'remember-me' .text-right - = link_to "Mot de passe oublié ?", new_user_password_path, class: "link" + = link_to t('views.sessions.new.reset_password'), new_user_password_path, class: "link" - = f.submit "Se connecter", class: "button large primary expand" + = f.submit t('views.sessions.new.connection'), class: "button large primary expand" %hr %p.center - %span Vous êtes nouveau sur #{APPLICATION_NAME.gsub("-","‑").html_safe} ? + %span= t('views.sessions.new.are_you_new', app_name: APPLICATION_NAME.gsub("-","‑")).html_safe %br %br - = link_to "Trouvez votre démarche", COMMENT_TROUVER_MA_DEMARCHE_URL, target: "_blank", class: "button expend secondary" + = link_to t('views.sessions.new.find_procedure'), COMMENT_TROUVER_MA_DEMARCHE_URL, target: "_blank", class: "button expend secondary" diff --git a/config/locales/en.yml b/config/locales/en.yml index c1bcac742..fc9d6d678 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -35,7 +35,21 @@ en: previous: Previous first: First truncate: '…' - + sessions: + new: + title: Sign in + email: Email address (name@site.com) + password: Password (minimum length %{min_length} characters) + remember_me: Remember me + reset_password: Forgot password? + connection: Sign in + are_you_new: First time on %{app_name} ? + find_procedure: Find your procedure + commencer: + no_procedure: + ligne1: A simple tool + ligne2: to manage dematerialized + ligne3: administrative forms. modal: publish: title: @@ -47,7 +61,6 @@ en: submit: publish: Publish reopen: Reopen - activerecord: attributes: user: @@ -91,7 +104,6 @@ en: taken: is already used for procedure. You cannot use it because it belongs to another administrator. # taken_can_be_claimed: est identique à celui d’une autre de vos procedures publiées. Si vous publiez cette procedure, l’ancienne sera dépubliée et ne sera plus accessible au public. Les utilisateurs qui ont commencé un brouillon vont pouvoir le déposer. invalid: is not valid. It must countain between 3 and 50 characters among a-z, 0-9, '_' and '-'. - errors: messages: dossier_not_found: "The file does not exist or you do not have access to it." @@ -111,7 +123,6 @@ en: # other: "Aucune parcelle cadastrale sur les zones sélectionnées" not_an_integer: "must be an integer (without decimal)" blank: "can't be blank" - time: formats: default: "%B %d %Y %R" @@ -151,4 +162,4 @@ en: draft: zero: Draft one: Draft - other: Drafts + other: Drafts \ No newline at end of file diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 397819ef1..275d95b56 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -35,7 +35,21 @@ fr: previous: Précédent first: Premier truncate: '…' - + sessions: + new: + title: Connectez-vous + email: Email (nom@site.com) + password: Mot de passe (%{min_length} caractères minimum) + remember_me: Se souvenir de moi + reset_password: Mot de passe oublié ? + connection: Se connecter + are_you_new: Vous êtes nouveau sur %{app_name} ? + find_procedure: Trouvez votre démarche + commencer: + no_procedure: + ligne1: Un outil simple + ligne2: pour gérer les formulaires + ligne3: administratifs dématérialisés. modal: publish: title: @@ -47,7 +61,6 @@ fr: submit: publish: Publier reopen: Réactiver - activerecord: attributes: default_attributes: &default_attributes @@ -100,7 +113,6 @@ fr: taken: est déjà utilisé par une démarche. Vous ne pouvez pas l’utiliser car il appartient à un autre administrateur. taken_can_be_claimed: est identique à celui d’une autre de vos démarches publiées. Si vous publiez cette démarche, l’ancienne sera dépubliée et ne sera plus accessible au public. Les utilisateurs qui ont commencé un brouillon vont pouvoir le déposer. invalid: n’est pas valide. Il doit comporter au moins 3 caractères, au plus 50 caractères et seuls les caractères a-z, 0-9, '_' et '-' sont autorisés. - errors: messages: saml_not_authorized: "Vous n'êtes pas autorisé à accéder à ce service." @@ -122,7 +134,6 @@ fr: other: "Aucune parcelle cadastrale sur les zones sélectionnées" not_an_integer: "doit être un nombre entier (sans chiffres après la virgule)" blank: "doit être rempli" - time: formats: default: "%d %B %Y %R" @@ -174,4 +185,4 @@ fr: draft: zero: Brouillon one: Brouillon - other: Brouillons + other: Brouillons \ No newline at end of file diff --git a/config/locales/views/shared/en.yml b/config/locales/views/shared/en.yml new file mode 100644 index 000000000..b4c087c37 --- /dev/null +++ b/config/locales/views/shared/en.yml @@ -0,0 +1,9 @@ +en: + views: + shared: + france_connect_login: + title: "With FranceConnect" + description: "France connect is a solution proposed by the government to secure and simplify the connection to web services." + login_button: "Sign in with FranceConnect" + help_link: What is FranceConnect ? + separator: or \ No newline at end of file