Add page « Procédure terminée »
This commit is contained in:
parent
511cabf95a
commit
5284df5ce0
9 changed files with 93 additions and 35 deletions
|
@ -179,7 +179,12 @@ class Admin::ProceduresController < AdminController
|
|||
end
|
||||
|
||||
def path_list
|
||||
render json: ProcedurePath.where("path LIKE '%#{params[:request]}%'").pluck(:path, :administrateur_id).inject([]) {
|
||||
render json: ProcedurePath
|
||||
.joins(', procedures')
|
||||
.where("procedures.id = procedure_paths.procedure_id AND procedures.archived != true")
|
||||
.where("path LIKE '%#{params[:request]}%'")
|
||||
.pluck(:path, :administrateur_id)
|
||||
.inject([]) {
|
||||
|acc, value| acc.push({label: value.first, mine: value.second == current_administrateur.id})
|
||||
}.to_json
|
||||
end
|
||||
|
|
|
@ -30,6 +30,13 @@ class Users::DossiersController < UsersController
|
|||
procedure = ProcedurePath.where(path: params[:procedure_path]).first!.procedure
|
||||
end
|
||||
|
||||
if procedure.archived?
|
||||
|
||||
@dossier = Dossier.new(procedure: procedure)
|
||||
|
||||
return render 'commencer/archived'
|
||||
end
|
||||
|
||||
redirect_to new_users_dossier_path(procedure_id: procedure.id)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
error_procedure
|
||||
|
|
|
@ -103,7 +103,6 @@ class Procedure < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def archive
|
||||
self.procedure_path.destroy! if self.path
|
||||
self.update_attributes!({archived: true})
|
||||
end
|
||||
|
||||
|
|
15
app/views/commencer/archived.html.haml
Normal file
15
app/views/commencer/archived.html.haml
Normal file
|
@ -0,0 +1,15 @@
|
|||
%br
|
||||
%div{style: 'text-align: center; max-width:500px; margin-left:auto; margin-right:auto; padding: 20px;'}
|
||||
= render partial: 'users/sessions/resume_procedure'
|
||||
|
||||
.center{style:'margin-top: -20px'}
|
||||
%h3
|
||||
La campagne de création de nouveau dossier
|
||||
%br
|
||||
pour cette démarche en ligne est maintenant terminée.
|
||||
|
||||
%br
|
||||
%p
|
||||
Si vous avez déjà déposé un ou plusieurs dossiers :
|
||||
%a.btn.btn-lg.btn-info{href: new_user_session_path}
|
||||
Accéder à mon espace en ligne.
|
18
app/views/users/sessions/_resume_procedure.html.haml
Normal file
18
app/views/users/sessions/_resume_procedure.html.haml
Normal file
|
@ -0,0 +1,18 @@
|
|||
- if @dossier
|
||||
= link_to 'X', users_no_procedure_url, class: 'btn btn-xs', style:'float: right'
|
||||
|
||||
- if @dossier.procedure.euro_flag
|
||||
#euro_flag.flag
|
||||
=image_tag('drapeau_europe.png')
|
||||
|
||||
#logo_procedure.flag
|
||||
=image_tag( @dossier.procedure.decorate.logo_img )
|
||||
|
||||
%h2#titre_procedure.text-info
|
||||
= @dossier.procedure.libelle
|
||||
%p
|
||||
= h @dossier.procedure.description.html_safe
|
||||
|
||||
- else
|
||||
= image_tag(image_url(LOGO_NAME), {id: 'logo_tps'})
|
||||
%br
|
|
@ -1,24 +1,6 @@
|
|||
#form_login
|
||||
%br
|
||||
- if @dossier
|
||||
= link_to 'X', users_no_procedure_url, class: 'btn btn-xs', style:'float: right'
|
||||
|
||||
- if @dossier.procedure.euro_flag
|
||||
#euro_flag.flag
|
||||
=image_tag('drapeau_europe.png')
|
||||
|
||||
#logo_procedure.flag
|
||||
=image_tag( @dossier.procedure.decorate.logo_img )
|
||||
|
||||
%h2#titre_procedure.text-info
|
||||
= @dossier.procedure.libelle
|
||||
%p
|
||||
= h @dossier.procedure.description.html_safe
|
||||
|
||||
|
||||
- else
|
||||
= image_tag(image_url(LOGO_NAME), {id: 'logo_tps'})
|
||||
%br
|
||||
= render partial: 'users/sessions/resume_procedure'
|
||||
|
||||
%h2#login_user
|
||||
=t('dynamics.users.connexion_title')
|
||||
|
|
|
@ -299,7 +299,7 @@ describe Admin::ProceduresController, type: :controller do
|
|||
it 'archive previous procedure' do
|
||||
expect(procedure2.published).to be_truthy
|
||||
expect(procedure2.archived).to be_truthy
|
||||
expect(procedure2.path).to be_nil
|
||||
expect(procedure2.path).not_to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -427,21 +427,31 @@ describe Admin::ProceduresController, type: :controller do
|
|||
let!(:procedure) { create(:procedure, :published, administrateur: admin) }
|
||||
let(:admin2) { create(:administrateur) }
|
||||
let!(:procedure2) { create(:procedure, :published, administrateur: admin2) }
|
||||
let!(:procedure3) { create(:procedure, :published, administrateur: admin2) }
|
||||
|
||||
subject { get :path_list }
|
||||
|
||||
let(:body) { JSON.parse(response.body) }
|
||||
|
||||
describe 'when no params' do
|
||||
before do
|
||||
subject
|
||||
end
|
||||
|
||||
it { expect(response.status).to eq(200) }
|
||||
it { expect(body.size).to eq(2) }
|
||||
it { expect(body.size).to eq(3) }
|
||||
it { expect(body.first['label']).to eq(procedure.path) }
|
||||
it { expect(body.first['mine']).to be_truthy }
|
||||
it { expect(body.second['label']).to eq(procedure2.path) }
|
||||
it { expect(body.second['mine']).to be_falsy }
|
||||
|
||||
end
|
||||
|
||||
context 'filtered' do
|
||||
before do
|
||||
subject
|
||||
end
|
||||
|
||||
subject { get :path_list, request: procedure2.path }
|
||||
|
||||
it { expect(response.status).to eq(200) }
|
||||
|
@ -449,6 +459,18 @@ describe Admin::ProceduresController, type: :controller do
|
|||
it { expect(body.first['label']).to eq(procedure2.path) }
|
||||
it { expect(body.first['mine']).to be_falsy }
|
||||
end
|
||||
|
||||
context 'when procedure is archived' do
|
||||
|
||||
before do
|
||||
procedure3.update_attribute :archived, true
|
||||
subject
|
||||
end
|
||||
|
||||
it 'do not return on the json' do
|
||||
expect(body.size).to eq(2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST transfer' do
|
||||
|
|
|
@ -157,6 +157,16 @@ describe Users::DossiersController, type: :controller do
|
|||
|
||||
it { expect(subject.status).to eq 302 }
|
||||
it { expect(subject).to redirect_to new_users_dossier_path(procedure_id: procedure.id) }
|
||||
|
||||
context 'when procedure is archived' do
|
||||
let(:procedure) { create(:procedure, :published, archived: true) }
|
||||
|
||||
before do
|
||||
procedure.update_column :archived, true
|
||||
end
|
||||
|
||||
it { expect(subject.status).to eq 200 }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #siret_informations' do
|
||||
|
|
|
@ -243,14 +243,14 @@ describe Procedure do
|
|||
end
|
||||
|
||||
it 'is not available from a valid path anymore' do
|
||||
expect(procedure.path).to be_nil
|
||||
expect(procedure.path).to eq procedure_path.path
|
||||
expect(procedure.published).to be_truthy
|
||||
expect(procedure.archived).to be_truthy
|
||||
end
|
||||
|
||||
it 'is not in ProcedurePath table anymore' do
|
||||
expect(ProcedurePath.where(path: procedure.path).count).to eq(0)
|
||||
expect(ProcedurePath.find_by_procedure_id(procedure.id)).to be_nil
|
||||
expect(ProcedurePath.where(path: procedure.path).count).to eq(1)
|
||||
expect(ProcedurePath.find_by_procedure_id(procedure.id)).not_to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue