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:
commit
f2e9b04f99
12 changed files with 35 additions and 20 deletions
|
@ -67,10 +67,6 @@ class ApplicationController < ActionController::Base
|
|||
Flipper.enabled?(feature_name, current_user)
|
||||
end
|
||||
|
||||
def feature_enabled_for?(feature_name, item)
|
||||
Flipper.enabled?(feature_name, item)
|
||||
end
|
||||
|
||||
def authenticate_logged_user!
|
||||
if instructeur_signed_in?
|
||||
authenticate_instructeur!
|
||||
|
|
|
@ -72,7 +72,7 @@ module Instructeurs
|
|||
|
||||
def create_avis
|
||||
@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)
|
||||
|
||||
if @new_avis.nil?
|
||||
|
|
|
@ -2,8 +2,4 @@ module FlipperHelper
|
|||
def feature_enabled?(feature_name)
|
||||
Flipper.enabled?(feature_name, current_user)
|
||||
end
|
||||
|
||||
def feature_enabled_for?(feature_name, item)
|
||||
Flipper.enabled?(feature_name, item)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -418,6 +418,14 @@ class Dossier < ApplicationRecord
|
|||
Dossier.en_construction_close_to_expiration.where(id: self).present?
|
||||
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)
|
||||
if groupe_instructeur.procedure == procedure && groupe_instructeur != self.groupe_instructeur
|
||||
if update(groupe_instructeur: groupe_instructeur, groupe_instructeur_updated_at: Time.zone.now)
|
||||
|
@ -832,6 +840,10 @@ class Dossier < ApplicationRecord
|
|||
|
||||
private
|
||||
|
||||
def defaut_groupe_instructeur?
|
||||
groupe_instructeur == procedure.defaut_groupe_instructeur
|
||||
end
|
||||
|
||||
def geo_areas
|
||||
champs.includes(:geo_areas).flat_map(&:geo_areas) + champs_private.includes(:geo_areas).flat_map(&:geo_areas)
|
||||
end
|
||||
|
|
|
@ -342,6 +342,10 @@ class Procedure < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def feature_enabled?(feature)
|
||||
Flipper.enabled?(feature, self)
|
||||
end
|
||||
|
||||
# Warning: dossier after_save build_default_champs must be removed
|
||||
# to save a dossier created from this method
|
||||
def new_dossier
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
= 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']
|
||||
|
||||
- if feature_enabled_for?(:dossier_pdf_vide, @procedure)
|
||||
- if @procedure.feature_enabled?(:dossier_pdf_vide)
|
||||
- pdf_link = commencer_dossier_vide_path(path: @procedure.path)
|
||||
- if @procedure.brouillon?
|
||||
- pdf_link = commencer_dossier_vide_test_path(path: @procedure.path)
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
.send-wrapper
|
||||
= 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 }
|
||||
|
||||
- if @dossier.avis_for(current_instructeur).present?
|
||||
|
|
|
@ -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.
|
||||
- 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'
|
||||
- else
|
||||
- if procedure.present? && feature_enabled_for?(:coronavirus_banner, procedure)
|
||||
- if procedure.present? && procedure.feature_enabled?(:coronavirus_banner)
|
||||
= render partial: 'layouts/coronavirus_banner'
|
||||
|
||||
%header.new-header{ class: current_page?(root_path) ? nil : "new-header-with-border", role: 'banner' }
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
%thead
|
||||
%tr
|
||||
%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
|
||||
%tbody
|
||||
- @experts_procedure.each do |expert_procedure|
|
||||
|
@ -18,7 +18,7 @@
|
|||
%td
|
||||
%span.icon.person
|
||||
= expert_procedure.expert.email
|
||||
- if feature_enabled_for?(:make_experts_notifiable, @procedure)
|
||||
- if @procedure.feature_enabled?(:make_experts_notifiable)
|
||||
%td
|
||||
= form_for expert_procedure,
|
||||
url: admin_procedure_update_allow_decision_access_path(expert_procedure: expert_procedure),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
%table.table.vertical.dossier-champs
|
||||
%tbody
|
||||
- if dossier.procedure.routee?
|
||||
- if dossier.show_groupe_instructeur_details?
|
||||
%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.updated-at
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
%hr
|
||||
|
||||
- if dossier.procedure.routee?
|
||||
- if dossier.show_groupe_instructeur_selector?
|
||||
= f.label :groupe_instructeur_id do
|
||||
= dossier.procedure.routing_criteria_name
|
||||
%span.mandatory *
|
||||
|
|
|
@ -25,14 +25,21 @@ end
|
|||
|
||||
# A list of features to be deployed on first push
|
||||
features = [
|
||||
:administrateur_routage,
|
||||
:administrateur_web_hook,
|
||||
:carte_ign,
|
||||
:coronavirus_banner,
|
||||
:dossier_pdf_vide,
|
||||
:expert_not_allowed_to_invite,
|
||||
:hide_instructeur_email,
|
||||
:insee_api_v3,
|
||||
:instructeur_bypass_email_login_token,
|
||||
:localization,
|
||||
:maintenance_mode,
|
||||
:make_experts_notifiable,
|
||||
:mini_profiler,
|
||||
:xray,
|
||||
:carte_ign,
|
||||
:localization
|
||||
:procedure_routage_api,
|
||||
:xray
|
||||
]
|
||||
|
||||
def database_exists?
|
||||
|
|
Loading…
Reference in a new issue