Rename and remove attribut into Dossier
This commit is contained in:
parent
017c90f7b6
commit
810395c428
15 changed files with 24 additions and 69 deletions
|
@ -9,8 +9,8 @@ class CarteController < ApplicationController
|
|||
|
||||
def save_ref_api_carto
|
||||
dossier = current_dossier
|
||||
if dossier.ref_dossier.blank?
|
||||
dossier.update_attributes(ref_dossier: params[:ref_dossier])
|
||||
if dossier.ref_dossier_carto.blank?
|
||||
dossier.update_attributes(ref_dossier_carto: params[:ref_dossier])
|
||||
redirect_to url_for(controller: :description, action: :show, dossier_id: params[:dossier_id])
|
||||
else
|
||||
commentaire_params = {
|
||||
|
|
|
@ -52,6 +52,6 @@ class DescriptionController < ApplicationController
|
|||
private
|
||||
|
||||
def create_params
|
||||
params.permit(:nom_projet, :description, :montant_projet, :montant_aide_demande, :date_previsionnelle, :lien_plus_infos, :mail_contact)
|
||||
params.permit(:nom_projet, :description, :montant_projet, :montant_aide_demande, :date_previsionnelle)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,8 @@ class RecapitulatifController < ApplicationController
|
|||
|
||||
@commentaires = @commentaires.all.decorate
|
||||
|
||||
@commentaire_email = @dossier.mail_contact
|
||||
#TODO load user email
|
||||
@commentaire_email = 'user@email'
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
redirect_to url_for(controller: :start, action: :error_dossier)
|
||||
end
|
||||
|
|
|
@ -14,7 +14,6 @@ class Dossier < ActiveRecord::Base
|
|||
|
||||
after_save :build_default_pieces_justificatives, if: Proc.new { procedure_id_changed? }
|
||||
|
||||
validates :mail_contact, format: { with: /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/ }, unless: 'mail_contact.nil?'
|
||||
validates :nom_projet, presence: true, allow_blank: false, allow_nil: true
|
||||
validates :description, presence: true, allow_blank: false, allow_nil: true
|
||||
validates :montant_projet, presence: true, allow_blank: false, allow_nil: true
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
%script{type: 'text/javascript'}
|
||||
="url_carte = '#{@dossier.id}/'"
|
||||
="ref_dossier = '#{@dossier.ref_dossier}'"
|
||||
="ref_dossier = '#{@dossier.ref_dossier_carto}'"
|
||||
|
||||
= render partial: '/dossiers/infos_entreprise'
|
||||
%br
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
%script{type: 'text/javascript'}
|
||||
="var dossier_id =#{@dossier.id}"
|
||||
="var ref_dossier=#{@dossier.ref_dossier}"
|
||||
="var ref_dossier=#{@dossier.ref_dossier_carto}"
|
||||
|
||||
%div#sources_JS_api_carto_backend
|
||||
|
||||
|
|
|
@ -33,10 +33,6 @@
|
|||
%h4 Date prévisionnelle du début de votre projet *
|
||||
= text_field_tag :date_previsionnelle, @dossier.date_previsionnelle, placeholder: 'Date prévisionnelle', class: 'form-control', 'data-provide' => 'datepicker', 'data-date-format' => 'dd/mm/yyyy'
|
||||
|
||||
.col-lg-6.col-md-6
|
||||
%h4 Mail de contact *
|
||||
= email_field_tag :mail_contact, @dossier.mail_contact, placeholder: 'Mail de contact', class: 'form-control'
|
||||
|
||||
%br
|
||||
%h3 Documents administratifs
|
||||
|
||||
|
|
|
@ -24,13 +24,6 @@
|
|||
%p
|
||||
= @dossier.date_fr
|
||||
|
||||
.col-lg-6.col-md-6
|
||||
%br
|
||||
%h4 Contact
|
||||
|
||||
%a{ href: "mailto:#{@dossier.mail_contact}" }
|
||||
= @dossier.mail_contact
|
||||
|
||||
-if !request.url.include?('admin')
|
||||
.col-lg-6.col-md-6
|
||||
%br
|
||||
|
|
|
@ -4,7 +4,6 @@ fr:
|
|||
dossier: 'Dossier'
|
||||
attributes:
|
||||
dossier:
|
||||
mail_contact: 'Le mail de contact'
|
||||
nom_projet: 'Le nom du projet'
|
||||
description: 'La description'
|
||||
montant_projet: 'Le montant du projet'
|
||||
|
|
8
db/migrate/20150922113504_change_attributs_to_dossier.rb
Normal file
8
db/migrate/20150922113504_change_attributs_to_dossier.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
class ChangeAttributsToDossier < ActiveRecord::Migration
|
||||
def change
|
||||
remove_column :dossiers, :lien_plus_infos
|
||||
remove_column :dossiers, :mail_contact
|
||||
|
||||
rename_column :dossiers, :ref_dossier, :ref_dossier_carto
|
||||
end
|
||||
end
|
10
db/schema.rb
10
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150922110719) do
|
||||
ActiveRecord::Schema.define(version: 20150922113504) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -38,17 +38,15 @@ ActiveRecord::Schema.define(version: 20150922110719) do
|
|||
t.boolean "autorisation_donnees"
|
||||
t.string "position_lat"
|
||||
t.string "position_lon"
|
||||
t.string "ref_dossier"
|
||||
t.string "ref_dossier_carto"
|
||||
t.string "nom_projet"
|
||||
t.string "montant_projet"
|
||||
t.string "montant_aide_demande"
|
||||
t.string "lien_plus_infos"
|
||||
t.string "mail_contact"
|
||||
t.boolean "dossier_termine"
|
||||
t.integer "procedure_id"
|
||||
t.date "date_previsionnelle"
|
||||
t.datetime "created_at", default: '2015-09-22 09:25:29'
|
||||
t.datetime "updated_at", default: '2015-09-22 09:25:29'
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
add_index "dossiers", ["procedure_id"], name: "index_dossiers_on_procedure_id", using: :btree
|
||||
|
|
|
@ -24,7 +24,6 @@ describe DescriptionController, type: :controller do
|
|||
let(:montant_projet) { 12_000 }
|
||||
let(:montant_aide_demande) { 3000 }
|
||||
let(:date_previsionnelle) { '20/01/2016' }
|
||||
let(:mail_contact) { 'test@test.com' }
|
||||
|
||||
let(:name_piece_justificative) { 'dossierPDF.pdf' }
|
||||
let(:name_piece_justificative_0) { 'piece_justificative_0.pdf' }
|
||||
|
@ -37,14 +36,14 @@ describe DescriptionController, type: :controller do
|
|||
context 'Tous les attributs sont bons' do
|
||||
# TODO separer en deux tests : check donnees et check redirect
|
||||
it 'Premier enregistrement des données' do
|
||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle, mail_contact: mail_contact
|
||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle
|
||||
expect(response).to redirect_to("/dossiers/#{dossier_id}/recapitulatif")
|
||||
end
|
||||
|
||||
# TODO changer les valeurs des champs et check in bdd
|
||||
context 'En train de modifier les données de description du projet' do
|
||||
before do
|
||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle, mail_contact: mail_contact, back_url: 'recapitulatif'
|
||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle, back_url: 'recapitulatif'
|
||||
end
|
||||
|
||||
context 'Enregistrement d\'un commentaire informant la modification' do
|
||||
|
@ -77,8 +76,7 @@ describe DescriptionController, type: :controller do
|
|||
description: description,
|
||||
montant_projet: montant_projet,
|
||||
montant_aide_demande: montant_aide_demande,
|
||||
date_previsionnelle: date_previsionnelle,
|
||||
mail_contact: mail_contact
|
||||
date_previsionnelle: date_previsionnelle
|
||||
}
|
||||
before { subject }
|
||||
|
||||
|
@ -111,20 +109,6 @@ describe DescriptionController, type: :controller do
|
|||
it { is_expected.to render_template(:show) }
|
||||
it { expect(flash[:alert]).to be_present }
|
||||
end
|
||||
|
||||
it 'mail_contact manquant' do
|
||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle, mail_contact: ''
|
||||
expect(response).to render_template('show')
|
||||
expect(flash[:alert]).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
context 'Mauvais format(s)' do
|
||||
it 'mail_contact n\'est un format d\'email' do
|
||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle, mail_contact: 'test.com'
|
||||
expect(response).to render_template('show')
|
||||
expect(flash[:alert]).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
context 'Sauvegarde du CERFA PDF' do
|
||||
|
@ -135,7 +119,6 @@ describe DescriptionController, type: :controller do
|
|||
montant_projet: montant_projet,
|
||||
montant_aide_demande: montant_aide_demande,
|
||||
date_previsionnelle: date_previsionnelle,
|
||||
mail_contact: mail_contact,
|
||||
cerfa_pdf: cerfa_pdf
|
||||
dossier.reload
|
||||
end
|
||||
|
@ -153,7 +136,7 @@ describe DescriptionController, type: :controller do
|
|||
|
||||
context 'les anciens CERFA PDF sont écrasées à chaque fois' do
|
||||
it 'il n\'y a qu\'un CERFA PDF par dossier' do
|
||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle, mail_contact: mail_contact, cerfa_pdf: cerfa_pdf
|
||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle, cerfa_pdf: cerfa_pdf
|
||||
cerfa = PieceJustificative.where(type_de_piece_justificative_id: '0', dossier_id: dossier_id)
|
||||
expect(cerfa.many?).to eq(false)
|
||||
end
|
||||
|
@ -173,7 +156,6 @@ describe DescriptionController, type: :controller do
|
|||
montant_projet: montant_projet,
|
||||
montant_aide_demande: montant_aide_demande,
|
||||
date_previsionnelle: date_previsionnelle,
|
||||
mail_contact: mail_contact,
|
||||
'piece_justificative_'+all_pj_type[0].to_s => piece_justificative_0,
|
||||
'piece_justificative_'+all_pj_type[1].to_s => piece_justificative_1}
|
||||
dossier.reload
|
||||
|
|
|
@ -45,14 +45,6 @@ feature 'Description#Show Page' do
|
|||
expect(page).to have_selector('input[type=text][id=date_previsionnelle][data-provide=datepicker]')
|
||||
end
|
||||
|
||||
scenario 'Mail de contact' do
|
||||
expect(page).to have_selector('input[id=mail_contact][name=mail_contact]')
|
||||
end
|
||||
|
||||
scenario 'Mail de contact est de type mail' do
|
||||
expect(page).to have_selector('input[type=email][id=mail_contact]')
|
||||
end
|
||||
|
||||
scenario 'Charger votre CERFA (PDF)' do
|
||||
expect(page).to have_selector('input[type=file][name=cerfa_pdf][id=cerfa_pdf]')
|
||||
end
|
||||
|
@ -97,8 +89,7 @@ feature 'Description#Show Page' do
|
|||
description: 'Description de test',
|
||||
montant_projet: 12_000,
|
||||
montant_aide_demande: 3000,
|
||||
date_previsionnelle: '20/01/2016',
|
||||
mail_contact: 'test@test.com')
|
||||
date_previsionnelle: '20/01/2016')
|
||||
end
|
||||
|
||||
scenario 'Nom du projet' do
|
||||
|
@ -120,10 +111,6 @@ feature 'Description#Show Page' do
|
|||
scenario 'Date prévisionnelle du projet' do
|
||||
expect(page).to have_selector("input[id=date_previsionnelle][value='#{dossier.date_previsionnelle}']")
|
||||
end
|
||||
|
||||
scenario 'Mail de contact' do
|
||||
expect(page).to have_selector("input[id=mail_contact][value='#{dossier.mail_contact}']")
|
||||
end
|
||||
end
|
||||
|
||||
context 'Pièces justificatives' do
|
||||
|
|
|
@ -14,7 +14,6 @@ feature 'user is on description page' do
|
|||
find_by_id('montant_projet').set 10_000
|
||||
find_by_id('montant_aide_demande').set 100
|
||||
find_by_id('date_previsionnelle').set '10/10/2010'
|
||||
find_by_id('mail_contact').set 'plop@plop.com'
|
||||
end
|
||||
context 'before submit' do
|
||||
it 'dossier cerfa is empty' do
|
||||
|
|
|
@ -6,13 +6,10 @@ describe Dossier do
|
|||
it { is_expected.to have_db_column(:autorisation_donnees) }
|
||||
it { is_expected.to have_db_column(:position_lat) }
|
||||
it { is_expected.to have_db_column(:position_lon) }
|
||||
it { is_expected.to have_db_column(:ref_dossier) }
|
||||
it { is_expected.to have_db_column(:nom_projet) }
|
||||
it { is_expected.to have_db_column(:montant_projet) }
|
||||
it { is_expected.to have_db_column(:montant_aide_demande) }
|
||||
it { is_expected.to have_db_column(:date_previsionnelle).of_type(:date) }
|
||||
it { is_expected.to have_db_column(:lien_plus_infos) }
|
||||
it { is_expected.to have_db_column(:mail_contact) }
|
||||
it { is_expected.to have_db_column(:dossier_termine) }
|
||||
it { is_expected.to have_db_column(:created_at) }
|
||||
it { is_expected.to have_db_column(:updated_at) }
|
||||
|
@ -34,10 +31,6 @@ describe Dossier do
|
|||
end
|
||||
|
||||
describe 'validation' do
|
||||
context 'mail_contact' do
|
||||
it { is_expected.to allow_value('tanguy@plop.com').for(:mail_contact) }
|
||||
it { is_expected.not_to allow_value('tanguyplop.com').for(:mail_contact) }
|
||||
end
|
||||
context 'nom_projet' do
|
||||
it { is_expected.to allow_value(nil).for(:nom_projet) }
|
||||
it { is_expected.not_to allow_value('').for(:nom_projet) }
|
||||
|
|
Loading…
Reference in a new issue