Enable test revisions

This commit is contained in:
Paul Chavard 2021-06-24 11:57:05 +02:00
parent f288528e07
commit 280e54b59d
12 changed files with 36 additions and 44 deletions

View file

@ -27,7 +27,7 @@ module NewAdministrateur
end
def reset_procedure
if @procedure.brouillon?
if @procedure.brouillon? || @procedure.draft_changed?
@procedure.reset!
end
end

View file

@ -55,11 +55,8 @@ module NewAdministrateur
def show
@procedure = current_administrateur.procedures.find(params[:id])
@current_administrateur = current_administrateur
if @procedure.brouillon?
@procedure_lien = commencer_test_url(path: @procedure.path)
else
@procedure_lien = commencer_url(path: @procedure.path)
end
@procedure_lien = commencer_url(path: @procedure.path)
@procedure_lien_test = commencer_test_url(path: @procedure.path)
end
def edit
@ -142,11 +139,8 @@ module NewAdministrateur
end
def publication
if @procedure.brouillon?
@procedure_lien = commencer_test_url(path: @procedure.path)
else
@procedure_lien = commencer_url(path: @procedure.path)
end
@procedure_lien = commencer_url(path: @procedure.path)
@procedure_lien_test = commencer_test_url(path: @procedure.path)
@procedure.path = @procedure.suggested_path(current_administrateur)
@current_administrateur = current_administrateur
end

View file

@ -5,13 +5,15 @@ module Users
def commencer
@procedure = retrieve_procedure
return procedure_not_found if @procedure.blank? || @procedure.brouillon?
@revision = @procedure.published_revision
render 'commencer/show'
end
def commencer_test
@procedure = retrieve_procedure
return procedure_not_found if @procedure.blank? || @procedure.publiee?
return procedure_not_found if @procedure.blank? || (@procedure.publiee? && !@procedure.draft_changed?)
@revision = @procedure.draft_revision
render 'commencer/show'
end
@ -20,14 +22,14 @@ module Users
@procedure = retrieve_procedure
return procedure_not_found if @procedure.blank? || @procedure.brouillon?
generate_empty_pdf(@procedure)
generate_empty_pdf(@procedure.published_revision)
end
def dossier_vide_pdf_test
@procedure = retrieve_procedure
return procedure_not_found if @procedure.blank? || @procedure.publiee?
return procedure_not_found if @procedure.blank? || (@procedure.publiee? && !@procedure.draft_changed?)
generate_empty_pdf(@procedure)
generate_empty_pdf(@procedure.draft_revision)
end
def sign_in
@ -80,10 +82,10 @@ module Users
store_location_for(:user, helpers.procedure_lien(procedure))
end
def generate_empty_pdf(procedure)
@dossier = procedure.active_revision.new_dossier
def generate_empty_pdf(revision)
@dossier = revision.new_dossier
s = render_to_string(template: 'dossiers/dossier_vide', formats: [:pdf])
send_data(s, :filename => "#{procedure.libelle}.pdf")
send_data(s, :filename => "#{revision.procedure.libelle}.pdf")
end
end
end

View file

@ -242,18 +242,18 @@ module Users
erase_user_location!
begin
if params[:brouillon]
procedure = Procedure.brouillon.find(params[:procedure_id])
procedure = if params[:brouillon]
Procedure.publiees.or(Procedure.brouillons).find(params[:procedure_id])
else
procedure = Procedure.publiees.find(params[:procedure_id])
Procedure.publiees.find(params[:procedure_id])
end
rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.procedure_not_found')
return redirect_to url_for dossiers_path
return redirect_to dossiers_path
end
dossier = Dossier.new(
revision: procedure.active_revision,
revision: params[:brouillon] ? procedure.draft_revision : procedure.active_revision,
groupe_instructeur: procedure.defaut_groupe_instructeur_for_new_dossier,
user: current_user,
state: Dossier.states.fetch(:brouillon)
@ -303,7 +303,7 @@ module Users
end
def show_demarche_en_test_banner
if @dossier.present? && @dossier.procedure.brouillon?
if @dossier.present? && @dossier.revision.draft?
flash.now.alert = "Ce dossier est déposé sur une démarche en test. Toute modification de la démarche par l'administrateur (ajout dun champ, publication de la démarche...) entraînera sa suppression."
end
end