Merge pull request #519 from sgmap/change_attestation_on_published_procedure
Change attestation on published procedure
This commit is contained in:
commit
1e91867995
5 changed files with 7 additions and 32 deletions
|
@ -1,16 +1,6 @@
|
||||||
class Admin::AttestationTemplatesController < AdminController
|
class Admin::AttestationTemplatesController < AdminController
|
||||||
before_action :retrieve_procedure
|
before_action :retrieve_procedure
|
||||||
|
|
||||||
def show
|
|
||||||
attestation_template = @procedure.attestation_template
|
|
||||||
@logo = attestation_template.logo
|
|
||||||
@title = attestation_template.title
|
|
||||||
@body = attestation_template.body
|
|
||||||
@signature = attestation_template.signature
|
|
||||||
@footer = attestation_template.footer
|
|
||||||
@created_at = DateTime.now
|
|
||||||
end
|
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@attestation_template = @procedure.attestation_template || AttestationTemplate.new(procedure: @procedure)
|
@attestation_template = @procedure.attestation_template || AttestationTemplate.new(procedure: @procedure)
|
||||||
end
|
end
|
||||||
|
|
|
@ -63,10 +63,11 @@
|
||||||
%button.btn.btn-primary{ formaction: admin_procedure_attestation_template_preview_path, formtarget: '_blank' } Prévisualiser
|
%button.btn.btn-primary{ formaction: admin_procedure_attestation_template_preview_path, formtarget: '_blank' } Prévisualiser
|
||||||
|
|
||||||
.pull-right
|
.pull-right
|
||||||
- if @attestation_template.activated
|
- if @attestation_template.activated && !@procedure.locked?
|
||||||
%button.btn.btn-warning{ formaction: admin_procedure_attestation_template_disactivate_path } désactiver l'attestation
|
%button.btn.btn-warning{ formaction: admin_procedure_attestation_template_disactivate_path } désactiver l'attestation
|
||||||
|
|
||||||
- if @attestation_template.id.nil? || !@attestation_template.activated
|
- if @attestation_template.new_record? || !@attestation_template.activated
|
||||||
%button.btn.btn-success Activer l'attestation
|
%button.btn.btn-success Activer l'attestation
|
||||||
- else
|
- else
|
||||||
%button.btn.btn-success Enregistrer
|
- save_data = @procedure.locked? ? { toggle: :tooltip, confirm: "Attention: les modifications n'affecteront pas les attestations déjà délivrées." } : nil
|
||||||
|
%button.btn.btn-success{ data: save_data } Enregistrer
|
||||||
|
|
|
@ -45,12 +45,8 @@
|
||||||
.procedure-list-element{ class: ('active' if active == 'Prévisualisation') }
|
.procedure-list-element{ class: ('active' if active == 'Prévisualisation') }
|
||||||
Prévisualisation
|
Prévisualisation
|
||||||
|
|
||||||
- if !@procedure.locked?
|
|
||||||
%a#onglet-attestation{ href: url_for(edit_admin_procedure_attestation_template_path(@procedure)) }
|
%a#onglet-attestation{ href: url_for(edit_admin_procedure_attestation_template_path(@procedure)) }
|
||||||
.procedure-list-element{ class: ('active' if active == 'Attestation') } Attestation
|
.procedure-list-element{ class: ('active' if active == 'Attestation') } Attestation
|
||||||
- elsif @procedure.attestation_template.present?
|
|
||||||
%a#onglet-attestation{ href: url_for(admin_procedure_attestation_template_path(@procedure, format: :pdf)), target: '_blank' }
|
|
||||||
.procedure-list-element Attestation
|
|
||||||
|
|
||||||
.split-hr-left
|
.split-hr-left
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
resource :previsualisation, only: [:show]
|
resource :previsualisation, only: [:show]
|
||||||
|
|
||||||
resource :attestation_template, only: [:show, :edit, :update, :create]
|
resource :attestation_template, only: [:edit, :update, :create]
|
||||||
|
|
||||||
post 'attestation_template/disactivate' => 'attestation_templates#disactivate'
|
post 'attestation_template/disactivate' => 'attestation_templates#disactivate'
|
||||||
patch 'attestation_template/disactivate' => 'attestation_templates#disactivate'
|
patch 'attestation_template/disactivate' => 'attestation_templates#disactivate'
|
||||||
|
|
|
@ -10,18 +10,6 @@ describe Admin::AttestationTemplatesController, type: :controller do
|
||||||
Timecop.freeze(Time.now)
|
Timecop.freeze(Time.now)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET #show' do
|
|
||||||
before { get :show, params: { procedure_id: procedure.id, format: :pdf } }
|
|
||||||
|
|
||||||
it { expect(subject.status).to eq(200) }
|
|
||||||
it { expect(assigns[:title]).to eq(attestation_template.title) }
|
|
||||||
it { expect(assigns[:logo].read).to eq(attestation_template.logo.read) }
|
|
||||||
it { expect(assigns[:body]).to eq(attestation_template.body) }
|
|
||||||
it { expect(assigns[:signature].read).to eq(attestation_template.signature.read) }
|
|
||||||
it { expect(assigns[:footer]).to eq(attestation_template.footer) }
|
|
||||||
it { expect(assigns[:created_at]).to eq(DateTime.now) }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'POST #preview' do
|
describe 'POST #preview' do
|
||||||
let(:upload_params) { { title: 't', body: 'b', footer: 'f' } }
|
let(:upload_params) { { title: 't', body: 'b', footer: 'f' } }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue