parent
54181bd920
commit
64ce2719ed
8 changed files with 40 additions and 4 deletions
|
@ -74,7 +74,7 @@ module Administrateurs
|
|||
private
|
||||
|
||||
def service_params
|
||||
params.require(:service).permit(:nom, :organisme, :type_organisme, :email, :telephone, :horaires, :adresse)
|
||||
params.require(:service).permit(:nom, :organisme, :type_organisme, :email, :telephone, :horaires, :adresse, :siret)
|
||||
end
|
||||
|
||||
def service
|
||||
|
|
|
@ -90,7 +90,7 @@ module DossierHelper
|
|||
l(dossier.expiration_date, format: '%d/%m/%Y')
|
||||
end
|
||||
|
||||
def annuaire_link(siren)
|
||||
def annuaire_link(siren = nil)
|
||||
base_url = "https://annuaire-entreprises.data.gouv.fr"
|
||||
return base_url if siren.blank?
|
||||
"#{base_url}/entreprise/#{siren}"
|
||||
|
|
|
@ -34,6 +34,7 @@ class Service < ApplicationRecord
|
|||
validates :nom, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||
validates :nom, uniqueness: { scope: :administrateur, message: 'existe déjà' }
|
||||
validates :organisme, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||
validates :siret, siret_format: true, allow_nil: true
|
||||
validates :type_organisme, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||
validates :email, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||
validates :telephone, phone: { possible: true, allow_blank: true }
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
|
||||
= f.select :type_organisme, Service.type_organismes.keys.map { |key| [ I18n.t("type_organisme.#{key}"), key] }, class: 'width-33-desktop width-100-mobile'
|
||||
|
||||
= f.label :siret do
|
||||
Numéro SIRET
|
||||
%span.mandatory *
|
||||
= f.text_field :siret, placeholder: "14 chiffres"
|
||||
|
||||
= render Dsfr::CalloutComponent.new(title: "Informations de contact") do |c|
|
||||
- c.body do
|
||||
|
|
|
@ -9,3 +9,11 @@ en:
|
|||
adresse: 'Mail address'
|
||||
email: 'Email'
|
||||
telephone: 'Phone'
|
||||
errors:
|
||||
models:
|
||||
service:
|
||||
attributes:
|
||||
siret:
|
||||
format: "SIRET number %{message}"
|
||||
length: "must contain exactly 14 digits"
|
||||
checksum: "is invalid"
|
||||
|
|
|
@ -9,6 +9,14 @@ fr:
|
|||
adresse: 'Adresse postale'
|
||||
email: 'Email de contact'
|
||||
telephone: 'Téléphone'
|
||||
errors:
|
||||
models:
|
||||
service:
|
||||
attributes:
|
||||
siret:
|
||||
format: "Le numéro SIRET %{message}"
|
||||
length: "doit comporter exactement 14 chiffres"
|
||||
checksum: "est invalide"
|
||||
type_organisme:
|
||||
administration_centrale: 'Administration centrale'
|
||||
association: 'Association'
|
||||
|
|
|
@ -18,7 +18,8 @@ describe Administrateurs::ServicesController, type: :controller do
|
|||
email: 'email@toto.com',
|
||||
telephone: '1234',
|
||||
horaires: 'horaires',
|
||||
adresse: 'adresse'
|
||||
adresse: 'adresse',
|
||||
siret: "35600082800018"
|
||||
},
|
||||
procedure_id: procedure.id
|
||||
}
|
||||
|
@ -33,6 +34,7 @@ describe Administrateurs::ServicesController, type: :controller do
|
|||
it { expect(Service.last.telephone).to eq('1234') }
|
||||
it { expect(Service.last.horaires).to eq('horaires') }
|
||||
it { expect(Service.last.adresse).to eq('adresse') }
|
||||
it { expect(Service.last.siret).to eq('35600082800018') }
|
||||
it { expect(response).to redirect_to(admin_services_path(procedure_id: procedure.id)) }
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,8 @@ describe Service, type: :model do
|
|||
telephone: '012345678',
|
||||
horaires: 'du lundi au vendredi',
|
||||
adresse: '12 rue des schtroumpfs',
|
||||
administrateur_id: administrateur.id
|
||||
administrateur_id: administrateur.id,
|
||||
siret: "35600082800018"
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -41,6 +42,18 @@ describe Service, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
describe "siret" do
|
||||
it 'should not be invalid' do
|
||||
subject.siret = "012345678901234"
|
||||
expect(subject).not_to be_valid
|
||||
end
|
||||
|
||||
it 'should be optional' do
|
||||
subject.siret = nil
|
||||
expect(subject).to be_valid
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a first service exists' do
|
||||
before { Service.create(params) }
|
||||
|
||||
|
|
Loading…
Reference in a new issue