Merge pull request #5946 from tchak/routage-with-api

Implementer le feature flag pour permettre le routage via l'API
This commit is contained in:
Paul Chavard 2021-03-04 11:20:40 +01:00 committed by GitHub
commit f2e9b04f99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 35 additions and 20 deletions

View file

@ -67,10 +67,6 @@ class ApplicationController < ActionController::Base
Flipper.enabled?(feature_name, current_user) Flipper.enabled?(feature_name, current_user)
end end
def feature_enabled_for?(feature_name, item)
Flipper.enabled?(feature_name, item)
end
def authenticate_logged_user! def authenticate_logged_user!
if instructeur_signed_in? if instructeur_signed_in?
authenticate_instructeur! authenticate_instructeur!

View file

@ -72,7 +72,7 @@ module Instructeurs
def create_avis def create_avis
@procedure = Procedure.find(params[:procedure_id]) @procedure = Procedure.find(params[:procedure_id])
if !feature_enabled_for?(:expert_not_allowed_to_invite, @procedure) if !@procedure.feature_enabled?(:expert_not_allowed_to_invite)
@new_avis = create_avis_from_params(avis.dossier, avis.confidentiel) @new_avis = create_avis_from_params(avis.dossier, avis.confidentiel)
if @new_avis.nil? if @new_avis.nil?

View file

@ -2,8 +2,4 @@ module FlipperHelper
def feature_enabled?(feature_name) def feature_enabled?(feature_name)
Flipper.enabled?(feature_name, current_user) Flipper.enabled?(feature_name, current_user)
end end
def feature_enabled_for?(feature_name, item)
Flipper.enabled?(feature_name, item)
end
end end

View file

@ -418,6 +418,14 @@ class Dossier < ApplicationRecord
Dossier.en_construction_close_to_expiration.where(id: self).present? Dossier.en_construction_close_to_expiration.where(id: self).present?
end end
def show_groupe_instructeur_details?
procedure.routee? && (!procedure.feature_enabled?(:procedure_routage_api) || !defaut_groupe_instructeur?)
end
def show_groupe_instructeur_selector?
procedure.routee? && !procedure.feature_enabled?(:procedure_routage_api)
end
def assign_to_groupe_instructeur(groupe_instructeur, author = nil) def assign_to_groupe_instructeur(groupe_instructeur, author = nil)
if groupe_instructeur.procedure == procedure && groupe_instructeur != self.groupe_instructeur if groupe_instructeur.procedure == procedure && groupe_instructeur != self.groupe_instructeur
if update(groupe_instructeur: groupe_instructeur, groupe_instructeur_updated_at: Time.zone.now) if update(groupe_instructeur: groupe_instructeur, groupe_instructeur_updated_at: Time.zone.now)
@ -832,6 +840,10 @@ class Dossier < ApplicationRecord
private private
def defaut_groupe_instructeur?
groupe_instructeur == procedure.defaut_groupe_instructeur
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.includes(:geo_areas).flat_map(&:geo_areas) + champs_private.includes(:geo_areas).flat_map(&:geo_areas)
end end

View file

@ -342,6 +342,10 @@ class Procedure < ApplicationRecord
end end
end end
def feature_enabled?(feature)
Flipper.enabled?(feature, self)
end
# Warning: dossier after_save build_default_champs must be removed # Warning: dossier after_save build_default_champs must be removed
# to save a dossier created from this method # to save a dossier created from this method
def new_dossier def new_dossier

View file

@ -41,7 +41,7 @@
= link_to 'Voir mes dossiers en cours', dossiers_path, class: ['button large expand primary'] = link_to 'Voir mes dossiers en cours', dossiers_path, class: ['button large expand primary']
= link_to 'Commencer un nouveau dossier', url_for_new_dossier(@procedure), class: ['button large expand'] = link_to 'Commencer un nouveau dossier', url_for_new_dossier(@procedure), class: ['button large expand']
- if feature_enabled_for?(:dossier_pdf_vide, @procedure) - if @procedure.feature_enabled?(:dossier_pdf_vide)
- pdf_link = commencer_dossier_vide_path(path: @procedure.path) - pdf_link = commencer_dossier_vide_path(path: @procedure.path)
- if @procedure.brouillon? - if @procedure.brouillon?
- pdf_link = commencer_dossier_vide_test_path(path: @procedure.path) - pdf_link = commencer_dossier_vide_test_path(path: @procedure.path)

View file

@ -31,7 +31,7 @@
.send-wrapper .send-wrapper
= f.submit 'Envoyer votre avis', class: 'button send' = f.submit 'Envoyer votre avis', class: 'button send'
- if !@dossier.termine? && !feature_enabled_for?(:expert_not_allowed_to_invite, @avis.procedure) - if !@dossier.termine? && !@avis.procedure.feature_enabled?(:expert_not_allowed_to_invite)
= render partial: "instructeurs/shared/avis/form", locals: { url: avis_instructeur_avis_path(@avis.procedure, @avis), linked_dossiers: @dossier.linked_dossiers_for(current_instructeur), must_be_confidentiel: @avis.confidentiel?, avis: @new_avis } = render partial: "instructeurs/shared/avis/form", locals: { url: avis_instructeur_avis_path(@avis.procedure, @avis), linked_dossiers: @dossier.linked_dossiers_for(current_instructeur), must_be_confidentiel: @avis.confidentiel?, avis: @new_avis }
- if @dossier.avis_for(current_instructeur).present? - if @dossier.avis_for(current_instructeur).present?

View file

@ -5,10 +5,10 @@
-# only display the coronavirus to usagers (instructeurs know there are delays) when they are logged in, or on the public pages. -# only display the coronavirus to usagers (instructeurs know there are delays) when they are logged in, or on the public pages.
- if user_signed_in? - if user_signed_in?
- if dossier.present? && feature_enabled_for?(:coronavirus_banner, dossier.procedure) - if dossier.present? && dossier.procedure.feature_enabled?(:coronavirus_banner)
= render partial: 'layouts/coronavirus_banner' = render partial: 'layouts/coronavirus_banner'
- else - else
- if procedure.present? && feature_enabled_for?(:coronavirus_banner, procedure) - if procedure.present? && procedure.feature_enabled?(:coronavirus_banner)
= render partial: 'layouts/coronavirus_banner' = render partial: 'layouts/coronavirus_banner'
%header.new-header{ class: current_page?(root_path) ? nil : "new-header-with-border", role: 'banner' } %header.new-header{ class: current_page?(root_path) ? nil : "new-header-with-border", role: 'banner' }

View file

@ -10,7 +10,7 @@
%thead %thead
%tr %tr
%th Liste des experts %th Liste des experts
- if feature_enabled_for?(:make_experts_notifiable, @procedure) - if @procedure.feature_enabled?(:make_experts_notifiable)
%th Notifier des décisions sur les dossiers %th Notifier des décisions sur les dossiers
%tbody %tbody
- @experts_procedure.each do |expert_procedure| - @experts_procedure.each do |expert_procedure|
@ -18,7 +18,7 @@
%td %td
%span.icon.person %span.icon.person
= expert_procedure.expert.email = expert_procedure.expert.email
- if feature_enabled_for?(:make_experts_notifiable, @procedure) - if @procedure.feature_enabled?(:make_experts_notifiable)
%td %td
= form_for expert_procedure, = form_for expert_procedure,
url: admin_procedure_update_allow_decision_access_path(expert_procedure: expert_procedure), url: admin_procedure_update_allow_decision_access_path(expert_procedure: expert_procedure),

View file

@ -1,6 +1,6 @@
%table.table.vertical.dossier-champs %table.table.vertical.dossier-champs
%tbody %tbody
- if dossier.procedure.routee? - if dossier.show_groupe_instructeur_details?
%th= dossier.procedure.routing_criteria_name %th= dossier.procedure.routing_criteria_name
%td{ class: highlight_if_unseen_class(demande_seen_at, dossier.groupe_instructeur_updated_at) }= dossier.groupe_instructeur.label %td{ class: highlight_if_unseen_class(demande_seen_at, dossier.groupe_instructeur_updated_at) }= dossier.groupe_instructeur.label
%td.updated-at %td.updated-at

View file

@ -30,7 +30,7 @@
%hr %hr
- if dossier.procedure.routee? - if dossier.show_groupe_instructeur_selector?
= f.label :groupe_instructeur_id do = f.label :groupe_instructeur_id do
= dossier.procedure.routing_criteria_name = dossier.procedure.routing_criteria_name
%span.mandatory * %span.mandatory *

View file

@ -25,14 +25,21 @@ end
# A list of features to be deployed on first push # A list of features to be deployed on first push
features = [ features = [
:administrateur_routage,
:administrateur_web_hook, :administrateur_web_hook,
:carte_ign,
:coronavirus_banner,
:dossier_pdf_vide,
:expert_not_allowed_to_invite,
:hide_instructeur_email,
:insee_api_v3, :insee_api_v3,
:instructeur_bypass_email_login_token, :instructeur_bypass_email_login_token,
:localization,
:maintenance_mode, :maintenance_mode,
:make_experts_notifiable,
:mini_profiler, :mini_profiler,
:xray, :procedure_routage_api,
:carte_ign, :xray
:localization
] ]
def database_exists? def database_exists?