Skip to content

Commit

Permalink
Merge branch 'feature/import-2023-09-27'
Browse files Browse the repository at this point in the history
  • Loading branch information
maatinito committed Jan 15, 2024
2 parents 0c45e1c + 20457f4 commit 3efc11f
Show file tree
Hide file tree
Showing 86 changed files with 421 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
%p.fr-error-text= error_message
- elsif first?
%p.fr-text--sm.fr-text-mention--grey.fr-mb-1w
%p.fr-hint-text.fr-mb-1w
- if max_file_size.present?
= t('.max_file_size', max_file_size: number_to_human_size(max_file_size))
- if allowed_formats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ en:
check_content_rebased: The type of this field or its description has been modified by the administration. Check its content.
optional_champ: (optional)
recommended_size: The recommended maximum size is %{size} characters.
titre_identite_notice: National identity card (front side only), passport, residency permit or other proof of identity.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ fr:
check_content_rebased: Le type de ce champ ou sa description ont été modifiés par l'administration. Vérifier son contenu.
optional_champ: (facultatif)
recommended_size: La taille maximale conseillée est de %{size} caractères.
titre_identite_notice: Carte nationale d’identité (uniquement le recto), passeport, titre de séjour ou autre justificatif d’identité.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
%span.updated-at.highlighted
= t('.check_content_rebased')

- if @champ.titre_identite?
%span.fr-hint-text= t('.titre_identite_notice')

- if hint?
%span.fr-hint-text= hint

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
= @form.number_field(:value, input_opts(id: @champ.input_id, aria: { describedby: @champ.describedby_id }, step: :any, placeholder: "3.14", required: @champ.required?))
= @form.number_field(:value, input_opts(id: @champ.input_id, aria: { describedby: @champ.describedby_id }, step: :any, required: @champ.required?))

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
= @form.email_field(:value, input_opts(id: @champ.input_id, aria: { describedby: @champ.describedby_id }, placeholder: t(".placeholder"), required: @champ.required?))
= @form.email_field(:value, input_opts(id: @champ.input_id, aria: { describedby: @champ.describedby_id }, required: @champ.required?))

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
= @form.text_field(:value, input_opts(id: @champ.input_id, placeholder: t(".placeholder"), required: @champ.required?, aria: { describedby: @champ.describedby_id }, data: { controller: 'format', format: 'iban' }, class: "width-66-desktop", maxlength: 34 + 9)) # count space separator of 4 digits-groups
= @form.text_field(:value, input_opts(id: @champ.input_id, required: @champ.required?, aria: { describedby: @champ.describedby_id }, data: { controller: 'format', format: 'iban' }, class: "width-66-desktop", maxlength: 34 + 9)) # count space separator of 4 digits-groups

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-# Allowed @formats:
-# very light validation is made client-side
-# stronger validation is made server-side
= @form.phone_field(:value, input_opts(id: @champ.input_id, aria: { describedby: @champ.describedby_id }, placeholder: t(".placeholder"), required: @champ.required?, pattern: "[^a-z^A-Z]+"))
= @form.phone_field(:value, input_opts(id: @champ.input_id, aria: { describedby: @champ.describedby_id }, required: @champ.required?, pattern: "[^a-z^A-Z]+"))
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
en:
placeholder: "W503726238"
title: "The RNA number must begin with a capital W followed by 9 digits"
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
fr:
placeholder: "W503726238"
title: "Le numéro RNA doit commencer par un W majuscule suivi de 9 chiffres"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
= @form.text_field(:value, input_opts( id: @champ.input_id, aria: { describedby: @champ.describedby_id }, placeholder: t(".placeholder"), data: { controller: 'turbo-input', turbo_input_load_on_connect_value: @champ.prefilled? && @champ.value.present? && @champ.data.blank?, turbo_input_url_value: champs_rna_path(@champ.id) }, required: @champ.required?, pattern: "W[0-9]{9}", title: t(".title"), class: "width-33-desktop", maxlength: 10))
= @form.text_field(:value, input_opts( id: @champ.input_id, aria: { describedby: @champ.describedby_id }, data: { controller: 'turbo-input', turbo_input_load_on_connect_value: @champ.prefilled? && @champ.value.present? && @champ.data.blank?, turbo_input_url_value: champs_rna_path(@champ.id) }, required: @champ.required?, pattern: "W[0-9]{9}", title: t(".title"), class: "width-33-desktop", maxlength: 10))

.rna-info{ id: dom_id(@champ, :rna_info) }
= render 'shared/champs/rna/association', champ: @champ, error: nil
1 change: 0 additions & 1 deletion app/components/editable_champ/section_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ def initialize(nodes: nil, champs: nil)

def render_within_fieldset?
first_champ_is_an_header_section? && any_champ_fillable?
# pf: don't call any_champ_fillable? as this prevents correct numerotation
end

def header_section
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
en:
placeholder: "003970"
title: "The Tahiti number may start with a letter or digit followed by 5 digits"
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
fr:
placeholder: "003970"
title: "Le numéro Tahiti doit commencer par une lettre ou un chiffre et être suivi de 5 chiffres"
title: "Le numéro Tahiti doit commencer par une lettre ou un chiffre et être suivi de 5 chiffres"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
= @form.text_field(:value, input_opts(id: @champ.input_id, aria: { describedby: @champ.describedby_id }, placeholder: t(".placeholder"), data: { controller: 'turbo-input', turbo_input_load_on_connect_value: @champ.prefilled? && @champ.value.present? && @champ.etablissement.blank?, turbo_input_url_value: champs_siret_path(@champ.id) }, required: @champ.required?, pattern: "[A-Z0-9][0-9]{5}", title: t(".title"), class: "width-33-desktop", maxlength: 14))
= @form.text_field(:value, input_opts(id: @champ.input_id, aria: { describedby: @champ.describedby_id }, data: { controller: 'turbo-input', turbo_input_load_on_connect_value: @champ.prefilled? && @champ.value.present? && @champ.etablissement.blank?, turbo_input_url_value: champs_siret_path(@champ.id) }, required: @champ.required?, pattern: "[A-Z0-9][0-9]{5}", title: t(".title"), class: "width-33-desktop", maxlength: 14))
.siret-info{ id: dom_id(@champ, :siret_info) }
- if @champ.etablissement.present?
= render EditableChamp::EtablissementTitreComponent.new(etablissement: @champ.etablissement)
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

- if @champ.type_de_champ.piece_justificative_template&.attached?
= render partial: "shared/piece_justificative_template", locals: { champ: @champ }
= render Attachment::EditComponent.new(champ: @form.object, attached_file: @champ.piece_justificative_file, attachment: @champ.piece_justificative_file[0], form_object_name: @form.object_name,
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/administrateurs/procedures_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def search

significant_procedure_ids = Procedure
.publiees_ou_closes
.where(hidden_at_as_template: nil)
.where('unaccent(libelle) ILIKE unaccent(?)', "%#{query}%")
.joins(:dossiers)
.group("procedures.id")
Expand Down Expand Up @@ -406,7 +407,7 @@ def all
def administrateurs
@filter = ProceduresFilter.new(current_administrateur, params)
pids = AdministrateursProcedure.select(:administrateur_id).where(procedure: filter_procedures(@filter).map { |p| p["id"] })
@admins = Administrateur.includes(:user, :procedures).where(id: pids)
@admins = Administrateur.includes(:user, :procedures).where(id: pids, procedures: { hidden_at_as_template: nil })
@admins = @admins.where('unaccent(users.email) ILIKE unaccent(?)', "%#{@filter.email}%") if @filter.email.present?
@admins = paginate(@admins, 'users.email')
end
Expand All @@ -421,6 +422,7 @@ def filter_procedures(filter)

procedures_result = Procedure.select(:id).left_joins(:procedures_zones).distinct.publiees_ou_closes
procedures_result = procedures_result.where(procedures_zones: { zone_id: filter.zone_ids }) if filter.zone_ids.present?
procedures_result = procedures_result.where(hidden_at_as_template: nil)
procedures_result = procedures_result.where(aasm_state: filter.statuses) if filter.statuses.present?
procedures_result = procedures_result.where("tags @> ARRAY[?]::text[]", filter.tags) if filter.tags.present?
procedures_result = procedures_result.where('published_at >= ?', filter.from_publication_date) if filter.from_publication_date.present?
Expand Down
12 changes: 12 additions & 0 deletions app/controllers/manager/procedures_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ def whitelist
redirect_to manager_procedure_path(procedure)
end

def hide_as_template
procedure.hide_as_template!
flash[:notice] = "Démarche non visible dans les modèles."
redirect_to manager_procedure_path(procedure)
end

def unhide_as_template
procedure.unhide_as_template!
flash[:notice] = "Démarche visible dans les modèles."
redirect_to manager_procedure_path(procedure)
end

def discard
procedure.discard_and_keep_track!(current_super_admin)

Expand Down
5 changes: 3 additions & 2 deletions app/dashboards/dubious_procedure_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ class DubiousProcedureDashboard < Administrate::BaseDashboard
id: Field::Number,
libelle: Field::String,
dubious_champs: Field::String,
aasm_state: Field::String
aasm_state: Field::String,
hidden_at_as_template: Field::DateTime.with_options(format: "%d/%m/%Y")
}.freeze
COLLECTION_ATTRIBUTES = [:id, :libelle, :dubious_champs, :aasm_state].freeze
COLLECTION_ATTRIBUTES = [:id, :libelle, :dubious_champs, :aasm_state, :hidden_at_as_template].freeze
COLLECTION_FILTERS = {}.freeze
end
2 changes: 2 additions & 0 deletions app/dashboards/procedure_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ProcedureDashboard < Administrate::BaseDashboard
hidden_at: Field::DateTime,
closed_at: Field::DateTime,
whitelisted_at: Field::DateTime,
hidden_at_as_template: Field::DateTime,
service: Field::BelongsTo,
initiated_mail_template: MailTemplateField,
received_mail_template: MailTemplateField,
Expand Down Expand Up @@ -84,6 +85,7 @@ class ProcedureDashboard < Administrate::BaseDashboard
:published_at,
:whitelisted_at,
:hidden_at,
:hidden_at_as_template,
:closed_at,
:unpublished_at,
:published_types_de_champ_public,
Expand Down
4 changes: 1 addition & 3 deletions app/models/concerns/dossier_clone_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ def clone(user: nil, fork: false)
transaction do
cloned_dossier.save!(validate: !fork)

if fork
cloned_dossier.rebase!
end
cloned_dossier.rebase!
end

if fork
Expand Down
4 changes: 4 additions & 0 deletions app/models/contact_information.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class ContactInformation < ApplicationRecord
validates :adresse, presence: { message: 'doit être renseignée' }, allow_nil: false
validates :groupe_instructeur, presence: { message: 'doit être renseigné' }, allow_nil: false

def pretty_nom
nom
end

def telephone_url
if telephone.present?
"tel:#{telephone.gsub(/[[:blank:]]/, '')}"
Expand Down
5 changes: 3 additions & 2 deletions app/models/dubious_procedure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class DubiousProcedure
extend ActiveModel::Naming
extend ActiveModel::Translation

attr_accessor :id, :libelle, :dubious_champs, :aasm_state
attr_accessor :id, :libelle, :dubious_champs, :aasm_state, :hidden_at_as_template

FORBIDDEN_KEYWORDS = [
'NIR', 'RNIPP', 'race', 'religion', 'RIB',
Expand All @@ -19,7 +19,7 @@ def persisted?
def self.all
procedures_with_forbidden_tdcs_sql = TypeDeChamp
.joins(:procedure)
.select("string_agg(types_de_champ.libelle, ' - ') as dubious_champs, procedures.id as procedure_id, procedures.libelle as procedure_libelle, procedures.aasm_state as procedure_aasm_state")
.select("string_agg(types_de_champ.libelle, ' - ') as dubious_champs, procedures.id as procedure_id, procedures.libelle as procedure_libelle, procedures.aasm_state as procedure_aasm_state, procedures.hidden_at_as_template as procedure_hidden_at_as_template")
.where("unaccent(types_de_champ.libelle) ~* unaccent(?)", forbidden_regexp)
.where(type_champ: [TypeDeChamp.type_champs.fetch(:text), TypeDeChamp.type_champs.fetch(:textarea)])
.where(procedures: { closed_at: nil, whitelisted_at: nil })
Expand All @@ -33,6 +33,7 @@ def self.all
p.dubious_champs = procedure["dubious_champs"]
p.libelle = procedure["procedure_libelle"]
p.aasm_state = procedure["procedure_aasm_state"]
p.hidden_at_as_template = procedure["procedure_hidden_at_as_template"]
p
end
end
Expand Down
17 changes: 11 additions & 6 deletions app/models/logic/champ_value.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class Logic::ChampValue < Logic::Term
:integer_number,
:decimal_number,
:drop_down_list,
:multiple_drop_down_list
:multiple_drop_down_list,
:departements
)

CHAMP_VALUE_TYPE = {
Expand Down Expand Up @@ -60,7 +61,7 @@ def type(type_de_champs)
CHAMP_VALUE_TYPE.fetch(:boolean)
when MANAGED_TYPE_DE_CHAMP.fetch(:integer_number), MANAGED_TYPE_DE_CHAMP.fetch(:decimal_number)
CHAMP_VALUE_TYPE.fetch(:number)
when MANAGED_TYPE_DE_CHAMP.fetch(:drop_down_list)
when MANAGED_TYPE_DE_CHAMP.fetch(:drop_down_list), MANAGED_TYPE_DE_CHAMP.fetch(:departements)
CHAMP_VALUE_TYPE.fetch(:enum)
when MANAGED_TYPE_DE_CHAMP.fetch(:multiple_drop_down_list)
CHAMP_VALUE_TYPE.fetch(:enums)
Expand Down Expand Up @@ -94,11 +95,15 @@ def ==(other)

def options(type_de_champs)
tdc = type_de_champ(type_de_champs)
opts = tdc.drop_down_list_enabled_non_empty_options.map { |option| [option, option] }
if tdc.drop_down_other?
opts + [["Autre", Champs::DropDownListChamp::OTHER]]
if tdc.departement?
APIGeoService.departements.map { ["#{_1[:code]}#{_1[:name]}", _1[:code]] }
else
opts
opts = tdc.drop_down_list_enabled_non_empty_options.map { |option| [option, option] }
if tdc.drop_down_other?
opts + [["Autre", Champs::DropDownListChamp::OTHER]]
else
opts
end
end
end

Expand Down
14 changes: 14 additions & 0 deletions app/models/procedure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ def clone(admin, from_library)
procedure.encrypted_api_particulier_token = nil
procedure.opendata = true
procedure.api_particulier_scopes = []
procedure.routing_enabled = false
else
procedure.administrateurs = administrateurs
end
Expand Down Expand Up @@ -542,6 +543,19 @@ def whitelisted?
whitelisted_at.present?
end

def hidden_as_template?
hidden_at_as_template.present?
end

def hide_as_template!
touch(:hidden_at_as_template)
end

def unhide_as_template!
self.hidden_at_as_template = nil
save
end

def total_dossier
self.dossiers.state_not_brouillon.size
end
Expand Down
2 changes: 2 additions & 0 deletions app/models/procedure_presentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ def filtered_ids(dossiers, statut)
dossiers.filter_by_datetimes(column, dates)
elsif field['column'] == "state" && values.include?("pending_correction")
dossiers.joins(:corrections).where(corrections: DossierCorrection.pending)
elsif field['column'] == "state" && values.include?("en_construction")
dossiers.where("dossiers.#{column} IN (?)", values).includes(:corrections).where.not(corrections: DossierCorrection.pending)
else
dossiers.where("dossiers.#{column} IN (?)", values)
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class Service < ApplicationRecord
validates :adresse, presence: { message: 'doit être renseignée' }, allow_nil: false
validates :administrateur, presence: { message: 'doit être renseigné' }, allow_nil: false

def pretty_nom
"#{nom}, #{organisme}"
end

def clone_and_assign_to_administrateur(administrateur)
service_cloned = self.dup
service_cloned.administrateur = administrateur
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
%td
%button.fr-icon-add-line.fr-icon--sm.fr-mr-1w.fr-mb-1w.fr-text-action-high--blue-france{ 'aria-hidden': 'true', 'data-expand-target': 'icon' }
%td= admin.email
%td= admin.procedures.count
%td= admin.procedures.size
%td= l(admin.created_at, format: :message_date_without_time)
%tr.hidden{ 'data-expand-target': 'content' }
%td.fr-highlight--beige-gris-galet{ colspan: '6' }
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/mailers/_service_footer.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
= succeed '.' do
= link_to t('.file_messagerie'), messagerie_dossier_url(dossier), target: '_blank', rel: 'noopener'

- service = dossier&.service || dossier.procedure.service
- if service.present?
%table{ width: "100%", border: "0", cellspacing: "0", cellpadding: "0", style: "cursor:auto;color:#55575d;font-family:Helvetica, Arial, sans-serif;font-size:11px;line-height:22px;text-align:left;" }
%tr
Expand All @@ -13,7 +14,6 @@
%strong
= t('.procedure_management')
= service.nom
= service.organisme
= service.adresse
%td{ width: "50%", valign: "top" }
%p
Expand Down
6 changes: 6 additions & 0 deletions app/views/manager/procedures/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ as well as a link to its edit page.
<%= link_to 'whitelister', whitelist_manager_procedure_path(procedure), method: :post, class: 'button' %>
<% end %>

<% if procedure.hidden_as_template? %>
<%= link_to 'autoriser l\'affichage dans les modèles', unhide_as_template_manager_procedure_path(procedure), method: :post, class: 'button' %>
<% else %>
<%= link_to 'masquer l\'affichage dans les modèles', hide_as_template_manager_procedure_path(procedure), method: :post, class: 'button' %>
<% end %>

<% if procedure.can_be_deleted_by_manager? %>
<%= link_to 'Supprimer la démarche', discard_manager_procedure_path(procedure), method: :post, class: 'button', data: { confirm: "Confirmez-vous la suppression de la démarche ?" } %>
<% elsif procedure.discarded? %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/_procedure_footer.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- if service.present?
%h3.fr-footer__top-cat= I18n.t('users.procedure_footer.managed_by.header')
.fr-footer__top-link.fr-pb-2w
%span{ lang: :fr }= "#{service.nom}, #{service.organisme},"
%span{ lang: :fr }= service.pretty_nom
%div{ lang: :fr }
= render SimpleFormatComponent.new(service.adresse, class_names_map: {paragraph: 'fr-footer__content-desc'})
%h3.fr-footer__top-cat= I18n.t('users.procedure_footer.contact.header')
Expand Down
6 changes: 6 additions & 0 deletions config/locales/models/champs/address_champ/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
en:
activerecord:
attributes:
champs/address_champ:
hints:
value: "Enter an address, a street, a city. Example: 11 rue Réaumur, Paris"
6 changes: 6 additions & 0 deletions config/locales/models/champs/address_champ/fr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fr:
activerecord:
attributes:
champs/address_champ:
hints:
value: "Saisissez une adresse, une voie, un lieu-dit ou une commune. Exemple : 11 rue Réaumur, Paris"
6 changes: 6 additions & 0 deletions config/locales/models/champs/commune_champ/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
en:
activerecord:
attributes:
champs/commune_champ:
hints:
value: "Enter the municipality's zip code, then select the municipality from the list"
Loading

0 comments on commit 3efc11f

Please sign in to comment.