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
|
end
|
||||||
|
|
||||||
def path_list
|
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})
|
|acc, value| acc.push({label: value.first, mine: value.second == current_administrateur.id})
|
||||||
}.to_json
|
}.to_json
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,6 +30,13 @@ class Users::DossiersController < UsersController
|
||||||
procedure = ProcedurePath.where(path: params[:procedure_path]).first!.procedure
|
procedure = ProcedurePath.where(path: params[:procedure_path]).first!.procedure
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if procedure.archived?
|
||||||
|
|
||||||
|
@dossier = Dossier.new(procedure: procedure)
|
||||||
|
|
||||||
|
return render 'commencer/archived'
|
||||||
|
end
|
||||||
|
|
||||||
redirect_to new_users_dossier_path(procedure_id: procedure.id)
|
redirect_to new_users_dossier_path(procedure_id: procedure.id)
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
error_procedure
|
error_procedure
|
||||||
|
|
|
@ -103,7 +103,6 @@ class Procedure < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def archive
|
def archive
|
||||||
self.procedure_path.destroy! if self.path
|
|
||||||
self.update_attributes!({archived: true})
|
self.update_attributes!({archived: true})
|
||||||
end
|
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
|
#form_login
|
||||||
%br
|
%br
|
||||||
- if @dossier
|
= render partial: 'users/sessions/resume_procedure'
|
||||||
= 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
|
|
||||||
|
|
||||||
%h2#login_user
|
%h2#login_user
|
||||||
=t('dynamics.users.connexion_title')
|
=t('dynamics.users.connexion_title')
|
||||||
|
|
|
@ -299,7 +299,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
it 'archive previous procedure' do
|
it 'archive previous procedure' do
|
||||||
expect(procedure2.published).to be_truthy
|
expect(procedure2.published).to be_truthy
|
||||||
expect(procedure2.archived).to be_truthy
|
expect(procedure2.archived).to be_truthy
|
||||||
expect(procedure2.path).to be_nil
|
expect(procedure2.path).not_to be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -427,21 +427,31 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
let!(:procedure) { create(:procedure, :published, administrateur: admin) }
|
let!(:procedure) { create(:procedure, :published, administrateur: admin) }
|
||||||
let(:admin2) { create(:administrateur) }
|
let(:admin2) { create(:administrateur) }
|
||||||
let!(:procedure2) { create(:procedure, :published, administrateur: admin2) }
|
let!(:procedure2) { create(:procedure, :published, administrateur: admin2) }
|
||||||
|
let!(:procedure3) { create(:procedure, :published, administrateur: admin2) }
|
||||||
|
|
||||||
subject { get :path_list }
|
subject { get :path_list }
|
||||||
|
|
||||||
let(:body) { JSON.parse(response.body) }
|
let(:body) { JSON.parse(response.body) }
|
||||||
|
|
||||||
before do
|
describe 'when no params' do
|
||||||
subject
|
before do
|
||||||
|
subject
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(response.status).to eq(200) }
|
||||||
|
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
|
end
|
||||||
|
|
||||||
it { expect(response.status).to eq(200) }
|
|
||||||
it { expect(body.size).to eq(2) }
|
|
||||||
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 }
|
|
||||||
|
|
||||||
context 'filtered' do
|
context 'filtered' do
|
||||||
|
before do
|
||||||
|
subject
|
||||||
|
end
|
||||||
|
|
||||||
subject { get :path_list, request: procedure2.path }
|
subject { get :path_list, request: procedure2.path }
|
||||||
|
|
||||||
it { expect(response.status).to eq(200) }
|
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['label']).to eq(procedure2.path) }
|
||||||
it { expect(body.first['mine']).to be_falsy }
|
it { expect(body.first['mine']).to be_falsy }
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe 'POST transfer' do
|
describe 'POST transfer' do
|
||||||
|
@ -467,7 +489,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
let(:email_admin) { new_admin.email }
|
let(:email_admin) { new_admin.email }
|
||||||
|
|
||||||
it { expect(subject.status).to eq 200 }
|
it { expect(subject.status).to eq 200 }
|
||||||
it { expect {subject}.to change(Procedure, :count).by(1) }
|
it { expect { subject }.to change(Procedure, :count).by(1) }
|
||||||
|
|
||||||
context {
|
context {
|
||||||
before do
|
before do
|
||||||
|
|
|
@ -157,6 +157,16 @@ describe Users::DossiersController, type: :controller do
|
||||||
|
|
||||||
it { expect(subject.status).to eq 302 }
|
it { expect(subject.status).to eq 302 }
|
||||||
it { expect(subject).to redirect_to new_users_dossier_path(procedure_id: procedure.id) }
|
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
|
end
|
||||||
|
|
||||||
describe 'POST #siret_informations' do
|
describe 'POST #siret_informations' do
|
||||||
|
|
|
@ -243,14 +243,14 @@ describe Procedure do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is not available from a valid path anymore' do
|
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.published).to be_truthy
|
||||||
expect(procedure.archived).to be_truthy
|
expect(procedure.archived).to be_truthy
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is not in ProcedurePath table anymore' do
|
it 'is not in ProcedurePath table anymore' do
|
||||||
expect(ProcedurePath.where(path: procedure.path).count).to eq(0)
|
expect(ProcedurePath.where(path: procedure.path).count).to eq(1)
|
||||||
expect(ProcedurePath.find_by_procedure_id(procedure.id)).to be_nil
|
expect(ProcedurePath.find_by_procedure_id(procedure.id)).not_to be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue