commit
a731cbb138
12 changed files with 108 additions and 29 deletions
|
@ -2,6 +2,7 @@ class API::V1::DossiersController < APIController
|
||||||
before_action :fetch_procedure_and_check_token
|
before_action :fetch_procedure_and_check_token
|
||||||
|
|
||||||
DEFAULT_PAGE_SIZE = 100
|
DEFAULT_PAGE_SIZE = 100
|
||||||
|
MAX_PAGE_SIZE = 1000
|
||||||
ORDER_DIRECTIONS = { 'asc' => :asc, 'desc' => :desc }
|
ORDER_DIRECTIONS = { 'asc' => :asc, 'desc' => :desc }
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@ -33,7 +34,12 @@ class API::V1::DossiersController < APIController
|
||||||
end
|
end
|
||||||
|
|
||||||
def per_page # inherited value from will_paginate
|
def per_page # inherited value from will_paginate
|
||||||
[params[:resultats_par_page]&.to_i || DEFAULT_PAGE_SIZE, 1000].min
|
resultats_par_page = params[:resultats_par_page]&.to_i
|
||||||
|
if resultats_par_page && resultats_par_page > 0
|
||||||
|
[resultats_par_page, MAX_PAGE_SIZE].min
|
||||||
|
else
|
||||||
|
DEFAULT_PAGE_SIZE
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_procedure_and_check_token
|
def fetch_procedure_and_check_token
|
||||||
|
|
|
@ -48,8 +48,11 @@ module Users
|
||||||
end
|
end
|
||||||
|
|
||||||
def attestation
|
def attestation
|
||||||
if dossier.attestation.pdf.attached?
|
if dossier.attestation&.pdf&.attached?
|
||||||
redirect_to url_for(dossier.attestation.pdf)
|
redirect_to url_for(dossier.attestation.pdf)
|
||||||
|
else
|
||||||
|
flash.notice = "L'attestation n'est plus disponible sur ce dossier."
|
||||||
|
redirect_to dossier_path(dossier)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
16
app/models/dynamic_smtp_settings_interceptor.rb
Normal file
16
app/models/dynamic_smtp_settings_interceptor.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
class DynamicSmtpSettingsInterceptor
|
||||||
|
def self.delivering_email(message)
|
||||||
|
if ENV['SENDINBLUE_BALANCING'] == 'enabled'
|
||||||
|
if rand(0..99) < ENV['SENDINBLUE_BALANCING_VALUE'].to_i
|
||||||
|
message.delivery_method.settings = {
|
||||||
|
user_name: ENV['SENDINBLUE_USER_NAME'],
|
||||||
|
password: ENV['SENDINBLUE_SMTP_KEY'],
|
||||||
|
address: 'smtp-relay.sendinblue.com',
|
||||||
|
domain: 'smtp-relay.sendinblue.com',
|
||||||
|
port: '587',
|
||||||
|
authentication: :cram_md5
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -595,14 +595,18 @@ class Procedure < ApplicationRecord
|
||||||
|
|
||||||
def move_type_de_champ_attributes(types_de_champ, type_de_champ, new_index)
|
def move_type_de_champ_attributes(types_de_champ, type_de_champ, new_index)
|
||||||
old_index = types_de_champ.index(type_de_champ)
|
old_index = types_de_champ.index(type_de_champ)
|
||||||
types_de_champ.insert(new_index, types_de_champ.delete_at(old_index))
|
if types_de_champ.delete_at(old_index)
|
||||||
.map.with_index do |type_de_champ, index|
|
types_de_champ.insert(new_index, type_de_champ)
|
||||||
{
|
.map.with_index do |type_de_champ, index|
|
||||||
id: type_de_champ.id,
|
{
|
||||||
libelle: type_de_champ.libelle,
|
id: type_de_champ.id,
|
||||||
order_place: index
|
libelle: type_de_champ.libelle,
|
||||||
}
|
order_place: index
|
||||||
end
|
}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def before_publish
|
def before_publish
|
||||||
|
|
|
@ -53,7 +53,7 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas
|
||||||
|
|
||||||
def check_presence_of_primary_options
|
def check_presence_of_primary_options
|
||||||
if !PRIMARY_PATTERN.match?(drop_down_list.options.second)
|
if !PRIMARY_PATTERN.match?(drop_down_list.options.second)
|
||||||
errors.add(libelle, "doit commencer par une entrée de menu primaire de la forme <code style='white-space: pre-wrap;'>--texte--</code>")
|
errors.add(libelle.presence || "La liste", "doit commencer par une entrée de menu primaire de la forme <code style='white-space: pre-wrap;'>--texte--</code>")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
- champs = champ.rows.last
|
- champs = champ.rows.last
|
||||||
- index = (champ.rows.size - 1) * champs.size
|
- if champs.present?
|
||||||
%div{ class: "row row-#{champs.first.row}" }
|
- index = (champ.rows.size - 1) * champs.size
|
||||||
- champs.each.with_index(index) do |champ, index|
|
%div{ class: "row row-#{champs.first.row}" }
|
||||||
= fields_for "#{attribute}[#{index}]", champ do |form|
|
- champs.each.with_index(index) do |champ, index|
|
||||||
= render partial: "shared/dossiers/editable_champs/editable_champ", locals: { champ: champ, form: form }
|
= fields_for "#{attribute}[#{index}]", champ do |form|
|
||||||
= form.hidden_field :id
|
= render partial: "shared/dossiers/editable_champs/editable_champ", locals: { champ: champ, form: form }
|
||||||
= form.hidden_field :_destroy, disabled: true
|
= form.hidden_field :id
|
||||||
%button.button.danger.remove-row
|
= form.hidden_field :_destroy, disabled: true
|
||||||
Supprimer
|
%button.button.danger.remove-row
|
||||||
|
Supprimer
|
||||||
|
|
|
@ -46,8 +46,14 @@ SENTRY_DSN_JS=""
|
||||||
MATOMO_ENABLED="disabled"
|
MATOMO_ENABLED="disabled"
|
||||||
MATOMO_ID="73"
|
MATOMO_ID="73"
|
||||||
|
|
||||||
SENDINBLUE_ENABLED="disabled"
|
SENDINBLUE_BALANCING=""
|
||||||
|
SENDINBLUE_BALANCING_VALUE=""
|
||||||
|
SENDINBLUE_ENABLED=""
|
||||||
SENDINBLUE_CLIENT_KEY=""
|
SENDINBLUE_CLIENT_KEY=""
|
||||||
|
SENDINBLUE_SMTP_KEY=""
|
||||||
|
SENDINBLUE_USER_NAME=""
|
||||||
|
|
||||||
|
|
||||||
CRISP_ENABLED="disabled"
|
CRISP_ENABLED="disabled"
|
||||||
CRISP_CLIENT_KEY=""
|
CRISP_CLIENT_KEY=""
|
||||||
|
|
||||||
|
|
|
@ -45,14 +45,26 @@ Rails.application.configure do
|
||||||
config.assets.raise_runtime_errors = true
|
config.assets.raise_runtime_errors = true
|
||||||
|
|
||||||
# Action Mailer settings
|
# Action Mailer settings
|
||||||
config.action_mailer.delivery_method = :letter_opener_web
|
|
||||||
# Configure default root URL for generating URLs to routes
|
if ENV['SENDINBLUE_ENABLED'] == 'enabled'
|
||||||
config.action_mailer.default_url_options = {
|
config.action_mailer.delivery_method = :smtp
|
||||||
host: 'localhost',
|
config.action_mailer.smtp_settings = {
|
||||||
port: 3000
|
user_name: Rails.application.secrets.sendinblue[:username],
|
||||||
}
|
password: Rails.application.secrets.sendinblue[:smtp_key],
|
||||||
# Configure default root URL for email assets
|
address: 'smtp-relay.sendinblue.com',
|
||||||
config.action_mailer.asset_host = "http://" + ENV['APP_HOST']
|
domain: 'smtp-relay.sendinblue.com',
|
||||||
|
port: '587',
|
||||||
|
authentication: :cram_md5
|
||||||
|
}
|
||||||
|
else
|
||||||
|
config.action_mailer.delivery_method = :letter_opener_web
|
||||||
|
config.action_mailer.default_url_options = {
|
||||||
|
host: 'localhost',
|
||||||
|
port: 3000
|
||||||
|
}
|
||||||
|
|
||||||
|
config.action_mailer.asset_host = "http://" + ENV['APP_HOST']
|
||||||
|
end
|
||||||
|
|
||||||
Rails.application.routes.default_url_options = {
|
Rails.application.routes.default_url_options = {
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
|
|
|
@ -77,6 +77,16 @@ Rails.application.configure do
|
||||||
port: '2525',
|
port: '2525',
|
||||||
authentication: :cram_md5
|
authentication: :cram_md5
|
||||||
}
|
}
|
||||||
|
elsif ENV['SENDINBLUE_ENABLED'] == 'enabled'
|
||||||
|
config.action_mailer.delivery_method = :smtp
|
||||||
|
config.action_mailer.smtp_settings = {
|
||||||
|
user_name: Rails.application.secrets.sendinblue[:username],
|
||||||
|
password: Rails.application.secrets.sendinblue[:smtp_key],
|
||||||
|
address: 'smtp-relay.sendinblue.com',
|
||||||
|
domain: 'smtp-relay.sendinblue.com',
|
||||||
|
port: '587',
|
||||||
|
authentication: :cram_md5
|
||||||
|
}
|
||||||
else
|
else
|
||||||
config.action_mailer.delivery_method = :mailjet
|
config.action_mailer.delivery_method = :mailjet
|
||||||
end
|
end
|
||||||
|
|
1
config/initializers/dynamic_smtp_settings_interceptor.rb
Normal file
1
config/initializers/dynamic_smtp_settings_interceptor.rb
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ActionMailer::Base.register_interceptor "DynamicSmtpSettingsInterceptor"
|
|
@ -54,7 +54,9 @@ defaults: &defaults
|
||||||
webhook_secret: <%= ENV['HELPSCOUT_WEBHOOK_SECRET'] %>
|
webhook_secret: <%= ENV['HELPSCOUT_WEBHOOK_SECRET'] %>
|
||||||
sendinblue:
|
sendinblue:
|
||||||
enabled: <%= ENV['SENDINBLUE_ENABLED'] == 'enabled' %>
|
enabled: <%= ENV['SENDINBLUE_ENABLED'] == 'enabled' %>
|
||||||
|
username: <%= ENV['SENDINBLUE_USER_NAME'] %>
|
||||||
client_key: <%= ENV['SENDINBLUE_CLIENT_KEY'] %>
|
client_key: <%= ENV['SENDINBLUE_CLIENT_KEY'] %>
|
||||||
|
smtp_key: <%= ENV['SENDINBLUE_SMTP_KEY'] %>
|
||||||
api_v3_key: <%= ENV['SENDINBLUE_API_V3_KEY'] %>
|
api_v3_key: <%= ENV['SENDINBLUE_API_V3_KEY'] %>
|
||||||
matomo:
|
matomo:
|
||||||
enabled: <%= ENV['MATOMO_ENABLED'] == 'enabled' %>
|
enabled: <%= ENV['MATOMO_ENABLED'] == 'enabled' %>
|
||||||
|
|
|
@ -148,4 +148,22 @@ shared_examples 'type_de_champ_spec' do
|
||||||
expect(cloned_procedure.types_de_champ.first.types_de_champ).not_to be_empty
|
expect(cloned_procedure.types_de_champ.first.types_de_champ).not_to be_empty
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "linked_drop_down_list" do
|
||||||
|
let(:type_de_champ) { create(:type_de_champ_linked_drop_down_list) }
|
||||||
|
|
||||||
|
it 'should validate without label' do
|
||||||
|
type_de_champ.drop_down_list_value = 'toto'
|
||||||
|
expect(type_de_champ.validate).to be_falsey
|
||||||
|
messages = type_de_champ.errors.full_messages
|
||||||
|
expect(messages.size).to eq(1)
|
||||||
|
expect(messages.first.starts_with?("#{type_de_champ.libelle} doit commencer par")).to be_truthy
|
||||||
|
|
||||||
|
type_de_champ.libelle = ''
|
||||||
|
expect(type_de_champ.validate).to be_falsey
|
||||||
|
messages = type_de_champ.errors.full_messages
|
||||||
|
expect(messages.size).to eq(2)
|
||||||
|
expect(messages.last.starts_with?("La liste doit commencer par")).to be_truthy
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue