Merge branch 'dev'
This commit is contained in:
commit
a4d689e094
24 changed files with 270 additions and 199 deletions
3
Gemfile
3
Gemfile
|
@ -49,6 +49,9 @@ gem 'devise-async'
|
|||
gem 'openid_connect'
|
||||
gem 'omniauth-github'
|
||||
|
||||
# Locales par défaut
|
||||
gem 'rails-i18n'
|
||||
|
||||
gem 'rest-client'
|
||||
gem 'typhoeus'
|
||||
|
||||
|
|
56
Gemfile.lock
56
Gemfile.lock
|
@ -19,7 +19,7 @@ GEM
|
|||
remote: https://rubygems.org/
|
||||
specs:
|
||||
CFPropertyList (2.3.6)
|
||||
aasm (5.0.0)
|
||||
aasm (5.0.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
actioncable (5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
|
@ -209,7 +209,7 @@ GEM
|
|||
eventmachine (1.2.7)
|
||||
excon (0.62.0)
|
||||
execjs (2.7.0)
|
||||
factory_bot (4.11.0)
|
||||
factory_bot (4.11.1)
|
||||
activesupport (>= 3.0.0)
|
||||
faraday (0.12.2)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
|
@ -538,7 +538,7 @@ GEM
|
|||
parser (2.5.1.2)
|
||||
ast (~> 2.4.0)
|
||||
pdf-core (0.7.0)
|
||||
pg (1.1.2)
|
||||
pg (1.1.3)
|
||||
powerpack (0.1.2)
|
||||
prawn (2.2.2)
|
||||
pdf-core (~> 0.7.0)
|
||||
|
@ -599,6 +599,9 @@ GEM
|
|||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.0.4)
|
||||
loofah (~> 2.2, >= 2.2.2)
|
||||
rails-i18n (5.1.1)
|
||||
i18n (>= 0.7, < 2)
|
||||
railties (>= 5.0, < 6)
|
||||
railties (5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
|
@ -640,30 +643,30 @@ GEM
|
|||
activesupport (>= 3.0)
|
||||
builder (>= 3.0)
|
||||
rubyzip (>= 1.0)
|
||||
rspec (3.7.0)
|
||||
rspec-core (~> 3.7.0)
|
||||
rspec-expectations (~> 3.7.0)
|
||||
rspec-mocks (~> 3.7.0)
|
||||
rspec-core (3.7.1)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-expectations (3.7.0)
|
||||
rspec (3.8.0)
|
||||
rspec-core (~> 3.8.0)
|
||||
rspec-expectations (~> 3.8.0)
|
||||
rspec-mocks (~> 3.8.0)
|
||||
rspec-core (3.8.0)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-expectations (3.8.1)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-mocks (3.7.0)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-mocks (3.8.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-rails (3.7.2)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-rails (3.8.0)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
rspec-core (~> 3.7.0)
|
||||
rspec-expectations (~> 3.7.0)
|
||||
rspec-mocks (~> 3.7.0)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-support (3.7.1)
|
||||
rspec-core (~> 3.8.0)
|
||||
rspec-expectations (~> 3.8.0)
|
||||
rspec-mocks (~> 3.8.0)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-support (3.8.0)
|
||||
rspec_junit_formatter (0.4.1)
|
||||
rspec-core (>= 2, < 4, != 2.12.0)
|
||||
rubocop (0.58.2)
|
||||
rubocop (0.59.0)
|
||||
jaro_winkler (~> 1.5.1)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 2.5, != 2.5.1.1)
|
||||
|
@ -673,7 +676,7 @@ GEM
|
|||
unicode-display_width (~> 1.0, >= 1.0.1)
|
||||
rubocop-rspec-focused (1.0.0)
|
||||
rubocop (>= 0.51)
|
||||
ruby-progressbar (1.9.0)
|
||||
ruby-progressbar (1.10.0)
|
||||
ruby_dep (1.5.0)
|
||||
ruby_parser (3.11.0)
|
||||
sexp_processor (~> 4.9)
|
||||
|
@ -717,9 +720,9 @@ GEM
|
|||
rack (~> 2.0)
|
||||
rack-protection (= 2.0.3)
|
||||
tilt (~> 2.0)
|
||||
skylight (2.0.2)
|
||||
skylight-core (= 2.0.2)
|
||||
skylight-core (2.0.2)
|
||||
skylight (3.0.0)
|
||||
skylight-core (= 3.0.0)
|
||||
skylight-core (3.0.0)
|
||||
activesupport (>= 4.2.0)
|
||||
smart_listing (1.2.2)
|
||||
coffee-rails
|
||||
|
@ -763,7 +766,7 @@ GEM
|
|||
ethon (>= 0.9.0)
|
||||
tzinfo (1.2.5)
|
||||
thread_safe (~> 0.1)
|
||||
uglifier (4.1.18)
|
||||
uglifier (4.1.19)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
|
@ -874,6 +877,7 @@ DEPENDENCIES
|
|||
rack-mini-profiler
|
||||
rails
|
||||
rails-controller-testing
|
||||
rails-i18n
|
||||
rbnacl-libsodium
|
||||
rest-client
|
||||
rgeo-geojson
|
||||
|
@ -908,4 +912,4 @@ DEPENDENCIES
|
|||
xray-rails
|
||||
|
||||
BUNDLED WITH
|
||||
1.16.3
|
||||
1.16.4
|
||||
|
|
|
@ -45,7 +45,7 @@ class Admin::ProceduresController < AdminController
|
|||
procedure = current_administrateur.procedures.find(params[:id])
|
||||
procedure.hide!
|
||||
|
||||
flash.notice = "Démarche supprimée, en cas d'erreur #{view_context.contact_link('contactez nous', tags: 'démarche supprimée')}"
|
||||
flash.notice = "Démarche supprimée, en cas d'erreur #{helpers.contact_link('contactez nous', tags: 'démarche supprimée')}"
|
||||
redirect_to admin_procedures_draft_path
|
||||
end
|
||||
|
||||
|
@ -194,7 +194,7 @@ class Admin::ProceduresController < AdminController
|
|||
def path_list
|
||||
json_path_list = ProcedurePath
|
||||
.find_with_path(params[:request])
|
||||
.pluck(:path, :administrateur_id)
|
||||
.pluck('procedure_paths.path', :administrateur_id)
|
||||
.map do |path, administrateur_id|
|
||||
{
|
||||
label: path,
|
||||
|
|
|
@ -5,7 +5,7 @@ class Administrateurs::ActivateController < ApplicationController
|
|||
@administrateur = Administrateur.find_inactive_by_token(params[:token])
|
||||
|
||||
if !@administrateur
|
||||
flash.alert = "Le lien de validation d'administrateur a expiré, #{view_context.contact_link('contactez-nous', tags: 'lien expiré')} pour obtenir un nouveau lien."
|
||||
flash.alert = "Le lien de validation d'administrateur a expiré, #{helpers.contact_link('contactez-nous', tags: 'lien expiré')} pour obtenir un nouveau lien."
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ class Gestionnaires::ActivateController < ApplicationController
|
|||
@gestionnaire = Gestionnaire.with_reset_password_token(params[:token])
|
||||
|
||||
if !@gestionnaire
|
||||
flash.alert = "Le lien de validation du compte instructeur a expiré, #{view_context.contact_link('contactez-nous', tags: 'lien expiré')} pour obtenir un nouveau lien."
|
||||
flash.alert = "Le lien de validation du compte instructeur a expiré, #{helpers.contact_link('contactez-nous', tags: 'lien expiré')} pour obtenir un nouveau lien."
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
|
|
@ -67,10 +67,10 @@ module NewGestionnaire
|
|||
@archived_dossiers
|
||||
end
|
||||
|
||||
sorted_ids = sorted_ids(@dossiers)
|
||||
sorted_ids = DossierFieldService.sorted_ids(@dossiers, procedure_presentation, current_gestionnaire)
|
||||
|
||||
if @current_filters.count > 0
|
||||
filtered_ids = filtered_ids(@dossiers)
|
||||
filtered_ids = DossierFieldService.filtered_ids(@dossiers, current_filters)
|
||||
filtered_sorted_ids = sorted_ids.select { |id| filtered_ids.include?(id) }
|
||||
else
|
||||
filtered_sorted_ids = sorted_ids
|
||||
|
@ -217,81 +217,6 @@ module NewGestionnaire
|
|||
end
|
||||
end
|
||||
|
||||
def filtered_ids(dossiers)
|
||||
current_filters.map do |filter|
|
||||
case filter['table']
|
||||
when 'self'
|
||||
dossiers.where("? ILIKE ?", filter['column'], "%#{filter['value']}%")
|
||||
|
||||
when 'france_connect_information'
|
||||
dossiers
|
||||
.includes(user: :france_connect_information)
|
||||
.where("? ILIKE ?", "france_connect_informations.#{filter['column']}", "%#{filter['value']}%")
|
||||
|
||||
when 'type_de_champ', 'type_de_champ_private'
|
||||
relation = filter['table'] == 'type_de_champ' ? :champs : :champs_private
|
||||
dossiers
|
||||
.includes(relation)
|
||||
.where("champs.type_de_champ_id = ?", filter['column'].to_i)
|
||||
.where("champs.value ILIKE ?", "%#{filter['value']}%")
|
||||
when 'entreprise'
|
||||
table = 'etablissement'
|
||||
if filter['column'] == 'date_creation'
|
||||
date = filter['value'].to_date rescue nil
|
||||
dossiers
|
||||
.includes(table)
|
||||
.where("#{table.pluralize}.entreprise_#{filter['column']} = ?", date)
|
||||
else
|
||||
dossiers
|
||||
.includes(table)
|
||||
.where("#{table.pluralize}.entreprise_#{filter['column']} ILIKE ?", "%#{filter['value']}%")
|
||||
end
|
||||
when 'user', 'etablissement'
|
||||
dossiers
|
||||
.includes(filter['table'])
|
||||
.where("#{filter['table'].pluralize}.#{filter['column']} ILIKE ?", "%#{filter['value']}%")
|
||||
end.pluck(:id)
|
||||
end.reduce(:&)
|
||||
end
|
||||
|
||||
def sorted_ids(dossiers)
|
||||
table = procedure_presentation.sort['table']
|
||||
column = procedure_presentation.sort['column']
|
||||
order = procedure_presentation.sort['order']
|
||||
includes = ''
|
||||
where = ''
|
||||
|
||||
sorted_ids = nil
|
||||
|
||||
case table
|
||||
when 'notifications'
|
||||
dossiers_id_with_notification = current_gestionnaire.notifications_for_procedure(procedure)
|
||||
if order == 'desc'
|
||||
sorted_ids = dossiers_id_with_notification + (dossiers.order('dossiers.updated_at desc').ids - dossiers_id_with_notification)
|
||||
else
|
||||
sorted_ids = (dossiers.order('dossiers.updated_at asc').ids - dossiers_id_with_notification) + dossiers_id_with_notification
|
||||
end
|
||||
when 'self'
|
||||
order = "dossiers.#{column} #{order}"
|
||||
when 'france_connect_information'
|
||||
includes = { user: :france_connect_information }
|
||||
order = "france_connect_informations.#{column} #{order}"
|
||||
when 'type_de_champ', 'type_de_champ_private'
|
||||
includes = table == 'type_de_champ' ? :champs : :champs_private
|
||||
where = "champs.type_de_champ_id = #{column.to_i}"
|
||||
order = "champs.value #{order}"
|
||||
else
|
||||
includes = table
|
||||
order = "#{table.pluralize}.#{column} #{order}"
|
||||
end
|
||||
|
||||
if sorted_ids.nil?
|
||||
sorted_ids = dossiers.includes(includes).where(where).order(Dossier.sanitize_for_order(order)).pluck(:id)
|
||||
end
|
||||
|
||||
sorted_ids
|
||||
end
|
||||
|
||||
def current_filters
|
||||
@current_filters ||= procedure_presentation.filters[statut]
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ module NewUser
|
|||
class FeedbacksController < UserController
|
||||
def create
|
||||
current_user.feedbacks.create!(rating: params[:rating])
|
||||
flash.notice = "Merci de votre retour, si vous souhaitez nous en dire plus, n'hésitez pas à #{view_context.contact_link('nous contacter', type: Helpscout::FormAdapter::TYPE_AMELIORATION)}."
|
||||
flash.notice = "Merci de votre retour, si vous souhaitez nous en dire plus, n'hésitez pas à #{helpers.contact_link('nous contacter', type: Helpscout::FormAdapter::TYPE_AMELIORATION)}."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,14 +9,14 @@ class SupportController < ApplicationController
|
|||
if direct_message? && create_commentaire
|
||||
flash.notice = "Votre message a été envoyé sur la messagerie de votre dossier."
|
||||
|
||||
redirect_to users_dossier_recapitulatif_path(dossier)
|
||||
redirect_to helpers.url_for_dossier(dossier)
|
||||
elsif create_conversation
|
||||
flash.notice = "Votre message a été envoyé."
|
||||
|
||||
redirect_to root_path
|
||||
else
|
||||
setup_context
|
||||
flash.now.alert = "Une erreur est survenue. Vous pouvez nous contactez à #{view_context.mail_to(CONTACT_EMAIL)}."
|
||||
flash.now.alert = "Une erreur est survenue. Vous pouvez nous contactez à #{helpers.mail_to(CONTACT_EMAIL)}."
|
||||
|
||||
render :index
|
||||
end
|
||||
|
|
|
@ -4,8 +4,12 @@ class Users::RecapitulatifController < UsersController
|
|||
end
|
||||
|
||||
def show
|
||||
if Flipflop.new_dossier_details?
|
||||
redirect_to dossier_url(current_user_dossier)
|
||||
else
|
||||
create_dossier_facade
|
||||
end
|
||||
end
|
||||
|
||||
def initiate
|
||||
create_dossier_facade
|
||||
|
|
|
@ -9,17 +9,17 @@ class WebhookController < ActionController::Base
|
|||
html = []
|
||||
|
||||
if user
|
||||
url = view_context.manager_user_url(user)
|
||||
url = manager_user_url(user)
|
||||
html << link_to_manager(user, url)
|
||||
end
|
||||
|
||||
if gestionnaire
|
||||
url = view_context.manager_gestionnaire_url(gestionnaire)
|
||||
url = manager_gestionnaire_url(gestionnaire)
|
||||
html << link_to_manager(gestionnaire, url)
|
||||
end
|
||||
|
||||
if administrateur
|
||||
url = view_context.manager_administrateur_url(administrateur)
|
||||
url = manager_administrateur_url(administrateur)
|
||||
html << link_to_manager(administrateur, url)
|
||||
end
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ module DossierHelper
|
|||
def url_for_dossier(dossier)
|
||||
if dossier.brouillon?
|
||||
brouillon_dossier_path(dossier)
|
||||
elsif Flipflop.new_dossier_details?
|
||||
dossier_path(dossier)
|
||||
else
|
||||
users_dossier_recapitulatif_path(dossier)
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module ProcedureHelper
|
||||
def procedure_lien(procedure)
|
||||
if procedure.procedure_path.present?
|
||||
if procedure.path.present?
|
||||
if procedure.brouillon_avec_lien?
|
||||
commencer_test_url(procedure_path: procedure.path)
|
||||
else
|
||||
|
|
|
@ -217,22 +217,7 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
def get_value(table, column)
|
||||
case table
|
||||
when 'self'
|
||||
self.send(column)
|
||||
when 'user'
|
||||
self.user.send(column)
|
||||
when 'france_connect_information'
|
||||
self.user.france_connect_information&.send(column)
|
||||
when 'entreprise'
|
||||
self.etablissement&.send(:"entreprise_#{column}")
|
||||
when 'etablissement'
|
||||
self.etablissement&.send(column)
|
||||
when 'type_de_champ'
|
||||
self.champs.find { |c| c.type_de_champ_id == column.to_i }.value
|
||||
when 'type_de_champ_private'
|
||||
self.champs_private.find { |c| c.type_de_champ_id == column.to_i }.value
|
||||
end
|
||||
DossierFieldService.get_value(self, table, column)
|
||||
end
|
||||
|
||||
def self.sanitize_for_order(order)
|
||||
|
|
|
@ -51,6 +51,7 @@ class Procedure < ApplicationRecord
|
|||
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||
validates :description, presence: true, allow_blank: false, allow_nil: false
|
||||
validate :check_juridique
|
||||
validates :path, format: { with: /\A[a-z0-9_\-]{3,50}\z/ }, uniqueness: true, presence: true, allow_blank: false, allow_nil: true
|
||||
# FIXME: remove duree_conservation_required flag once all procedures are converted to the new style
|
||||
validates :duree_conservation_dossiers_dans_ds, allow_nil: false, numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: MAX_DUREE_CONSERVATION }, if: :durees_conservation_required
|
||||
validates :duree_conservation_dossiers_hors_ds, allow_nil: false, numericality: { only_integer: true, greater_than_or_equal_to: 0 }, if: :durees_conservation_required
|
||||
|
@ -106,6 +107,7 @@ class Procedure < ApplicationRecord
|
|||
else
|
||||
create_procedure_path!(administrateur: administrateur, path: path)
|
||||
end
|
||||
update!(path: path)
|
||||
end
|
||||
|
||||
def reset!
|
||||
|
@ -130,7 +132,7 @@ class Procedure < ApplicationRecord
|
|||
|
||||
# This method is needed for transition. Eventually this will be the same as brouillon?.
|
||||
def brouillon_avec_lien?
|
||||
Flipflop.publish_draft? && brouillon? && procedure_path.present?
|
||||
Flipflop.publish_draft? && brouillon? && path.present?
|
||||
end
|
||||
|
||||
def publiee_ou_archivee?
|
||||
|
@ -152,7 +154,7 @@ class Procedure < ApplicationRecord
|
|||
end
|
||||
|
||||
def path
|
||||
procedure_path.path if procedure_path.present?
|
||||
read_attribute(:path) || procedure_path&.path
|
||||
end
|
||||
|
||||
def default_path
|
||||
|
@ -214,6 +216,7 @@ class Procedure < ApplicationRecord
|
|||
types_de_champ: :drop_down_list,
|
||||
types_de_champ_private: :drop_down_list
|
||||
})
|
||||
procedure.path = nil
|
||||
procedure.aasm_state = :brouillon
|
||||
procedure.test_started_at = nil
|
||||
procedure.archived_at = nil
|
||||
|
@ -249,7 +252,7 @@ class Procedure < ApplicationRecord
|
|||
end
|
||||
|
||||
def export_filename
|
||||
procedure_identifier = procedure_path&.path || "procedure-#{id}"
|
||||
procedure_identifier = path || "procedure-#{id}"
|
||||
"dossiers_#{procedure_identifier}_#{Time.now.strftime('%Y-%m-%d_%H-%M')}"
|
||||
end
|
||||
|
||||
|
@ -290,50 +293,7 @@ class Procedure < ApplicationRecord
|
|||
end
|
||||
|
||||
def fields
|
||||
fields = [
|
||||
field_hash('Créé le', 'self', 'created_at'),
|
||||
field_hash('Mis à jour le', 'self', 'updated_at'),
|
||||
field_hash('Demandeur', 'user', 'email')
|
||||
]
|
||||
|
||||
fields << [
|
||||
field_hash('Civilité (FC)', 'france_connect_information', 'gender'),
|
||||
field_hash('Prénom (FC)', 'france_connect_information', 'given_name'),
|
||||
field_hash('Nom (FC)', 'france_connect_information', 'family_name')
|
||||
]
|
||||
|
||||
if !for_individual || (for_individual && individual_with_siret)
|
||||
fields << [
|
||||
field_hash('SIREN', 'etablissement', 'entreprise_siren'),
|
||||
field_hash('Forme juridique', 'etablissement', 'entreprise_forme_juridique'),
|
||||
field_hash('Nom commercial', 'etablissement', 'entreprise_nom_commercial'),
|
||||
field_hash('Raison sociale', 'etablissement', 'entreprise_raison_sociale'),
|
||||
field_hash('SIRET siège social', 'etablissement', 'entreprise_siret_siege_social'),
|
||||
field_hash('Date de création', 'etablissement', 'entreprise_date_creation')
|
||||
]
|
||||
|
||||
fields << [
|
||||
field_hash('SIRET', 'etablissement', 'siret'),
|
||||
field_hash('Libellé NAF', 'etablissement', 'libelle_naf'),
|
||||
field_hash('Code postal', 'etablissement', 'code_postal')
|
||||
]
|
||||
end
|
||||
|
||||
types_de_champ
|
||||
.reject { |tdc| [TypeDeChamp.type_champs.fetch(:header_section), TypeDeChamp.type_champs.fetch(:explication)].include?(tdc.type_champ) }
|
||||
.each do |type_de_champ|
|
||||
|
||||
fields << field_hash(type_de_champ.libelle, 'type_de_champ', type_de_champ.id.to_s)
|
||||
end
|
||||
|
||||
types_de_champ_private
|
||||
.reject { |tdc| [TypeDeChamp.type_champs.fetch(:header_section), TypeDeChamp.type_champs.fetch(:explication)].include?(tdc.type_champ) }
|
||||
.each do |type_de_champ|
|
||||
|
||||
fields << field_hash(type_de_champ.libelle, 'type_de_champ_private', type_de_champ.id.to_s)
|
||||
end
|
||||
|
||||
fields.flatten
|
||||
DossierFieldService.fields(self)
|
||||
end
|
||||
|
||||
def fields_for_select
|
||||
|
@ -384,12 +344,12 @@ class Procedure < ApplicationRecord
|
|||
end
|
||||
|
||||
def after_archive
|
||||
update!(archived_at: Time.now)
|
||||
update!(archived_at: Time.now, path: nil)
|
||||
end
|
||||
|
||||
def after_hide
|
||||
now = Time.now
|
||||
update!(hidden_at: now)
|
||||
update!(hidden_at: now, path: nil)
|
||||
procedure_path&.hide!
|
||||
dossiers.update_all(hidden_at: now)
|
||||
end
|
||||
|
@ -424,14 +384,6 @@ class Procedure < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def field_hash(label, table, column)
|
||||
{
|
||||
'label' => label,
|
||||
'table' => table,
|
||||
'column' => column
|
||||
}
|
||||
end
|
||||
|
||||
def update_durees_conservation_required
|
||||
self.durees_conservation_required ||= duree_conservation_dossiers_hors_ds.present? && duree_conservation_dossiers_dans_ds.present?
|
||||
true
|
||||
|
|
|
@ -19,7 +19,7 @@ class ProcedurePath < ApplicationRecord
|
|||
def self.find_with_path(path)
|
||||
joins(:procedure)
|
||||
.where.not(procedures: { aasm_state: :archivee })
|
||||
.where("path LIKE ?", "%#{path}%")
|
||||
.where("procedure_paths.path LIKE ?", "%#{path}%")
|
||||
.order(:id)
|
||||
end
|
||||
|
||||
|
|
151
app/services/dossier_field_service.rb
Normal file
151
app/services/dossier_field_service.rb
Normal file
|
@ -0,0 +1,151 @@
|
|||
class DossierFieldService
|
||||
class << self
|
||||
def fields(procedure)
|
||||
fields = [
|
||||
field_hash('Créé le', 'self', 'created_at'),
|
||||
field_hash('Mis à jour le', 'self', 'updated_at'),
|
||||
field_hash('Demandeur', 'user', 'email')
|
||||
]
|
||||
|
||||
fields.push(
|
||||
field_hash('Civilité (FC)', 'france_connect_information', 'gender'),
|
||||
field_hash('Prénom (FC)', 'france_connect_information', 'given_name'),
|
||||
field_hash('Nom (FC)', 'france_connect_information', 'family_name')
|
||||
)
|
||||
|
||||
if !procedure.for_individual || (procedure.for_individual && procedure.individual_with_siret)
|
||||
fields.push(
|
||||
field_hash('SIREN', 'etablissement', 'entreprise_siren'),
|
||||
field_hash('Forme juridique', 'etablissement', 'entreprise_forme_juridique'),
|
||||
field_hash('Nom commercial', 'etablissement', 'entreprise_nom_commercial'),
|
||||
field_hash('Raison sociale', 'etablissement', 'entreprise_raison_sociale'),
|
||||
field_hash('SIRET siège social', 'etablissement', 'entreprise_siret_siege_social'),
|
||||
field_hash('Date de création', 'etablissement', 'entreprise_date_creation')
|
||||
)
|
||||
|
||||
fields.push(
|
||||
field_hash('SIRET', 'etablissement', 'siret'),
|
||||
field_hash('Libellé NAF', 'etablissement', 'libelle_naf'),
|
||||
field_hash('Code postal', 'etablissement', 'code_postal')
|
||||
)
|
||||
end
|
||||
|
||||
explanatory_types_de_champ = [:header_section, :explication].map{ |k| TypeDeChamp.type_champs.fetch(k) }
|
||||
|
||||
fields.concat procedure.types_de_champ
|
||||
.reject { |tdc| explanatory_types_de_champ.include?(tdc.type_champ) }
|
||||
.map { |type_de_champ| field_hash(type_de_champ.libelle, 'type_de_champ', type_de_champ.id.to_s) }
|
||||
|
||||
fields.concat procedure.types_de_champ_private
|
||||
.reject { |tdc| explanatory_types_de_champ.include?(tdc.type_champ) }
|
||||
.map { |type_de_champ| field_hash(type_de_champ.libelle, 'type_de_champ_private', type_de_champ.id.to_s) }
|
||||
|
||||
fields
|
||||
end
|
||||
|
||||
def get_value(dossier, table, column)
|
||||
case table
|
||||
when 'self'
|
||||
dossier.send(column)
|
||||
when 'user'
|
||||
dossier.user.send(column)
|
||||
when 'france_connect_information'
|
||||
dossier.user.france_connect_information&.send(column)
|
||||
when 'entreprise'
|
||||
dossier.etablissement&.send(:"entreprise_#{column}")
|
||||
when 'etablissement'
|
||||
dossier.etablissement&.send(column)
|
||||
when 'type_de_champ'
|
||||
dossier.champs.find { |c| c.type_de_champ_id == column.to_i }.value
|
||||
when 'type_de_champ_private'
|
||||
dossier.champs_private.find { |c| c.type_de_champ_id == column.to_i }.value
|
||||
end
|
||||
end
|
||||
|
||||
def filtered_ids(dossiers, filters)
|
||||
filters.map do |filter|
|
||||
case filter['table']
|
||||
when 'self'
|
||||
dossiers.where("? ILIKE ?", filter['column'], "%#{filter['value']}%")
|
||||
|
||||
when 'france_connect_information'
|
||||
dossiers
|
||||
.includes(user: :france_connect_information)
|
||||
.where("? ILIKE ?", "france_connect_informations.#{filter['column']}", "%#{filter['value']}%")
|
||||
|
||||
when 'type_de_champ', 'type_de_champ_private'
|
||||
relation = filter['table'] == 'type_de_champ' ? :champs : :champs_private
|
||||
dossiers
|
||||
.includes(relation)
|
||||
.where("champs.type_de_champ_id = ?", filter['column'].to_i)
|
||||
.where("champs.value ILIKE ?", "%#{filter['value']}%")
|
||||
when 'entreprise'
|
||||
table = 'etablissement'
|
||||
if filter['column'] == 'date_creation'
|
||||
date = filter['value'].to_date rescue nil
|
||||
dossiers
|
||||
.includes(table)
|
||||
.where("#{table.pluralize}.entreprise_#{filter['column']} = ?", date)
|
||||
else
|
||||
dossiers
|
||||
.includes(table)
|
||||
.where("#{table.pluralize}.entreprise_#{filter['column']} ILIKE ?", "%#{filter['value']}%")
|
||||
end
|
||||
when 'user', 'etablissement'
|
||||
dossiers
|
||||
.includes(filter['table'])
|
||||
.where("#{filter['table'].pluralize}.#{filter['column']} ILIKE ?", "%#{filter['value']}%")
|
||||
end.pluck(:id)
|
||||
end.reduce(:&)
|
||||
end
|
||||
|
||||
def sorted_ids(dossiers, procedure_presentation, gestionnaire)
|
||||
table = procedure_presentation.sort['table']
|
||||
column = procedure_presentation.sort['column']
|
||||
order = procedure_presentation.sort['order']
|
||||
includes = ''
|
||||
where = ''
|
||||
|
||||
sorted_ids = nil
|
||||
|
||||
case table
|
||||
when 'notifications'
|
||||
procedure = procedure_presentation.assign_to.procedure
|
||||
dossiers_id_with_notification = gestionnaire.notifications_for_procedure(procedure)
|
||||
if order == 'desc'
|
||||
sorted_ids = dossiers_id_with_notification + (dossiers.order('dossiers.updated_at desc').ids - dossiers_id_with_notification)
|
||||
else
|
||||
sorted_ids = (dossiers.order('dossiers.updated_at asc').ids - dossiers_id_with_notification) + dossiers_id_with_notification
|
||||
end
|
||||
when 'self'
|
||||
order = "dossiers.#{column} #{order}"
|
||||
when 'france_connect_information'
|
||||
includes = { user: :france_connect_information }
|
||||
order = "france_connect_informations.#{column} #{order}"
|
||||
when 'type_de_champ', 'type_de_champ_private'
|
||||
includes = table == 'type_de_champ' ? :champs : :champs_private
|
||||
where = "champs.type_de_champ_id = #{column.to_i}"
|
||||
order = "champs.value #{order}"
|
||||
else
|
||||
includes = table
|
||||
order = "#{table.pluralize}.#{column} #{order}"
|
||||
end
|
||||
|
||||
if sorted_ids.nil?
|
||||
sorted_ids = dossiers.includes(includes).where(where).order(Dossier.sanitize_for_order(order)).pluck(:id)
|
||||
end
|
||||
|
||||
sorted_ids
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def field_hash(label, table, column)
|
||||
{
|
||||
'label' => label,
|
||||
'table' => table,
|
||||
'column' => column
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,8 +1,8 @@
|
|||
- if mine
|
||||
Ce lien est déjà utilisé par une de vos procédure.
|
||||
Ce lien est déjà utilisé par une de vos démarche.
|
||||
%br
|
||||
Si vous voulez l’utiliser, l’ancienne procédure sera archivée (plus accessible du public).
|
||||
Si vous voulez l’utiliser, l’ancienne démarche sera archivée (plus accessible du public).
|
||||
- else
|
||||
Ce lien est déjà utilisé par une procédure.
|
||||
Ce lien est déjà utilisé par une démarche.
|
||||
%br
|
||||
Vous ne pouvez pas l’utiliser car il appartient à un autre administrateur.
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
= link_to service.email, "mailto:#{service.email}"
|
||||
- else
|
||||
Directement
|
||||
- if Flipflop.new_dossier_details?
|
||||
= link_to "par la messagerie", messagerie_dossier_path(dossier)
|
||||
- else
|
||||
= link_to "par la messagerie", users_dossier_recapitulatif_path(dossier)
|
||||
|
||||
%p
|
||||
Par téléphone :
|
||||
%a{ href: "tel:#{service.telephone}" }= service.telephone
|
||||
|
|
|
@ -18,4 +18,7 @@
|
|||
%b échanger avec un instructeur
|
||||
lors de sa construction et de son instruction
|
||||
|
||||
- if Flipflop.new_dossier_details?
|
||||
= link_to 'Accéder à votre dossier', dossier_path(@dossier), class: 'button large primary'
|
||||
- else
|
||||
= link_to 'Accéder à votre dossier', users_dossier_recapitulatif_path(@dossier), class: 'button large primary'
|
||||
|
|
|
@ -143,9 +143,9 @@ Rails.application.routes.draw do
|
|||
|
||||
patch 'pieces_justificatives' => 'description#pieces_justificatives'
|
||||
|
||||
# TODO: once these pages will be migrated to the new user design, replace these routes by a redirection
|
||||
get '/recapitulatif' => 'recapitulatif#show'
|
||||
post '/recapitulatif/initiate' => 'recapitulatif#initiate'
|
||||
|
||||
post '/commentaire' => 'commentaires#create'
|
||||
|
||||
get '/carte/position' => 'carte#get_position'
|
||||
|
|
5
db/migrate/20180913160415_add_path_to_procedures.rb
Normal file
5
db/migrate/20180913160415_add_path_to_procedures.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddPathToProcedures < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :procedures, :path, :string, index: true
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2018_08_27_111451) do
|
||||
ActiveRecord::Schema.define(version: 2018_09_13_160415) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -486,6 +486,7 @@ ActiveRecord::Schema.define(version: 2018_08_27_111451) do
|
|||
t.string "cadre_juridique"
|
||||
t.boolean "juridique_required", default: true
|
||||
t.boolean "durees_conservation_required", default: true
|
||||
t.string "path"
|
||||
t.index ["hidden_at"], name: "index_procedures_on_hidden_at"
|
||||
t.index ["parent_procedure_id"], name: "index_procedures_on_parent_procedure_id"
|
||||
t.index ["service_id"], name: "index_procedures_on_service_id"
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: add_path_to_procedures'
|
||||
task add_path_to_procedures: :environment do
|
||||
puts "Running deploy task 'add_path_to_procedures'"
|
||||
|
||||
def print_procedure(procedure)
|
||||
puts "#{procedure.id}##{procedure.path} - #{procedure.errors.full_messages}"
|
||||
end
|
||||
|
||||
puts "Démarches publiées :"
|
||||
Procedure.publiees.where(path: nil).find_each do |procedure|
|
||||
procedure.path = procedure.path
|
||||
if !procedure.save
|
||||
print_procedure(procedure)
|
||||
end
|
||||
end
|
||||
|
||||
puts "Démarches archivées :"
|
||||
Procedure.archivees.where(path: nil).find_each do |procedure|
|
||||
if procedure.procedure_path.present?
|
||||
procedure.path = procedure.path
|
||||
if !procedure.save
|
||||
print_procedure(procedure)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Update task as completed. If you remove the line below, the task will
|
||||
# run with every deploy (or every time you call after_party:run).
|
||||
AfterParty::TaskRecord.create version: '20180913161001'
|
||||
end
|
||||
end
|
|
@ -754,8 +754,8 @@ describe Admin::ProceduresController, type: :controller do
|
|||
let(:path) { procedure_owned.path }
|
||||
|
||||
it {
|
||||
expect(response.body).to include('Ce lien est déjà utilisé par une de vos procédure.')
|
||||
expect(response.body).to include('Si vous voulez l’utiliser, l’ancienne procédure sera archivée')
|
||||
expect(response.body).to include('Ce lien est déjà utilisé par une de vos démarche.')
|
||||
expect(response.body).to include('Si vous voulez l’utiliser, l’ancienne démarche sera archivée')
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -764,7 +764,7 @@ describe Admin::ProceduresController, type: :controller do
|
|||
let(:path) { procedure_not_owned.path }
|
||||
|
||||
it {
|
||||
expect(response.body).to include('Ce lien est déjà utilisé par une procédure.')
|
||||
expect(response.body).to include('Ce lien est déjà utilisé par une démarche.')
|
||||
expect(response.body).to include('Vous ne pouvez pas l’utiliser car il appartient à un autre administrateur.')
|
||||
}
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue