Merge develop into staging

This commit is contained in:
Xavier J 2017-02-07 18:28:22 +01:00
commit 812b8f7f27
23 changed files with 208 additions and 57 deletions

4
.byebug_history Normal file
View file

@ -0,0 +1,4 @@
exit
xit
xtei
cniuecniu

View file

@ -1,4 +1,4 @@
#left-pannel {
#left-panel {
margin-top: 60px;
padding: 0;
background-color: #003189;

View file

@ -158,7 +158,6 @@
position: fixed;
bottom: 26px;
right: -35px;
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
width: 150px;
background-color: #008cba;
@ -207,4 +206,3 @@
font-size: 20px;
}
}

View file

@ -1,6 +1,5 @@
@media print {
html, body {
width: 900px;
margin: 0;
}
@ -28,4 +27,39 @@
#backoffice_dossier_show .nav-tabs {
display: none;
}
#left-panel {
margin-top: 0;
height: auto;
position: relative;
width: 100%;
}
#wrap {
overflow: visible;
}
#main-container {
width: 100%;
}
#beta {
top: 26px;
bottom: initial;
position: absolute;
transform: rotate(45deg);
}
.copyright {
width: 100%;
left: 0;
}
.no-page-break-inside {
page-break-inside: avoid;
}
.display-block-on-print {
display: block !important;
}
}

View file

@ -6,8 +6,11 @@ class Admin::PiecesJustificativesController < AdminController
end
def update
@procedure.update_attributes(update_params)
flash.now.notice = 'Modifications sauvegardées'
if @procedure.update_attributes(update_params)
flash.now.notice = 'Modifications sauvegardées'
else
flash.now.notice = 'Une erreur est survenue'
end
render 'show', format: :js
end
@ -22,7 +25,7 @@ class Admin::PiecesJustificativesController < AdminController
def update_params
params
.require(:procedure)
.permit(types_de_piece_justificative_attributes: [:libelle, :description, :id, :order_place])
.permit(types_de_piece_justificative_attributes: [:libelle, :description, :id, :order_place, :lien_demarche])
end
def move_up

View file

@ -43,6 +43,8 @@ class RootController < ApplicationController
return redirect_to administrations_path
end
@demo_environment_host = "https://tps-dev.apientreprise.fr" unless Rails.env.development?
render 'landing'
end
end

View file

@ -309,6 +309,10 @@ class Dossier < ActiveRecord::Base
end
end
def followers_gestionnaires_emails
follows.includes(:gestionnaire).map { |f| f.gestionnaire }.pluck(:email).join(' ')
end
def reset!
etablissement.destroy
entreprise.destroy

View file

@ -4,4 +4,6 @@ class TypeDePieceJustificative < ActiveRecord::Base
belongs_to :procedure
validates :libelle, presence: true, allow_blank: false, allow_nil: false
validates :lien_demarche, format: { with: URI::regexp }, allow_blank: true, allow_nil: true
end

View file

@ -5,4 +5,6 @@ class DossierProcedureSerializer < ActiveModel::Serializer
:archived,
:mandataire_social,
:state
attribute :followers_gestionnaires_emails, key: :emails_accompagnateurs
end

View file

@ -2,5 +2,6 @@ class TypeDePieceJustificativeSerializer < ActiveModel::Serializer
attributes :id,
:libelle,
:description,
:order_place
:order_place,
:lien_demarche
end

View file

@ -6,6 +6,12 @@
.form-group
%h4 Description
=ff.text_area :description, class: 'form-control description', placeholder: 'Description'
.form-group
%h4
Lien du formulaire vierge
%small
(optionel)
=ff.url_field :lien_demarche, class: 'form-control', placeholder: 'Lien du document vierge'
.form-group
= ff.hidden_field :order_place, value: ff.index
@ -23,4 +29,3 @@
= f.submit('Ajouter la pièce', class: 'btn btn-success', id: 'add_piece_justificative')
- else
= link_to("", admin_procedure_piece_justificative_path(@procedure, ff.object.id), method: :delete, remote: true, id: "delete_type_de_piece_justificative_#{ff.object.id}", class: %w(form-control btn btn-danger fa fa-trash-o) )

View file

@ -4,7 +4,7 @@
.default_data_block
%div.row.show-block.infos
%div.header
%div.col-lg-8.col-md-8.col-sm-8.col-xs-8.title-no-expanse
%div.col-xs-8.title-no-expanse
%div.carret-right
INFORMATIONS DU DEMANDEUR
- if !@current_gestionnaire && ["draft", "updated", "replied", "initiated"].include?(@facade.dossier.state)
@ -16,34 +16,34 @@
.default_data_block
%div.row.show-block.infos#infos_entreprise
%div.header
%div.col-lg-12.col-md-12.col-sm-12.col-xs-12.title
%div.col-xs-12.title
%div.carret-right
%div.carret-down
INFORMATIONS DU DEMANDEUR
%div.body
%div.body.display-block-on-print
= render partial: '/dossiers/infos_entreprise'
.default_data_block.default_visible
%div.row.show-block.infos#infos_dossier
%div.header
%div.col-lg-10.col-md-10.col-sm-10.col-xs-10.title
%div.col-xs-10.title
%div.carret-right
%div.carret-down
CONSTRUCTION DU DOSSIER
= render partial: '/dossiers/edit_dossier'
%div.body
%div.body.display-block-on-print
= render partial: '/dossiers/infos_dossier'
- if @facade.dossier.procedure.module_api_carto.use_api_carto
.default_data_block.default_visible
.default_data_block.default_visible.no-page-break-inside
%div.row.show-block#carto
%div.header
%div.col-lg-10.col-md-10.col-sm-10.col-xs-10.title
%div.col-xs-10.title
%div.carret-right
%div.carret-down
CARTOGRAPHIE
= render partial: '/dossiers/edit_carto'
%div.body
%div.body.display-block-on-print
%input{id: 'json_latlngs', type: 'hidden', value: "#{@facade.dossier.json_latlngs}", name: 'json_latlngs'}
%input{id: 'quartier_prioritaires', type: 'hidden', value: "#{@facade.dossier.quartier_prioritaires.to_json}"}
%input{id: 'cadastres', type: 'hidden', value: "#{@facade.dossier.cadastres.to_json}"}
@ -56,11 +56,11 @@
.default_data_block.default_visible
%div.row.show-block#private-fields
%div.header
%div.col-lg-10.col-md-10.col-sm-10.col-xs-10.title
%div.col-xs-10.title
%div.carret-right
%div.carret-down
= "formulaire privé".upcase
%div.col-lg-2.col-md-2.col-sm-2.col-xs-2.count
%div.col-xs-2.count
- private_fields_count = @champs_private.count
= (private_fields_count == 1) ? "1 champ" : "#{private_fields_count} champs"
%div.body

View file

@ -11,17 +11,20 @@
.alert.alert-info
Cette messagerie permet d'échanger entre le demandeur et le service instructeur.
.body
.body.display-block-on-print
- if dossier_facade.commentaires.any?
.commentaires
= render partial: 'dossiers/commentaires/commentaire', collection: dossier_facade.commentaires.object.sort
.split-hr
#new-commentaire
#new-commentaire.hidden-print
= render partial: 'dossiers/commentaires/form', locals: { dossier_facade: @facade }
.last-commentaire.clearfix
.col-md-6
%input#save-message.form-control.btn.btn-send{ type: 'submit', value: 'ENVOYER' }
.last-commentaire.clearfix.hidden-print
- if last_comment = dossier_facade.commentaires.first
%div
DERNIER MESSAGE

View file

@ -6,6 +6,7 @@
%meta{'http-equiv' => "X-UA-Compatible", :content => "IE=edge"}
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
= stylesheet_link_tag 'print', media: 'print', 'data-turbolinks-track' => true
= javascript_include_tag 'application', 'data-turbolinks-track' => true
= csrf_meta_tags
@ -32,7 +33,7 @@
= render partial: "layouts/navbar"
%div.row.no-margin
- if RenderPartialService.left_panel_exist? @left_pannel_url
%div.col-lg-2.col-md-2.col-sm-2.col-xs-2#left-pannel
%div.col-xs-2#left-panel
- if gestionnaire_signed_in?
#search-block
= render partial: 'layouts/left_panels/search_area'

View file

@ -44,18 +44,19 @@
.col-md-4.col-lg-4
%h3.text-primary Acteurs publics
%h4 Créez des démarches en ligne simplifiées et sécurisées.
=link_to 'Démonstration', 'https://tps-dev.apientreprise.fr/administrateurs/sign_in/demo', {class: 'btn btn-lg btn-primary'}
=link_to 'Démonstration', "#{@demo_environment_host}/administrateurs/sign_in/demo", {class: 'btn btn-lg btn-primary'}
.col-md-4.col-lg-4
%h3.text-warning Agents et services
%h4 Accompagnez et co-traitez les projets avec les usagers.
=link_to 'Démonstration', 'https://tps-dev.apientreprise.fr/gestionnaires/sign_in/demo', {class: 'btn btn-lg btn-warning'}
=link_to 'Démonstration', "#{@demo_environment_host}/gestionnaires/sign_in/demo", {class: 'btn btn-lg btn-warning'}
.col-md-4.col-lg-4
%h3.text-success Usagers
%h4 Profitez de démarches simplifiées et déchanges continus avec les services traitants.
=link_to 'Démonstration', 'https://tps-dev.apientreprise.fr/users/sign_in/demo', {class: 'btn btn-lg btn-success'}
=link_to 'Démonstration', "#{@demo_environment_host}/users/sign_in/demo", {class: 'btn btn-lg btn-success'}
%h1
= @demo_environment_host
.split-hr-left
.center

View file

@ -1,15 +1,17 @@
-unless dossier.procedure.lien_demarche.blank?
%p
Récupérer le formulaire de demande ou CERFA vierge pour mon dossier :
= link_to "Télécharger", dossier.procedure.lien_demarche, target: '_blank', id: 'lien_cerfa'
%table.table
- if dossier.procedure.cerfa_flag
%tr
%th.col-lg-6
%th
Formulaire de demande ou CERFA (complété et numérisé)
%td
-unless dossier.procedure.lien_demarche.blank?
%em
Récupérer le formulaire de demande ou CERFA vierge pour mon dossier :
= link_to "Télécharger", "#{dossier.procedure.lien_demarche}", target: :blank, id: :lien_cerfa
-# %a{ id: 'lien_cerfa', href: "#{dossier.procedure.lien_demarche}", target: '_blank'} Télécharger
%td.col-lg-5
%td
-if dossier.cerfa_available?
%span.btn.btn-sm.btn-file.btn-success
Modifier
@ -19,9 +21,16 @@
- dossier.types_de_piece_justificative.order('order_place ASC').each do |type_de_piece_justificative|
%tr
%th.col-lg-6.piece-libelle
%th.piece-libelle
= type_de_piece_justificative.libelle
%td.col-lg-5
%td
- unless type_de_piece_justificative.lien_demarche.blank?
%em
Récupérer le formulaire vierge pour mon dossier :
= link_to "Télécharger", type_de_piece_justificative.lien_demarche, target: :blank
%td
-if type_de_piece_justificative.api_entreprise
%span.text-success{ id: "piece_justificative_#{type_de_piece_justificative.id}" } Nous l'avons récupéré pour vous.
-else

View file

@ -24,6 +24,7 @@
%br
%h3 Documents administratifs
//TODO a refactorer
.row
.col-lg-8

View file

@ -8,4 +8,4 @@ Rails.application.config.assets.version = '1.0'
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )
Rails.application.config.assets.precompile += %w(print.css)

View file

@ -0,0 +1,5 @@
class AddLienToTypeDePieceJustificative < ActiveRecord::Migration[5.0]
def change
add_column :types_de_piece_justificative, :lien_demarche, :string, default: nil
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20161227103823) do
ActiveRecord::Schema.define(version: 20170125152856) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -361,6 +361,7 @@ ActiveRecord::Schema.define(version: 20161227103823) do
t.datetime "updated_at", null: false
t.integer "procedure_id"
t.integer "order_place"
t.string "lien_demarche"
end
create_table "users", force: :cascade do |t|

View file

@ -56,6 +56,31 @@ describe RootController, type: :controller do
end
it { expect(response.body).to have_css('#landing') }
end
context 'environment is not development' do
render_views
before do
Rails.env.stub(:development? => false)
subject
end
it { expect(response.body).to have_link('Démonstration', href: "https://tps-dev.apientreprise.fr#{ users_sign_in_demo_path }") }
end
context 'environment is development' do
render_views
before do
Rails.env.stub(:development? => true)
subject
end
it { expect(response.body).to have_link('Démonstration', href: users_sign_in_demo_path) }
end
context 'when opensimplif features is true' do
@ -81,4 +106,5 @@ describe RootController, type: :controller do
expect(response.body).to have_css("a[href='#{new_user_session_path}']")
end
end
end

View file

@ -681,27 +681,32 @@ describe Dossier do
end
end
describe '#export_headers' do
context 'when dossier is followed' do
let(:procedure) { create(:procedure, :with_type_de_champ) }
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
subject { dossier.export_headers }
let(:gestionnaire) { create(:gestionnaire) }
let(:follow) { create(:follow, gestionnaire: gestionnaire) }
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure, follows: [follow]) }
it { expect(subject).to include(:description) }
it { expect(subject.count).to eq(DossierProcedureSerializer.new(dossier).attributes.count + dossier.procedure.types_de_champ.count + dossier.export_entreprise_data.count) }
end
describe '#export_headers' do
describe '#data_with_champs' do
let(:procedure) { create(:procedure, :with_type_de_champ) }
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
subject { dossier.data_with_champs }
subject { dossier.export_headers }
it { expect(subject[0]).to be_a_kind_of(Integer) }
it { expect(subject[1]).to be_a_kind_of(Time) }
it { expect(subject[2]).to be_a_kind_of(Time) }
it { expect(subject[3]).to be_in([true, false]) }
it { expect(subject[4]).to be_in([true, false]) }
it { expect(subject[5]).to eq("draft") }
it { expect(subject.count).to eq(DossierProcedureSerializer.new(dossier).attributes.count + dossier.procedure.types_de_champ.count + dossier.export_entreprise_data.count) }
it { expect(subject).to include(:description) }
it { expect(subject.count).to eq(DossierProcedureSerializer.new(dossier).attributes.count + dossier.procedure.types_de_champ.count + dossier.export_entreprise_data.count) }
end
describe '#data_with_champs' do
subject { dossier.data_with_champs }
it { expect(subject[0]).to be_a_kind_of(Integer) }
it { expect(subject[1]).to be_a_kind_of(Time) }
it { expect(subject[2]).to be_a_kind_of(Time) }
it { expect(subject[3]).to be_in([true, false]) }
it { expect(subject[4]).to be_in([true, false]) }
it { expect(subject[5]).to eq("draft") }
it { expect(subject[6]).to eq(dossier.followers_gestionnaires_emails) }
it { expect(subject.count).to eq(DossierProcedureSerializer.new(dossier).attributes.count + dossier.procedure.types_de_champ.count + dossier.export_entreprise_data.count) }
end
end
describe '#Dossier.to_csv' do
@ -746,6 +751,7 @@ describe Dossier do
it { expect(subject[:entreprise_prenom]).to be_nil }
end
describe '#Dossier.to_xlsx' do
let!(:procedure) { create(:procedure) }
let!(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
@ -930,4 +936,39 @@ describe Dossier do
it { is_expected.to be_falsey }
end
end
describe '#followers_gestionnaires_emails' do
context 'when there is no follower' do
let(:dossier) { create(:dossier, follows: []) }
subject { dossier.followers_gestionnaires_emails }
it { is_expected.to eq "" }
end
let(:gestionnaire) { create(:gestionnaire) }
let(:follow) { create(:follow, gestionnaire: gestionnaire) }
context 'when there is 1 follower' do
let(:dossier) { create(:dossier, follows: [follow]) }
subject { dossier.followers_gestionnaires_emails }
it { is_expected.to eq gestionnaire.email }
end
let(:gestionnaire2) { create :gestionnaire}
let(:follow2) { create(:follow, gestionnaire: gestionnaire2) }
context 'when there is 2 followers' do
let(:dossier) { create(:dossier, follows: [follow, follow2]) }
subject { dossier.followers_gestionnaires_emails }
it { is_expected.to eq "#{gestionnaire.email} #{gestionnaire2.email}" }
end
end
end

View file

@ -10,6 +10,7 @@ describe TypeDePieceJustificative do
it { is_expected.to have_db_column(:created_at) }
it { is_expected.to have_db_column(:updated_at) }
it { is_expected.to have_db_column(:order_place) }
it { is_expected.to have_db_column(:lien_demarche) }
end
describe 'associations' do
@ -29,5 +30,12 @@ describe TypeDePieceJustificative do
# it { is_expected.not_to allow_value('').for(:order_place) }
it { is_expected.to allow_value(1).for(:order_place) }
end
context 'lien_demarche' do
it { is_expected.not_to allow_value(nil).for(:lien_demarche) }
it { is_expected.not_to allow_value('').for(:lien_demarche) }
it { is_expected.not_to allow_value('not-a-link').for(:lien_demarche) }
it { is_expected.to allow_value('http://link').for(:lien_demarche) }
end
end
end