Merge branch 'dev'
This commit is contained in:
commit
0b86c22c91
19 changed files with 137 additions and 111 deletions
|
@ -148,7 +148,7 @@ class Users::DossiersController < UsersController
|
||||||
flash.alert = individual_errors
|
flash.alert = individual_errors
|
||||||
redirect_to users_dossier_path(id: @facade.dossier.id)
|
redirect_to users_dossier_path(id: @facade.dossier.id)
|
||||||
else
|
else
|
||||||
if !Dossier.find(@facade.dossier.id).update update_params_with_formatted_birthdate
|
if !Dossier.find(@facade.dossier.id).update(update_params)
|
||||||
flash.alert = @facade.dossier.errors.full_messages
|
flash.alert = @facade.dossier.errors.full_messages
|
||||||
|
|
||||||
return redirect_to users_dossier_path(id: @facade.dossier.id)
|
return redirect_to users_dossier_path(id: @facade.dossier.id)
|
||||||
|
@ -201,24 +201,6 @@ class Users::DossiersController < UsersController
|
||||||
params.require(:dossier).permit(:id, :autorisation_donnees, individual_attributes: [:gender, :nom, :prenom, :birthdate])
|
params.require(:dossier).permit(:id, :autorisation_donnees, individual_attributes: [:gender, :nom, :prenom, :birthdate])
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_params_with_formatted_birthdate
|
|
||||||
editable_params = update_params
|
|
||||||
|
|
||||||
if editable_params &&
|
|
||||||
editable_params[:individual_attributes] &&
|
|
||||||
editable_params[:individual_attributes][:birthdate]
|
|
||||||
|
|
||||||
iso_date = begin
|
|
||||||
Date.parse(editable_params[:individual_attributes][:birthdate]).iso8601
|
|
||||||
rescue
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
editable_params[:individual_attributes][:birthdate] = iso_date
|
|
||||||
end
|
|
||||||
|
|
||||||
editable_params
|
|
||||||
end
|
|
||||||
|
|
||||||
def individual_errors
|
def individual_errors
|
||||||
errors = []
|
errors = []
|
||||||
|
|
||||||
|
@ -226,13 +208,6 @@ class Users::DossiersController < UsersController
|
||||||
errors << "La validation des conditions d'utilisation est obligatoire"
|
errors << "La validation des conditions d'utilisation est obligatoire"
|
||||||
end
|
end
|
||||||
|
|
||||||
if update_params[:individual_attributes].present? &&
|
|
||||||
update_params[:individual_attributes][:birthdate] &&
|
|
||||||
!/^\d{4}\-\d{2}\-\d{2}$/.match(update_params[:individual_attributes][:birthdate]) &&
|
|
||||||
!/^\d{2}\/\d{2}\/\d{4}$/.match(update_params[:individual_attributes][:birthdate])
|
|
||||||
errors << "Le format de la date de naissance doit être JJ/MM/AAAA"
|
|
||||||
end
|
|
||||||
|
|
||||||
errors
|
errors
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,13 @@ module MailTemplateConcern
|
||||||
|
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
def default_for_procedure(procedure)
|
def default_for_procedure(procedure)
|
||||||
body = ActionController::Base.new.render_to_string(template: self.const_get(:TEMPLATE_NAME))
|
template_name = default_template_name_for_procedure(procedure)
|
||||||
self.new(subject: self.const_get(:DEFAULT_SUBJECT), body: body, procedure: procedure)
|
body = ActionController::Base.new.render_to_string(template: template_name)
|
||||||
|
new(subject: const_get(:DEFAULT_SUBJECT), body: body, procedure: procedure)
|
||||||
|
end
|
||||||
|
|
||||||
|
def default_template_name_for_procedure(procedure)
|
||||||
|
const_get(:DEFAULT_TEMPLATE_NAME)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,14 @@ module TagsSubstitutionConcern
|
||||||
{
|
{
|
||||||
libelle: 'lien dossier',
|
libelle: 'lien dossier',
|
||||||
description: '',
|
description: '',
|
||||||
lambda: -> (d) { users_dossier_recapitulatif_link(d) },
|
lambda: -> (d) { external_link(users_dossier_recapitulatif_url(d)) },
|
||||||
available_for_states: Dossier::SOUMIS
|
available_for_states: Dossier::SOUMIS
|
||||||
|
},
|
||||||
|
{
|
||||||
|
libelle: 'lien attestation',
|
||||||
|
description: '',
|
||||||
|
lambda: -> (d) { external_link(dossier_attestation_url(d)) },
|
||||||
|
available_for_states: ['accepte']
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -126,8 +132,7 @@ module TagsSubstitutionConcern
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def users_dossier_recapitulatif_link(dossier)
|
def external_link(url)
|
||||||
url = users_dossier_recapitulatif_url(dossier)
|
|
||||||
link_to(url, url, target: '_blank')
|
link_to(url, url, target: '_blank')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ class Individual < ApplicationRecord
|
||||||
validates :birthdate, format: { with: /\A\d{4}\-\d{2}\-\d{2}\z/, message: "La date n'est pas au format AAAA-MM-JJ" }, allow_nil: true
|
validates :birthdate, format: { with: /\A\d{4}\-\d{2}\-\d{2}\z/, message: "La date n'est pas au format AAAA-MM-JJ" }, allow_nil: true
|
||||||
|
|
||||||
before_validation :set_iso_date, if: -> { birthdate_changed? }
|
before_validation :set_iso_date, if: -> { birthdate_changed? }
|
||||||
|
before_save :save_birthdate_in_datetime_format
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
@ -17,4 +18,13 @@ class Individual < ApplicationRecord
|
||||||
self.birthdate = Date.parse(birthdate).iso8601
|
self.birthdate = Date.parse(birthdate).iso8601
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def save_birthdate_in_datetime_format
|
||||||
|
if birthdate.present?
|
||||||
|
begin
|
||||||
|
self.second_birthdate = Date.parse(birthdate)
|
||||||
|
rescue
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,9 +5,17 @@ module Mails
|
||||||
belongs_to :procedure
|
belongs_to :procedure
|
||||||
|
|
||||||
SLUG = "closed_mail"
|
SLUG = "closed_mail"
|
||||||
TEMPLATE_NAME = "mails/closed_mail"
|
|
||||||
DISPLAYED_NAME = "Accusé d'acceptation"
|
DISPLAYED_NAME = "Accusé d'acceptation"
|
||||||
DEFAULT_SUBJECT = 'Votre dossier demarches-simplifiees.fr nº --numéro du dossier-- a été accepté'
|
DEFAULT_SUBJECT = 'Votre dossier demarches-simplifiees.fr nº --numéro du dossier-- a été accepté'
|
||||||
DOSSIER_STATE = 'accepte'
|
DOSSIER_STATE = 'accepte'
|
||||||
|
|
||||||
|
def self.default_template_name_for_procedure(procedure)
|
||||||
|
attestation_template = procedure.attestation_template
|
||||||
|
if attestation_template.present? && attestation_template.activated?
|
||||||
|
"mails/closed_mail_with_attestation"
|
||||||
|
else
|
||||||
|
"mails/closed_mail"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Mails
|
||||||
belongs_to :procedure
|
belongs_to :procedure
|
||||||
|
|
||||||
SLUG = "initiated_mail"
|
SLUG = "initiated_mail"
|
||||||
TEMPLATE_NAME = "mails/initiated_mail"
|
DEFAULT_TEMPLATE_NAME = "mails/initiated_mail"
|
||||||
DISPLAYED_NAME = 'Accusé de réception'
|
DISPLAYED_NAME = 'Accusé de réception'
|
||||||
DEFAULT_SUBJECT = 'Votre dossier demarches-simplifiees.fr nº --numéro du dossier-- a bien été reçu'
|
DEFAULT_SUBJECT = 'Votre dossier demarches-simplifiees.fr nº --numéro du dossier-- a bien été reçu'
|
||||||
DOSSIER_STATE = 'en_construction'
|
DOSSIER_STATE = 'en_construction'
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Mails
|
||||||
belongs_to :procedure
|
belongs_to :procedure
|
||||||
|
|
||||||
SLUG = "received_mail"
|
SLUG = "received_mail"
|
||||||
TEMPLATE_NAME = "mails/received_mail"
|
DEFAULT_TEMPLATE_NAME = "mails/received_mail"
|
||||||
DISPLAYED_NAME = 'Accusé de passage en instruction'
|
DISPLAYED_NAME = 'Accusé de passage en instruction'
|
||||||
DEFAULT_SUBJECT = 'Votre dossier demarches-simplifiees.fr nº --numéro du dossier-- va être instruit'
|
DEFAULT_SUBJECT = 'Votre dossier demarches-simplifiees.fr nº --numéro du dossier-- va être instruit'
|
||||||
DOSSIER_STATE = 'en_instruction'
|
DOSSIER_STATE = 'en_instruction'
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Mails
|
||||||
belongs_to :procedure
|
belongs_to :procedure
|
||||||
|
|
||||||
SLUG = "refused_mail"
|
SLUG = "refused_mail"
|
||||||
TEMPLATE_NAME = "mails/refused_mail"
|
DEFAULT_TEMPLATE_NAME = "mails/refused_mail"
|
||||||
DISPLAYED_NAME = 'Accusé de rejet du dossier'
|
DISPLAYED_NAME = 'Accusé de rejet du dossier'
|
||||||
DEFAULT_SUBJECT = 'Votre dossier demarches-simplifiees.fr nº --numéro du dossier-- a été refusé'
|
DEFAULT_SUBJECT = 'Votre dossier demarches-simplifiees.fr nº --numéro du dossier-- a été refusé'
|
||||||
DOSSIER_STATE = 'refuse'
|
DOSSIER_STATE = 'refuse'
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Mails
|
||||||
belongs_to :procedure
|
belongs_to :procedure
|
||||||
|
|
||||||
SLUG = "without_continuation"
|
SLUG = "without_continuation"
|
||||||
TEMPLATE_NAME = "mails/without_continuation_mail"
|
DEFAULT_TEMPLATE_NAME = "mails/without_continuation_mail"
|
||||||
DISPLAYED_NAME = 'Accusé de classement sans suite'
|
DISPLAYED_NAME = 'Accusé de classement sans suite'
|
||||||
DEFAULT_SUBJECT = 'Votre dossier demarches-simplifiees.fr nº --numéro du dossier-- a été classé sans suite'
|
DEFAULT_SUBJECT = 'Votre dossier demarches-simplifiees.fr nº --numéro du dossier-- a été classé sans suite'
|
||||||
DOSSIER_STATE = 'sans_suite'
|
DOSSIER_STATE = 'sans_suite'
|
||||||
|
|
|
@ -1,4 +1 @@
|
||||||
- if @facade.procedure.for_individual?
|
|
||||||
= render partial: 'dossiers/etapes/etape_2/individual'
|
|
||||||
- else
|
|
||||||
= render partial: 'dossiers/etapes/etape_2/entreprise'
|
= render partial: 'dossiers/etapes/etape_2/entreprise'
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
.col-xs-3.center
|
|
||||||
%h3 Mes informations
|
|
||||||
%p
|
|
||||||
Les informations de bases
|
|
||||||
%br
|
|
||||||
vous concernant.
|
|
||||||
|
|
||||||
.etape.etapes-informations.col-xs-9
|
|
||||||
= form_for @facade.dossier, url: { controller: '/users/dossiers', action: :update } do |f|
|
|
||||||
.row
|
|
||||||
.col-xs-12.padding-left-30
|
|
||||||
= f.hidden_field :id
|
|
||||||
|
|
||||||
= f.fields_for :individual, @facade.individual do |ff|
|
|
||||||
.form-group
|
|
||||||
%label
|
|
||||||
%h4
|
|
||||||
Civilité
|
|
||||||
= ff.select :gender, ['M.', 'Mme']
|
|
||||||
.form-group
|
|
||||||
%label
|
|
||||||
%h4
|
|
||||||
Nom *
|
|
||||||
= ff.text_field :nom, { class: 'form-control', required: true }
|
|
||||||
.form-group
|
|
||||||
%label
|
|
||||||
%h4
|
|
||||||
Prénom *
|
|
||||||
= ff.text_field :prenom, { class: 'form-control', required: true }
|
|
||||||
|
|
||||||
- if @facade.procedure.ask_birthday?
|
|
||||||
.form-group
|
|
||||||
%label
|
|
||||||
%h4
|
|
||||||
Date de naissance *
|
|
||||||
= ff.date_field :birthdate, { value: @facade.individual.birthdate, class: 'form-control', placeholder: 'jj/mm/aaaa', required: true }
|
|
||||||
|
|
||||||
%p
|
|
||||||
%label{ style: 'font-weight: normal;' }
|
|
||||||
= f.check_box :autorisation_donnees
|
|
||||||
J'accepte
|
|
||||||
= link_to "les CGU", CGU_URL, target: :blank
|
|
||||||
.row
|
|
||||||
.col-xs-5.col-xs-5
|
|
||||||
.col-xs-2.col-xs-2
|
|
||||||
= f.submit 'Etape suivante', class: "action", id: 'etape_suivante'
|
|
||||||
.col-xs-5.col-xs-5
|
|
22
app/views/mails/closed_mail_with_attestation.html.haml
Normal file
22
app/views/mails/closed_mail_with_attestation.html.haml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
Bonjour,
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
Votre dossier nº --numéro du dossier-- a été accepté le --date de décision--.
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
Vous pouvez télécharger votre attestation à l'adresse suivante : --lien attestation--
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
A tout moment, vous pouvez consulter le contenu de vos dossiers et les éventuels commentaires de l'administration à cette adresse : --lien dossier--
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
Bonne journée,
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
L'équipe demarches-simplifiees.fr (anciennement Téléprocédures Simplifiées)
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
—
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
Merci de ne pas répondre à cet email. Postez directement vos questions dans votre dossier sur la plateforme.
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddSecondBirthdateColumnToIndividual < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
add_column :individuals, :second_birthdate, :date
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2018_03_23_101837) do
|
ActiveRecord::Schema.define(version: 2018_04_03_094135) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -366,6 +366,7 @@ ActiveRecord::Schema.define(version: 2018_03_23_101837) do
|
||||||
t.string "gender"
|
t.string "gender"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
|
t.date "second_birthdate"
|
||||||
t.index ["dossier_id"], name: "index_individuals_on_dossier_id"
|
t.index ["dossier_id"], name: "index_individuals_on_dossier_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
14
lib/tasks/2018_04_03_type_individual_date.rake
Normal file
14
lib/tasks/2018_04_03_type_individual_date.rake
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
namespace :'2018_04_03_type_individual_date' do
|
||||||
|
task set: :environment do
|
||||||
|
Individual.all.each { |individual| save_birthdate_in_datetime_format(individual) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def save_birthdate_in_datetime_format(individual)
|
||||||
|
if individual.birthdate.present?
|
||||||
|
begin
|
||||||
|
individual.update_column(:second_birthdate, Date.parse(individual.birthdate))
|
||||||
|
rescue
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -345,29 +345,6 @@ describe Users::DossiersController, type: :controller do
|
||||||
subject
|
subject
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when procedure is for individual' do
|
|
||||||
let(:autorisation_donnees) { "1" }
|
|
||||||
let(:procedure) { create(:procedure, :published, for_individual: true) }
|
|
||||||
|
|
||||||
before do
|
|
||||||
dossier.reload
|
|
||||||
end
|
|
||||||
|
|
||||||
it { expect(dossier.individual.gender).to eq 'M.' }
|
|
||||||
it { expect(dossier.individual.nom).to eq 'Julien' }
|
|
||||||
it { expect(dossier.individual.prenom).to eq 'Xavier' }
|
|
||||||
it { expect(dossier.individual.birthdate).to eq '1991-01-20' }
|
|
||||||
it { expect(dossier.procedure.for_individual).to eq true }
|
|
||||||
|
|
||||||
context "and birthdate is ISO (YYYY-MM-DD) formatted" do
|
|
||||||
let(:birthdate) { "1991-11-01" }
|
|
||||||
before do
|
|
||||||
dossier.reload
|
|
||||||
end
|
|
||||||
it { expect(dossier.individual.birthdate).to eq '1991-11-01' }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when Checkbox is checked' do
|
context 'when Checkbox is checked' do
|
||||||
let(:autorisation_donnees) { '1' }
|
let(:autorisation_donnees) { '1' }
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,31 @@ describe MailTemplateConcern do
|
||||||
expect(received_mail.tags).to include(include({ libelle: 'date de passage en instruction' }))
|
expect(received_mail.tags).to include(include({ libelle: 'date de passage en instruction' }))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '--lien attestation--' do
|
||||||
|
let(:attestation_template) { AttestationTemplate.new(activated: true) }
|
||||||
|
let(:procedure) { create(:procedure, attestation_template: attestation_template) }
|
||||||
|
|
||||||
|
subject { mail.body_for_dossier(dossier) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
dossier.attestation = dossier.build_attestation
|
||||||
|
dossier.reload
|
||||||
|
mail.body = "--lien attestation--"
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "in closed mail" do
|
||||||
|
let(:mail) { create(:closed_mail, procedure: procedure) }
|
||||||
|
|
||||||
|
it { is_expected.to eq("<a target=\"_blank\" href=\"http://localhost:3000/dossiers/#{dossier.id}/attestation\">http://localhost:3000/dossiers/#{dossier.id}/attestation</a>") }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "in refuse mail" do
|
||||||
|
let(:mail) { create(:refused_mail, procedure: procedure) }
|
||||||
|
|
||||||
|
it { is_expected.to eq("--lien attestation--") }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#replace_tags' do
|
describe '#replace_tags' do
|
||||||
|
|
|
@ -23,6 +23,7 @@ describe Individual do
|
||||||
|
|
||||||
it { expect(individual.valid?).to be true }
|
it { expect(individual.valid?).to be true }
|
||||||
it { expect(individual.birthdate).to eq("1980-11-12") }
|
it { expect(individual.birthdate).to eq("1980-11-12") }
|
||||||
|
it { expect(individual.second_birthdate).to eq(Date.new(1980, 11, 12)) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "and the format is ISO" do
|
context "and the format is ISO" do
|
||||||
|
@ -30,6 +31,7 @@ describe Individual do
|
||||||
|
|
||||||
it { expect(individual.valid?).to be true }
|
it { expect(individual.valid?).to be true }
|
||||||
it { expect(individual.birthdate).to eq("1980-11-12") }
|
it { expect(individual.birthdate).to eq("1980-11-12") }
|
||||||
|
it { expect(individual.second_birthdate).to eq(Date.new(1980, 11, 12)) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "and the format is WTF" do
|
context "and the format is WTF" do
|
||||||
|
@ -37,6 +39,7 @@ describe Individual do
|
||||||
|
|
||||||
it { expect(individual.valid?).to be false }
|
it { expect(individual.valid?).to be false }
|
||||||
it { expect(individual.birthdate).to eq("1980 1 12") }
|
it { expect(individual.birthdate).to eq("1980 1 12") }
|
||||||
|
it { expect(individual.second_birthdate).to be_nil }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -41,6 +41,32 @@ describe Procedure do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'closed mail template body' do
|
||||||
|
let(:procedure) { create(:procedure) }
|
||||||
|
|
||||||
|
subject { procedure.closed_mail_template.body }
|
||||||
|
|
||||||
|
context 'for procedures without an attestation' do
|
||||||
|
it { is_expected.not_to include('lien attestation') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'for procedures with an attestation' do
|
||||||
|
before { create(:attestation_template, procedure: procedure, activated: activated) }
|
||||||
|
|
||||||
|
context 'when the attestation is inactive' do
|
||||||
|
let(:activated) { false }
|
||||||
|
|
||||||
|
it { is_expected.not_to include('lien attestation') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the attestation is inactive' do
|
||||||
|
let(:activated) { true }
|
||||||
|
|
||||||
|
it { is_expected.to include('lien attestation') }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'validation' do
|
describe 'validation' do
|
||||||
context 'libelle' do
|
context 'libelle' do
|
||||||
it { is_expected.not_to allow_value(nil).for(:libelle) }
|
it { is_expected.not_to allow_value(nil).for(:libelle) }
|
||||||
|
|
Loading…
Reference in a new issue