Service: add organisme, email, tel, horaires, adresse
This commit is contained in:
parent
0be21395ac
commit
39bb56d1d9
8 changed files with 66 additions and 2 deletions
|
@ -70,7 +70,7 @@ module NewAdministrateur
|
|||
private
|
||||
|
||||
def service_params
|
||||
params.require(:service).permit(:nom, :type_organisme)
|
||||
params.require(:service).permit(:nom, :organisme, :type_organisme, :email, :telephone, :horaires, :adresse)
|
||||
end
|
||||
|
||||
def service
|
||||
|
|
|
@ -17,6 +17,11 @@ 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 :type_organisme, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||
validates :email, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||
validates :telephone, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||
validates :horaires, presence: { message: 'doivent être renseignés' }, allow_nil: false
|
||||
validates :adresse, presence: { message: 'doit être renseignée' }, allow_nil: false
|
||||
validates :administrateur, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||
end
|
||||
|
|
|
@ -5,12 +5,37 @@
|
|||
%span.mandatory *
|
||||
= f.text_field :nom, placeholder: 'service jeunesse et prévention, direction des affaires maritimes', required: true
|
||||
|
||||
= f.label :organisme do
|
||||
Organisme
|
||||
%span.mandatory *
|
||||
= f.text_field :organisme, placeholder: "mairie de Mours, préfecture de l'Oise, ministère de la Culture", required: true
|
||||
|
||||
= f.label :type_organisme do
|
||||
Type d’organisme
|
||||
%span.mandatory *
|
||||
|
||||
= f.select :type_organisme, Service.type_organismes.keys.map { |key| [ I18n.t("type_organisme.#{key}"), key] }
|
||||
|
||||
= f.label :email do
|
||||
Courriel
|
||||
%span.mandatory *
|
||||
= f.email_field :email, placeholder: 'contact@mon-service.fr', required: true
|
||||
|
||||
= f.label :telephone do
|
||||
Numéro de téléphone
|
||||
%span.mandatory *
|
||||
= f.telephone_field :telephone, placeholder: '04 12 24 42 37', required: true
|
||||
|
||||
= f.label :horaires do
|
||||
Horaires
|
||||
%span.mandatory *
|
||||
= f.text_area :horaires, placeholder: "Du lundi au vendredi de 9 h 30 à 17 h 30\nLe samedi de 9 h 30 à 12 h", required: true
|
||||
|
||||
= f.label :adresse do
|
||||
Adresse
|
||||
%span.mandatory *
|
||||
= f.text_area :adresse, placeholder: "20 avenue de Ségur\n75007 Paris", required: true
|
||||
|
||||
- if procedure_id.present?
|
||||
= hidden_field_tag :procedure_id, procedure_id
|
||||
|
||||
|
|
9
db/migrate/20180509152919_add_columns_to_service.rb
Normal file
9
db/migrate/20180509152919_add_columns_to_service.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
class AddColumnsToService < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :services, :organisme, :string
|
||||
add_column :services, :email, :string
|
||||
add_column :services, :telephone, :string
|
||||
add_column :services, :horaires, :text
|
||||
add_column :services, :adresse, :text
|
||||
end
|
||||
end
|
|
@ -519,6 +519,11 @@ ActiveRecord::Schema.define(version: 2018_05_15_135415) do
|
|||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "administrateur_id"
|
||||
t.string "organisme"
|
||||
t.string "email"
|
||||
t.string "telephone"
|
||||
t.text "horaires"
|
||||
t.text "adresse"
|
||||
t.index ["administrateur_id", "nom"], name: "index_services_on_administrateur_id_and_nom", unique: true
|
||||
t.index ["administrateur_id"], name: "index_services_on_administrateur_id"
|
||||
end
|
||||
|
|
|
@ -12,7 +12,12 @@ describe NewAdministrateur::ServicesController, type: :controller do
|
|||
{
|
||||
service: {
|
||||
nom: 'super service',
|
||||
type_organisme: 'region'
|
||||
organisme: 'organisme',
|
||||
type_organisme: 'region',
|
||||
email: 'email@toto.com',
|
||||
telephone: '1234',
|
||||
horaires: 'horaires',
|
||||
adresse: 'adresse'
|
||||
},
|
||||
procedure_id: 12
|
||||
}
|
||||
|
@ -21,7 +26,12 @@ describe NewAdministrateur::ServicesController, type: :controller do
|
|||
it { expect(flash.alert).to be_nil }
|
||||
it { expect(flash.notice).to eq('super service créé') }
|
||||
it { expect(Service.last.nom).to eq('super service') }
|
||||
it { expect(Service.last.organisme).to eq('organisme') }
|
||||
it { expect(Service.last.type_organisme).to eq('region') }
|
||||
it { expect(Service.last.email).to eq('email@toto.com') }
|
||||
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(response).to redirect_to(services_path(procedure_id: 12)) }
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
FactoryBot.define do
|
||||
factory :service do
|
||||
nom 'service'
|
||||
organisme 'organisme'
|
||||
type_organisme 'commune'
|
||||
administrateur { create(:administrateur) }
|
||||
email 'email@toto.com'
|
||||
telephone '1234'
|
||||
horaires 'de 9 h à 18 h'
|
||||
adresse 'adresse'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,12 @@ describe Service, type: :model do
|
|||
let(:params) do
|
||||
{
|
||||
nom: 'service des jardins',
|
||||
organisme: 'mairie des iles',
|
||||
type_organisme: 'commune',
|
||||
email: 'super@email.com',
|
||||
telephone: '1212202',
|
||||
horaires: 'du lundi au vendredi',
|
||||
adresse: '12 rue des schtroumpfs',
|
||||
administrateur_id: administrateur.id
|
||||
}
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue