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 end
group :development, :test do 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 # Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug' gem 'byebug'
gem 'pry-byebug' gem 'pry-byebug'

View file

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

View file

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

View file

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

View file

@ -1,36 +1,35 @@
class Users::RecapitulatifController < UsersController class Users::RecapitulatifController < UsersController
def show def show
@dossier = current_user_dossier create_dossier_facade
@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)
end end
def initiate def initiate
show create_dossier_facade
@dossier.next_step! 'user', 'initiate' @facade.dossier.next_step! 'user', 'initiate'
flash.notice = 'Dossier soumis avec succès.' flash.notice = 'Dossier soumis avec succès.'
render 'show' render 'show'
end end
def submit 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.' flash.notice = 'Dossier déposé avec succès.'
NotificationMailer.dossier_submitted(@dossier).deliver_now! NotificationMailer.dossier_submitted(@facade.dossier).deliver_now!
render 'show' render 'show'
end 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 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 #onglets
%ul.nav.nav-tabs %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')}"} %a{:href => "#{url_for backoffice_dossiers_path(liste: 'a_traiter')}"}
%h5.text-danger %h5.text-danger
= "À traiter " = "À traiter "
.badge.progress-bar-danger .badge.progress-bar-danger
=@dossiers_a_traiter_total =@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')}"} %a{:href => "#{url_for backoffice_dossiers_path(liste: 'en_attente')}"}
%h5.text-info %h5.text-info
="En attente " ="En attente "
.badge.progress-bar-info .badge.progress-bar-info
=@dossiers_en_attente_total =@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')}"} %a{:href => "#{url_for backoffice_dossiers_path(liste: 'termine')}"}
%h5.text-success %h5.text-success
= "Terminé" = "Terminé"
.badge.progress-bar-success .badge.progress-bar-success
=@dossiers_termine_total =@dossiers_termine_total
%li#search{class: "#{'active' unless @dossiers_search.nil?}", style:'float:right'} %li#search{class: "#{'active' unless @dossiers_search.nil?}", style:'float:right'}
%a %a
= form_tag(backoffice_dossiers_search_url, method: :get) do = form_tag(backoffice_dossiers_search_url, method: :get) do

View file

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

View file

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

View file

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

View file

@ -2,22 +2,22 @@
.col-lg-6.col-md-6 .col-lg-6.col-md-6
%dl.dl-horizontal %dl.dl-horizontal
%dt Association ID : %dt Association ID :
%dd.text-success= @entreprise.rna_information.association_id %dd.text-success= @facade.entreprise.rna_information.association_id
%dt Titre : %dt Titre :
%dd= @entreprise.rna_information.titre %dd= @facade.entreprise.rna_information.titre
%dt Objet : %dt Objet :
%dd= @entreprise.rna_information.objet %dd= @facade.entreprise.rna_information.objet
.col-lg-6.col-md-6 .col-lg-6.col-md-6
%dl.dl-horizontal %dl.dl-horizontal
%dt Date création : %dt Date création :
%dd= @entreprise.rna_information.date_creation %dd= @facade.entreprise.rna_information.date_creation
%dt Capital publication : %dt Capital publication :
%dd= @entreprise.rna_information.date_publication %dd= @facade.entreprise.rna_information.date_publication
%dt Capital déclaration : %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 #pieces_justificatives
-#%h3.text-info Liste des pièces justificatives -#%h3.text-info Liste des pièces justificatives
-#%br -#%br
%table.table %table.table
-if @procedure.lien_demarche != nil -if @facade.procedure.lien_demarche != nil
%tr{id: "piece_justificative_0"} %tr{id: "piece_justificative_0"}
%th{class:'col-lg-6'} %th{class:'col-lg-6'}
='CERFA' ='CERFA'
-if @procedure.lien_demarche != nil -if @facade.procedure.lien_demarche != nil
%a{style:'font-size:0.9em; padding-left:3px', id: 'lien_cerfa' ,href: "#{@procedure.lien_demarche}", :target => '_blank'} Lien CERFA %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 %td.col-lg-6.col-md-6
- if !@dossier.cerfa.empty? - if !@facade.dossier.cerfa.empty?
- if user_signed_in? - if user_signed_in?
= 'Pièce fournie' = 'Pièce fournie'
- elsif gestionnaire_signed_in? - elsif gestionnaire_signed_in?
%a{ href: "#{@dossier.cerfa.content}", target: '_blank' } Consulter %a{ href: "#{@facade.dossier.cerfa.content}", target: '_blank' } Consulter
- else - else
= 'Pièce non fournie' = '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}" } %tr{ id: "piece_justificative_#{piece_justificative.type}" }
%th.col-lg-6 %th.col-lg-6
= piece_justificative.libelle = piece_justificative.libelle

View file

@ -5,7 +5,7 @@
%div.row %div.row
= render partial: '/dossiers/infos_entreprise' = render partial: '/dossiers/infos_entreprise'
%br %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' } %label{ style:'font-weight:normal' }
= f.check_box :autorisation_donnees = 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. 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%;'} .content#commentaires_flux{style:'width:100%;'}
%div#commentaire_new{style: 'width:80%; margin-left:auto; margin-right:auto'} %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."} %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'} %input.form-control.btn.btn-success{:type => 'submit', :value => 'Poster', style: 'float:right'}
%br %br
%br %br
-@commentaires.each do |com| -@facade.commentaires.each do |com|
%span.text-info#email_contact{style: 'font-weight:bold'} %span.text-info#email_contact{style: 'font-weight:bold'}
=com.email =com.email
%span#created_at %span#created_at

View file

@ -4,7 +4,7 @@
.col-md-6.col-lg-6 .col-md-6.col-lg-6
%h2 Récapitulatif %h2 Récapitulatif
.col-md-6.col-lg-6 .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} %button#archive.btn.btn-sm.btn-default.text-info{type: :button}
%i.fa.fa-eraser %i.fa.fa-eraser
Archiver Archiver
@ -20,17 +20,17 @@
.col-md-3.col-lg-3 .col-md-3.col-lg-3
%h2#dossier_id{:class => 'text-info', :style => 'text-align:right; margin-bottom:15px'} %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? - unless gestionnaire_signed_in?
-if @dossier.validated? -if @facade.dossier.validated?
%br %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 %button#validate_button.btn.btn-success
= 'Déposer mon dossier' = 'Déposer mon dossier'
-else -else
%h3{:class => 'text-success', :style => 'text-align:right'} %h3{:class => 'text-success', :style => 'text-align:right'}
= @dossier.state_fr = @facade.dossier.state_fr
%br %br

View file

@ -5,6 +5,7 @@ feature 'user arrive on siret page' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:siret) { '42149333900020' } let(:siret) { '42149333900020' }
let(:siren) { siret[0...9] } let(:siren) { siret[0...9] }
context 'when user is not logged in' do context 'when user is not logged in' do
before do before do
visit new_users_dossiers_path(procedure_id: procedure.id) 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_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 } let!(:decorate_dossier_closed) { create(:dossier, :with_user, procedure: procedure, nom_projet: 'projet closed', state: 'closed').decorate }
describe 'on tab a_traiter' do describe 'on tab a_traiter' do
before do before do
assign(:dossiers, gestionnaire.dossiers.waiting_for_gestionnaire.paginate(:page => 1).decorate) assign(:dossiers, gestionnaire.dossiers.waiting_for_gestionnaire.paginate(:page => 1).decorate)
assign(:liste, 'a_traiter') assign(:liste, 'a_traiter')
assign(:a_traiter_class, 'active')
render render
end end
@ -37,6 +38,8 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
before do before do
assign(:dossiers, gestionnaire.dossiers.waiting_for_user.paginate(:page => 1).decorate) assign(:dossiers, gestionnaire.dossiers.waiting_for_user.paginate(:page => 1).decorate)
assign(:liste, 'en_attente') assign(:liste, 'en_attente')
assign(:en_attente_class, 'active')
render render
end end
@ -58,6 +61,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
describe 'on tab termine' do describe 'on tab termine' do
before do before do
assign(:dossiers, gestionnaire.dossiers.termine.paginate(:page => 1).decorate) assign(:dossiers, gestionnaire.dossiers.termine.paginate(:page => 1).decorate)
assign(:termine_class, 'active')
assign(:liste, 'termine') assign(:liste, 'termine')
render render
end end

View file

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

View file

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

View file

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

View file

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