Create facade for dossier into user and gestionnaire views

This commit is contained in:
Xavier J 2015-12-24 15:10:20 +01:00
parent 1a3aebe6ab
commit 3c18882407
22 changed files with 249 additions and 207 deletions

View file

@ -88,6 +88,9 @@ group :test do
end
group :development, :test do
gem 'terminal-notifier'
gem 'terminal-notifier-guard'
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'pry-byebug'

View file

@ -378,6 +378,8 @@ GEM
httpclient (>= 2.4)
i18n
json (>= 1.4.3)
terminal-notifier (1.6.3)
terminal-notifier-guard (1.6.4)
therubyracer (0.12.2)
libv8 (~> 3.16.14.0)
ref
@ -482,6 +484,8 @@ DEPENDENCIES
simplecov
spring
spring-commands-rspec
terminal-notifier
terminal-notifier-guard
therubyracer
timecop
turbolinks

View file

@ -2,37 +2,18 @@ class Backoffice::DossiersController < ApplicationController
before_action :authenticate_gestionnaire!
def index
if params[:liste] == 'a_traiter' || params[:liste].nil?
@dossiers = current_gestionnaire.dossiers.waiting_for_gestionnaire
@dossiers_a_traiter = @dossiers
@liste = params[:liste] || 'a_traiter'
@dossiers = dossiers_to_display.paginate(page: params[:page]).decorate
@liste = 'a_traiter'
elsif params[:liste] == 'en_attente'
@dossiers = current_gestionnaire.dossiers.waiting_for_user
@dossiers_en_attente = @dossiers
@liste = 'en_attente'
elsif params[:liste] == 'termine'
@dossiers = current_gestionnaire.dossiers.termine
@dossiers_termine = @dossiers
@liste = 'termine'
end
@dossiers = @dossiers.paginate(:page => (params[:page] || 1)).decorate
total_dossiers_per_state
end
def show
initialize_instance_params params[:id]
create_dossier_facade params[:id]
end
def search
@search_terms = params[:q]
@dossiers_search, @dossier = Dossier.search(current_gestionnaire, @search_terms)
unless @dossiers_search.empty?
@ -47,20 +28,20 @@ class Backoffice::DossiersController < ApplicationController
end
def valid
initialize_instance_params params[:dossier_id]
create_dossier_facade params[:dossier_id]
@dossier.next_step! 'gestionnaire', 'valid'
@facade.dossier.next_step! 'gestionnaire', 'valid'
flash.notice = 'Dossier confirmé avec succès.'
NotificationMailer.dossier_validated(@dossier).deliver_now!
NotificationMailer.dossier_validated(@facade.dossier).deliver_now!
render 'show'
end
def close
initialize_instance_params params[:dossier_id]
create_dossier_facade params[:dossier_id]
@dossier.next_step! 'gestionnaire', 'close'
@facade.dossier.next_step! 'gestionnaire', 'close'
flash.notice = 'Dossier traité avec succès.'
render 'show'
@ -68,25 +49,36 @@ class Backoffice::DossiersController < ApplicationController
private
def total_dossiers_per_state
@dossiers_a_traiter_total = !@dossiers_a_traiter.nil? ? @dossiers_a_traiter.size : current_gestionnaire.dossiers.waiting_for_gestionnaire.size
@dossiers_en_attente_total = !@dossiers_en_attente.nil? ? @dossiers_en_attente.size : current_gestionnaire.dossiers.waiting_for_user.size
@dossiers_termine_total = !@dossiers_termine.nil? ? @dossiers_termine.size : current_gestionnaire.dossiers.termine.size
def dossiers_to_display
{'a_traiter' => waiting_for_gestionnaire,
'en_attente' => waiting_for_user,
'termine' => termine}[@liste]
end
def initialize_instance_params dossier_id
@dossier = Dossier.where(archived: false).find(dossier_id)
@entreprise = @dossier.entreprise.decorate
@etablissement = @dossier.etablissement
@pieces_justificatives = @dossier.pieces_justificatives
@commentaires = @dossier.ordered_commentaires
@commentaires = @commentaires.all.decorate
@commentaire_email = current_gestionnaire.email
def waiting_for_gestionnaire
@a_traiter_class = (@liste == 'a_traiter' ? 'active' : '')
@waiting_for_gestionnaire ||= current_gestionnaire.dossiers.waiting_for_gestionnaire
end
@procedure = @dossier.procedure
def waiting_for_user
@en_attente_class = (@liste == 'en_attente' ? 'active' : '')
@waiting_for_user ||= current_gestionnaire.dossiers.waiting_for_user
end
def termine
@termine_class = (@liste == 'termine' ? 'active' : '')
@termine ||= current_gestionnaire.dossiers.termine
end
def total_dossiers_per_state
@dossiers_a_traiter_total = waiting_for_gestionnaire.count
@dossiers_en_attente_total = waiting_for_user.count
@dossiers_termine_total = termine.count
end
def create_dossier_facade dossier_id
@facade = DossierFacades.new dossier_id, current_gestionnaire.email
@dossier = @dossier.decorate
@champs = @dossier.ordered_champs
rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.dossier_not_found')
redirect_to url_for(controller: '/backoffice')

View file

@ -5,27 +5,9 @@ class Users::DossiersController < UsersController
def index
order = 'DESC'
if params[:liste] == 'a_traiter' || params[:liste].nil?
@dossiers = current_user.dossiers.waiting_for_user order
@dossiers_a_traiter = @dossiers
@liste = params[:liste] || 'a_traiter'
@dossiers = dossiers_to_display.paginate(page: params[:page]).decorate
@liste = 'a_traiter'
elsif params[:liste] == 'en_attente'
@dossiers = current_user.dossiers.waiting_for_gestionnaire order
@dossiers_en_attente = @dossiers
@liste = 'en_attente'
elsif params[:liste] == 'termine'
@dossiers = current_user.dossiers.termine order
@dossiers_termine = @dossiers
@liste = 'termine'
end
@dossiers = @dossiers.paginate(:page => (params[:page] || 1)).decorate
total_dossiers_per_state
end
@ -40,46 +22,43 @@ class Users::DossiersController < UsersController
end
def show
@dossier = current_user_dossier params[:id]
@facade = DossierFacades.new params[:id], current_user.email
@etablissement = @dossier.etablissement
@entreprise = @dossier.entreprise.decorate
rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.dossier_not_found')
redirect_to url_for users_dossiers_path
end
def create
@etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(siret).to_params)
@entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(siren).to_params)
etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(siret).to_params)
entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(siren).to_params)
rna_information = SIADE::RNAAdapter.new(siret).to_params
exercices = SIADE::ExercicesAdapter.new(siret).to_params
unless exercices.nil?
exercices.each_value do |exercice|
exercice = Exercice.new(exercice)
exercice.etablissement = @etablissement
exercice.etablissement = etablissement
exercice.save
end
end
@dossier = Dossier.create(user: current_user, state: 'draft', procedure_id: create_params[:procedure_id])
dossier = Dossier.create(user: current_user, state: 'draft', procedure_id: create_params[:procedure_id])
@entreprise.dossier = @dossier
@entreprise.save
entreprise.dossier = dossier
entreprise.save
unless rna_information.nil?
rna_information = RNAInformation.new(rna_information)
rna_information.entreprise = @entreprise
rna_information.entreprise = entreprise
rna_information.save
end
@etablissement.dossier = @dossier
@etablissement.entreprise = @entreprise
@etablissement.save
etablissement.dossier = dossier
etablissement.entreprise = entreprise
etablissement.save
redirect_to url_for(controller: :dossiers, action: :show, id: @dossier.id)
redirect_to url_for(controller: :dossiers, action: :show, id: dossier.id)
rescue RestClient::ResourceNotFound
errors_valid_siret
@ -90,27 +69,25 @@ class Users::DossiersController < UsersController
end
def update
@facade = DossierFacades.new params[:id], current_user.email
@dossier = current_user_dossier params[:id]
if checked_autorisation_donnees?
@dossier.update_attributes(update_params)
@facade.dossier.update_attributes(update_params)
if @dossier.procedure.module_api_carto.use_api_carto
redirect_to url_for(controller: :carte, action: :show, dossier_id: @dossier.id)
if @facade.dossier.procedure.module_api_carto.use_api_carto
redirect_to url_for(controller: :carte, action: :show, dossier_id: @facade.dossier.id)
else
redirect_to url_for(controller: :description, action: :show, dossier_id: @dossier.id)
redirect_to url_for(controller: :description, action: :show, dossier_id: @facade.dossier.id)
end
else
@etablissement = @dossier.etablissement
@entreprise = @dossier.entreprise.decorate
flash.now.alert = 'Les conditions sont obligatoires.'
render 'show'
end
end
def archive
@dossier = current_user.dossiers.find(params[:dossier_id])
@dossier.update_attributes({archived: true})
dossier = current_user.dossiers.find(params[:dossier_id])
dossier.update_attributes({archived: true})
flash.notice = 'Dossier archivé'
redirect_to users_dossiers_path
@ -122,6 +99,33 @@ class Users::DossiersController < UsersController
private
def dossiers_to_display
{'a_traiter' => waiting_for_user,
'en_attente' => waiting_for_gestionnaire,
'termine' => termine}[@liste]
end
def waiting_for_user
@en_attente_class = (@liste == 'a_traiter' ? 'active' : '')
@waiting_for_user ||= current_user.dossiers.waiting_for_user 'DESC'
end
def waiting_for_gestionnaire
@a_traiter_class = (@liste == 'en_attente' ? 'active' : '')
@waiting_for_gestionnaire ||= current_user.dossiers.waiting_for_gestionnaire 'DESC'
end
def termine
@termine_class = (@liste == 'termine' ? 'active' : '')
@termine ||= current_user.dossiers.termine 'DESC'
end
def total_dossiers_per_state
@dossiers_a_traiter_total = waiting_for_gestionnaire.count
@dossiers_en_attente_total = waiting_for_user.count
@dossiers_termine_total = termine.count
end
def check_siret
errors_valid_siret unless Siret.new(siret: siret).valid?
end
@ -135,10 +139,6 @@ class Users::DossiersController < UsersController
params.require(:dossier).permit(:autorisation_donnees)
end
def dossier_id_is_present?
@dossier_id != ''
end
def checked_autorisation_donnees?
update_params[:autorisation_donnees] == '1'
end
@ -151,12 +151,6 @@ class Users::DossiersController < UsersController
siret[0..8]
end
def total_dossiers_per_state
@dossiers_a_traiter_total = !@dossiers_a_traiter.nil? ? @dossiers_a_traiter.size : current_user.dossiers.waiting_for_user.size
@dossiers_en_attente_total = !@dossiers_en_attente.nil? ? @dossiers_en_attente.size : current_user.dossiers.waiting_for_gestionnaire.size
@dossiers_termine_total = !@dossiers_termine.nil? ? @dossiers_termine.size : current_user.dossiers.termine.size
end
def create_params
params.require(:dossier).permit(:siret, :procedure_id)
end

View file

@ -1,36 +1,35 @@
class Users::RecapitulatifController < UsersController
def show
@dossier = current_user_dossier
@dossier = @dossier.decorate
@procedure = @dossier.procedure
@champs = @dossier.ordered_champs
@commentaires = @dossier.ordered_commentaires
@commentaires = @commentaires.all.decorate
@commentaire_email = current_user.email
rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.dossier_not_found')
redirect_to url_for(root_path)
create_dossier_facade
end
def initiate
show
create_dossier_facade
@dossier.next_step! 'user', 'initiate'
@facade.dossier.next_step! 'user', 'initiate'
flash.notice = 'Dossier soumis avec succès.'
render 'show'
end
def submit
show
create_dossier_facade
@dossier.next_step! 'user', 'submit'
@facade.dossier.next_step! 'user', 'submit'
flash.notice = 'Dossier déposé avec succès.'
NotificationMailer.dossier_submitted(@dossier).deliver_now!
NotificationMailer.dossier_submitted(@facade.dossier).deliver_now!
render 'show'
end
private
def create_dossier_facade
@facade = DossierFacades.new current_user_dossier.id, current_user.email
rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.dossier_not_found')
redirect_to url_for(root_path)
end
end

View file

@ -0,0 +1,40 @@
class DossierFacades
#TODO rechercher en fonction de la personne/email
def initialize dossier_id, email
@dossier = Dossier.where(archived: false).find(dossier_id)
@email = email
end
def dossier
@dossier.decorate
end
def champs
@dossier.ordered_champs
end
def entreprise
@dossier.entreprise.decorate
end
def etablissement
@dossier.etablissement
end
def pieces_justificatives
@dossier.pieces_justificatives
end
def commentaires
@dossier.ordered_commentaires.all.decorate
end
def commentaire_email
@email
end
def procedure
@dossier.procedure
end
end

View file

@ -3,24 +3,27 @@
#onglets
%ul.nav.nav-tabs
%li{ class: (@dossiers.active_class_a_traiter(@liste) unless @dossiers.nil?) }
%li{ class: (@a_traiter_class) }
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'a_traiter')}"}
%h5.text-danger
= "À traiter "
.badge.progress-bar-danger
=@dossiers_a_traiter_total
%li{ class: (@dossiers.active_class_en_attente(@liste) unless @dossiers.nil?) }
%li{ class: (@en_attente_class) }
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'en_attente')}"}
%h5.text-info
="En attente "
.badge.progress-bar-info
=@dossiers_en_attente_total
%li{ class: (@dossiers.active_class_termine(@liste) unless @dossiers.nil?) }
%li{ class: (@termine_class) }
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'termine')}"}
%h5.text-success
= "Terminé"
.badge.progress-bar-success
=@dossiers_termine_total
%li#search{class: "#{'active' unless @dossiers_search.nil?}", style:'float:right'}
%a
= form_tag(backoffice_dossiers_search_url, method: :get) do

View file

@ -1,9 +1,9 @@
#backoffice_dossier_show
%h1#dossier_id.text-info{ :style => 'text-align:right'}
= "Dossier n°#{@dossier.id}"
= "Dossier n°#{@facade.dossier.id}"
%h3{:class => 'text-success', :style => 'text-align:right'}
= @dossier.state_fr
= @facade.dossier.state_fr
= render partial: '/dossiers/infos_entreprise'
@ -17,5 +17,5 @@
%br
-#%script{type: 'text/javascript'}
-# ="url_carte = '#{@dossier.id}/'"
-# ="ref_dossier = '#{@dossier.ref_dossier_carto}'"
-# ="url_carte = '#{@facade.dossier.id}/'"
-# ="ref_dossier = '#{@facade.dossier.ref_dossier_carto}'"

View file

@ -3,33 +3,33 @@
%div.row
.col-lg-6.col-md-6
%h3.text-info
= @dossier.nom_projet
= @facade.dossier.nom_projet
%h4
= @dossier.procedure.libelle
= @facade.dossier.procedure.libelle
.description
- begin
- @dossier.description.split(/(?:\n\r?|\r\n?')/).each do |line|
- @facade.dossier.description.split(/(?:\n\r?|\r\n?')/).each do |line|
= line
%br
- rescue
=''
- if @dossier.procedure.module_api_carto.use_api_carto
- if @facade.dossier.procedure.module_api_carto.use_api_carto
.col-lg-6.col-md-6
#map.mini{class: @dossier.class_qp_active}
#map.mini{class: @facade.dossier.class_qp_active}
%input{id: 'json_latlngs', type:'hidden', value: "#{@dossier.json_latlngs}"}
%input{id: 'quartier_prioritaires', type:'hidden', value: "#{@dossier.quartier_prioritaires.to_json}"}
%input{id: 'json_latlngs', type:'hidden', value: "#{@facade.dossier.json_latlngs}"}
%input{id: 'quartier_prioritaires', type:'hidden', value: "#{@facade.dossier.quartier_prioritaires.to_json}"}
%script{type: 'text/javascript'}
= "var dossier_id =#{@dossier.id}"
= "var dossier_id =#{@facade.dossier.id}"
initCarto();
%br
-unless @champs.nil?
-unless @facade.champs.nil?
.row
.col-lg-6.col-md-6
%table.table#liste_champs
-@champs.each do |champ|
-@facade.champs.each do |champ|
%tr
%th{ style: 'width:25%' }
=champ.libelle
@ -41,20 +41,20 @@
%div.row{style: 'text-align:right'}
-unless gestionnaire_signed_in?
-if !@dossier.validated? && !@dossier.submitted? && !@dossier.closed?
-if @dossier.procedure.module_api_carto.use_api_carto
%a#maj_carte.btn.btn-primary{href: "/users/dossiers/#{@dossier.id}/carte"}
-if !@facade.dossier.validated? && !@facade.dossier.submitted? && !@facade.dossier.closed?
-if @facade.dossier.procedure.module_api_carto.use_api_carto
%a#maj_carte.btn.btn-primary{href: "/users/dossiers/#{@facade.dossier.id}/carte"}
= 'Editer ma carte'
%a#maj_infos.btn.btn-info{href: "/users/dossiers/#{@dossier.id}/description"}
%a#maj_infos.btn.btn-info{href: "/users/dossiers/#{@facade.dossier.id}/description"}
= 'Editer mon dossier'
-unless user_signed_in?
-if !@dossier.validated? && !@dossier.submitted? && !@dossier.closed?
= form_tag(url_for({controller: 'backoffice/dossiers', action: :valid, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
-if !@facade.dossier.validated? && !@facade.dossier.submitted? && !@facade.dossier.closed?
= form_tag(url_for({controller: 'backoffice/dossiers', action: :valid, dossier_id: @facade.dossier.id}), class: 'form-inline', method: 'POST') do
%button#action_button.btn.btn-success
= 'Valider le dossier'
-elsif @dossier.submitted?
= form_tag(url_for({controller: 'backoffice/dossiers', action: :close, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
-elsif @facade.dossier.submitted?
= form_tag(url_for({controller: 'backoffice/dossiers', action: :close, dossier_id: @facade.dossier.id}), class: 'form-inline', method: 'POST') do
%button#action_button.btn.btn-success
= 'Traiter le dossier'

View file

@ -1,37 +1,37 @@
.col-md-12
%h4
= @entreprise.raison_sociale_or_name
= @facade.entreprise.raison_sociale_or_name
.row#infos_entreprise
.col-lg-6.col-md-6
%dl.dl-horizontal
%dt Siret :
%dd.text-success= @etablissement.siret
%dd.text-success= @facade.etablissement.siret
- if @etablissement.siret != @entreprise.siret_siege_social
- if @facade.etablissement.siret != @facade.entreprise.siret_siege_social
%dt SIRET siège social :
%dd= @entreprise.siret_siege_social
%dd= @facade.entreprise.siret_siege_social
%dt Forme juridique :
%dd= @entreprise.forme_juridique
%dd= @facade.entreprise.forme_juridique
%dt Libellé naf :
%dd= @etablissement.libelle_naf
%dd= @facade.etablissement.libelle_naf
%dt Code naf :
%dd= @etablissement.naf
%dd= @facade.etablissement.naf
%dt Date de création :
%dd= Time.at(@entreprise.date_creation).strftime "%d-%m-%Y"
%dd= Time.at(@facade.entreprise.date_creation).strftime "%d-%m-%Y"
%dt Effectif organisation :
%dd= @entreprise.effectif
%dd= @facade.entreprise.effectif
%dt Code effectif :
%dd= @entreprise.code_effectif_entreprise
%dd= @facade.entreprise.code_effectif_entreprise
%dt Numéro TVA intracommunautaire :
%dd= @entreprise.numero_tva_intracommunautaire
%dd= @facade.entreprise.numero_tva_intracommunautaire
.col-lg-6.col-md-6
@ -39,21 +39,21 @@
%dt Adresse :
%dd
%address
- @etablissement.adresse.split("\n").each do |line|
- @facade.etablissement.adresse.split("\n").each do |line|
= line
%br
%dt Capital social :
%dd= @entreprise.pretty_capital_social
%dd= @facade.entreprise.pretty_capital_social
%dt Exercices :
%dd
%address
- @etablissement.exercices.each_with_index do |exercice, index|
- @facade.etablissement.exercices.each_with_index do |exercice, index|
%strong
= "#{exercice.dateFinExercice.year} : "
= number_to_currency(exercice.ca)
%br
- unless @entreprise.rna_information.nil?
- unless @facade.entreprise.rna_information.nil?
= render partial: '/dossiers/infos_rna'

View file

@ -2,22 +2,22 @@
.col-lg-6.col-md-6
%dl.dl-horizontal
%dt Association ID :
%dd.text-success= @entreprise.rna_information.association_id
%dd.text-success= @facade.entreprise.rna_information.association_id
%dt Titre :
%dd= @entreprise.rna_information.titre
%dd= @facade.entreprise.rna_information.titre
%dt Objet :
%dd= @entreprise.rna_information.objet
%dd= @facade.entreprise.rna_information.objet
.col-lg-6.col-md-6
%dl.dl-horizontal
%dt Date création :
%dd= @entreprise.rna_information.date_creation
%dd= @facade.entreprise.rna_information.date_creation
%dt Capital publication :
%dd= @entreprise.rna_information.date_publication
%dd= @facade.entreprise.rna_information.date_publication
%dt Capital déclaration :
%dd= @entreprise.rna_information.date_declaration
%dd= @facade.entreprise.rna_information.date_declaration

View file

@ -1,23 +1,24 @@
#pieces_justificatives
-#%h3.text-info Liste des pièces justificatives
-#%br
%table.table
-if @procedure.lien_demarche != nil
-if @facade.procedure.lien_demarche != nil
%tr{id: "piece_justificative_0"}
%th{class:'col-lg-6'}
='CERFA'
-if @procedure.lien_demarche != nil
%a{style:'font-size:0.9em; padding-left:3px', id: 'lien_cerfa' ,href: "#{@procedure.lien_demarche}", :target => '_blank'} Lien CERFA
-if @facade.procedure.lien_demarche != nil
%a{style:'font-size:0.9em; padding-left:3px', id: 'lien_cerfa' ,href: "#{@facade.procedure.lien_demarche}", :target => '_blank'} Lien CERFA
%td.col-lg-6.col-md-6
- if !@dossier.cerfa.empty?
- if !@facade.dossier.cerfa.empty?
- if user_signed_in?
= 'Pièce fournie'
- elsif gestionnaire_signed_in?
%a{ href: "#{@dossier.cerfa.content}", target: '_blank' } Consulter
%a{ href: "#{@facade.dossier.cerfa.content}", target: '_blank' } Consulter
- else
= 'Pièce non fournie'
- @dossier.pieces_justificatives.each do |piece_justificative|
- @facade.dossier.pieces_justificatives.each do |piece_justificative|
%tr{ id: "piece_justificative_#{piece_justificative.type}" }
%th.col-lg-6
= piece_justificative.libelle

View file

@ -5,7 +5,7 @@
%div.row
= render partial: '/dossiers/infos_entreprise'
%br
= form_for @dossier, url: { controller: '/users/dossiers', action: :update } do |f|
= form_for @facade.dossier, url: { controller: '/users/dossiers', action: :update } do |f|
%label{ style:'font-weight:normal' }
= f.check_box :autorisation_donnees
J'autorise les décideurs publics à vérifier les informations de mon organisation auprès des administrations concernées. Ces informations resteront strictement confidentielles.

View file

@ -1,12 +1,12 @@
.content#commentaires_flux{style:'width:100%;'}
%div#commentaire_new{style: 'width:80%; margin-left:auto; margin-right:auto'}
= form_tag(url_for({ controller: :commentaires, action: :create, dossier_id: @dossier.id }), class: 'form-inline', method: 'POST') do
= form_tag(url_for({ controller: :commentaires, action: :create, dossier_id: @facade.dossier.id }), class: 'form-inline', method: 'POST') do
%textarea.form-control{id: 'texte_commentaire', name: 'texte_commentaire', style: 'width: 100%; margin-bottom:2%', rows: '5', maxlength: '255', placeholder:"Dialoguer avec votre interlocuteur privilégié en charge de votre dossier."}
%input.form-control.btn.btn-success{:type => 'submit', :value => 'Poster', style: 'float:right'}
%br
%br
-@commentaires.each do |com|
-@facade.commentaires.each do |com|
%span.text-info#email_contact{style: 'font-weight:bold'}
=com.email
%span#created_at

View file

@ -4,7 +4,7 @@
.col-md-6.col-lg-6
%h2 Récapitulatif
.col-md-6.col-lg-6
= form_tag "/users/dossiers/#{@dossier.id}/archive", style:'margin-top:21px', action: :archive, method: :put do
= form_tag "/users/dossiers/#{@facade.dossier.id}/archive", style:'margin-top:21px', action: :archive, method: :put do
%button#archive.btn.btn-sm.btn-default.text-info{type: :button}
%i.fa.fa-eraser
Archiver
@ -20,17 +20,17 @@
.col-md-3.col-lg-3
%h2#dossier_id{:class => 'text-info', :style => 'text-align:right; margin-bottom:15px'}
= "Dossier n°#{@dossier.id}"
= "Dossier n°#{@facade.dossier.id}"
- unless gestionnaire_signed_in?
-if @dossier.validated?
-if @facade.dossier.validated?
%br
= form_tag(url_for({controller: :recapitulatif, action: :submit, dossier_id: @dossier.id}), method: 'POST') do
= form_tag(url_for({controller: :recapitulatif, action: :submit, dossier_id: @facade.dossier.id}), method: 'POST') do
%button#validate_button.btn.btn-success
= 'Déposer mon dossier'
-else
%h3{:class => 'text-success', :style => 'text-align:right'}
= @dossier.state_fr
= @facade.dossier.state_fr
%br

View file

@ -5,6 +5,7 @@ feature 'user arrive on siret page' do
let(:user) { create(:user) }
let(:siret) { '42149333900020' }
let(:siren) { siret[0...9] }
context 'when user is not logged in' do
before do
visit new_users_dossiers_path(procedure_id: procedure.id)

View file

@ -9,11 +9,12 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
let!(:decorate_dossier_replied) { create(:dossier, :with_user, procedure: procedure, nom_projet: 'projet replied', state: 'replied').decorate }
let!(:decorate_dossier_closed) { create(:dossier, :with_user, procedure: procedure, nom_projet: 'projet closed', state: 'closed').decorate }
describe 'on tab a_traiter' do
before do
assign(:dossiers, gestionnaire.dossiers.waiting_for_gestionnaire.paginate(:page => 1).decorate)
assign(:liste, 'a_traiter')
assign(:a_traiter_class, 'active')
render
end
@ -37,6 +38,8 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
before do
assign(:dossiers, gestionnaire.dossiers.waiting_for_user.paginate(:page => 1).decorate)
assign(:liste, 'en_attente')
assign(:en_attente_class, 'active')
render
end
@ -58,6 +61,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
describe 'on tab termine' do
before do
assign(:dossiers, gestionnaire.dossiers.termine.paginate(:page => 1).decorate)
assign(:termine_class, 'active')
assign(:liste, 'termine')
render
end

View file

@ -1,17 +1,14 @@
require 'spec_helper'
describe 'backoffice/dossiers/show.html.haml', type: :view do
let!(:dossier) { create(:dossier, :with_entreprise, :with_procedure, :with_user) }
let!(:dossier) { create(:dossier, :with_entreprise, :with_procedure, :with_user, state: state) }
let(:state) { 'draft' }
let(:dossier_id) { dossier.id }
let(:gestionnaire) { create(:gestionnaire) }
before do
sign_in create(:gestionnaire)
assign(:dossier, dossier.decorate)
assign(:entreprise, dossier.entreprise.decorate)
assign(:etablissement, dossier.etablissement)
assign(:procedure, dossier.procedure)
assign(:commentaires, dossier.commentaires)
sign_in gestionnaire
assign(:facade, (DossierFacades.new dossier.id, gestionnaire.email))
end
context 'on the dossier admin page' do
@ -48,8 +45,9 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
context 'dossier state changements' do
context 'when dossier have state initiated' do
let(:state) { 'initiated' }
before do
dossier.initiated!
render
end
@ -62,8 +60,9 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
end
context 'when dossier have state replied' do
let(:state) { 'replied' }
before do
dossier.replied!
render
end
@ -76,8 +75,9 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
end
context 'when dossier have state update' do
let(:state) { 'updated' }
before do
dossier.updated!
render
end
@ -90,8 +90,9 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
end
context 'when dossier have state validated' do
let(:state) { 'validated' }
before do
dossier.validated!
render
end
@ -104,8 +105,9 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
end
context 'when dossier have state submitted' do
let(:state) { 'submitted' }
before do
dossier.submitted!
render
end
@ -122,8 +124,9 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
end
context 'when dossier have state closed' do
let(:state) { 'closed' }
before do
dossier.closed!
render
end

View file

@ -4,9 +4,7 @@ describe 'dossiers/_infos_dossier.html.haml', type: :view do
let(:dossier) { create(:dossier, :with_entreprise, :with_user, procedure: create(:procedure, :with_api_carto, :with_type_de_champ)) }
before do
assign(:dossier, dossier.decorate)
assign(:champs, dossier.ordered_champs)
assign(:procedure, dossier.procedure)
assign(:facade, DossierFacades.new(dossier.id, dossier.user.email))
render
end

View file

@ -5,9 +5,7 @@ describe 'dossiers/show.html.haml', type: :view do
let(:dossier) { create(:dossier, :with_entreprise, user: user) }
before do
assign(:dossier, dossier)
assign(:entreprise, dossier.entreprise.decorate)
assign(:etablissement, dossier.etablissement)
assign(:facade, DossierFacades.new(dossier.id, user.email))
render
end

View file

@ -8,8 +8,7 @@ describe 'users/recapitulatif/_commentaires_flux.html.haml', type: :view do
let(:body) { 'Commentaire de test' }
before do
assign(:dossier, dossier.decorate)
assign(:commentaires, dossier.commentaires.all.decorate)
assign(:facade, DossierFacades.new(dossier.id, dossier.user.email))
render
end

View file

@ -1,13 +1,12 @@
require 'spec_helper'
describe 'users/recapitulatif/show.html.haml', type: :view do
let(:dossier) { create(:dossier, :with_user, :with_entreprise, procedure: create(:procedure, :with_api_carto)) }
let(:dossier) { create(:dossier, :with_user, :with_entreprise, state: state, procedure: create(:procedure, :with_api_carto)) }
let(:dossier_id) { dossier.id }
let(:state) { 'draft' }
before do
assign(:dossier, dossier.decorate)
assign(:procedure, dossier.procedure)
assign(:commentaires, dossier.commentaires)
assign(:facade, DossierFacades.new(dossier.id, dossier.user.email))
end
context 'sur la rendered recapitulative' do
@ -54,8 +53,8 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
context 'buttons to change dossier state' do
context 'when dossier state is initiated' do
let(:state) { 'initiated' }
before do
dossier.initiated!
render
end
@ -63,18 +62,19 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
end
context 'when dossier state is replied' do
let(:state) { 'replied' }
before do
dossier.replied!
render
end
#TODO gestionnaire test
it { expect(rendered).to have_content('Répondu') }
end
context 'when dossier state is updated' do
let(:state) { 'updated' }
before do
dossier.updated!
render
end
@ -82,8 +82,9 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
end
context 'when dossier state is validated' do
let(:state) { 'validated' }
before do
dossier.validated!
render
end
@ -99,8 +100,9 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
end
context 'when dossier state is submitted' do
let(:state) { 'submitted' }
before do
dossier.submitted!
render
end
@ -113,8 +115,9 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
end
context 'when dossier state is traité' do
let(:state) { 'closed' }
before do
dossier.closed!
render
end
it { expect(rendered).to have_content('Traité') }