Merge pull request #519 from sgmap/change_attestation_on_published_procedure

Change attestation on published procedure
This commit is contained in:
LeSim 2017-07-04 14:10:15 +02:00 committed by GitHub
commit 1e91867995
5 changed files with 7 additions and 32 deletions

View file

@ -1,16 +1,6 @@
class Admin::AttestationTemplatesController < AdminController
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
@attestation_template = @procedure.attestation_template || AttestationTemplate.new(procedure: @procedure)
end

View file

@ -63,10 +63,11 @@
%button.btn.btn-primary{ formaction: admin_procedure_attestation_template_preview_path, formtarget: '_blank' } Prévisualiser
.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
- if @attestation_template.id.nil? || !@attestation_template.activated
- if @attestation_template.new_record? || !@attestation_template.activated
%button.btn.btn-success Activer l'attestation
- 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

View file

@ -45,12 +45,8 @@
.procedure-list-element{ class: ('active' if active == 'Prévisualisation') }
Prévisualisation
- if !@procedure.locked?
%a#onglet-attestation{ href: url_for(edit_admin_procedure_attestation_template_path(@procedure)) }
.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
%a#onglet-attestation{ href: url_for(edit_admin_procedure_attestation_template_path(@procedure)) }
.procedure-list-element{ class: ('active' if active == 'Attestation') } Attestation
.split-hr-left

View file

@ -144,7 +144,7 @@ Rails.application.routes.draw do
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'
patch 'attestation_template/disactivate' => 'attestation_templates#disactivate'

View file

@ -10,18 +10,6 @@ describe Admin::AttestationTemplatesController, type: :controller do
Timecop.freeze(Time.now)
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
let(:upload_params) { { title: 't', body: 'b', footer: 'f' } }