From cc36ec49e277a538fb6c6d8e27484ef08fa6e30e Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Fri, 14 Apr 2017 16:14:17 +0200 Subject: [PATCH 01/26] Remove tps_v2 reference in deploy script --- config/deploy.rb | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/config/deploy.rb b/config/deploy.rb index f03e38682..13367378b 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -11,7 +11,7 @@ require 'mina/rbenv' # for rbenv support. (http://rbenv.org) # branch - Branch name to deploy. (needed by mina/git) ENV['to'] ||= "staging" -raise "Bad to=#{+ENV['to']}" unless ["staging", "production", "tps_v2"].include?(ENV['to']) +raise "Bad to=#{+ENV['to']}" unless ["staging", "production"].include?(ENV['to']) raise "missing domain, run with 'rake deploy domain=37.187.154.237'" if ENV['domain'].nil? @@ -42,23 +42,10 @@ elsif ENV["to"] == "production" set :deploy_to, '/var/www/tps' set :user, 'tps' # Username in the server to SSH to. appname = 'tps' -elsif ENV["to"] == "tps_v2" - if ENV['branch'].nil? - set :branch, 'staging_v2' - else - set :branch, ENV['branch'] - end - set :deploy_to, '/var/www/tps_v2' - set :user, 'tps_v2' # Username in the server to SSH to. - appname = 'tps_v2' end set :rails_env, ENV["to"] -if ENV["to"] == "tps_v2" - set :rails_env, "staging" -end - # For system-wide RVM install. # set :rvm_path, '/usr/local/rvm/bin/rvm' From 21ff863dab8bbe36ad5a583e032fe5c631df4e21 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 17 Apr 2017 19:32:26 +0200 Subject: [PATCH 02/26] [Fix #112] Add favicons --- app/assets/images/favicons/16x16.png | Bin 0 -> 466 bytes app/assets/images/favicons/32x32.png | Bin 0 -> 889 bytes app/assets/images/favicons/96x96.png | Bin 0 -> 2557 bytes app/views/layouts/application.html.haml | 4 ++++ 4 files changed, 4 insertions(+) create mode 100644 app/assets/images/favicons/16x16.png create mode 100644 app/assets/images/favicons/32x32.png create mode 100644 app/assets/images/favicons/96x96.png diff --git a/app/assets/images/favicons/16x16.png b/app/assets/images/favicons/16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..c73712dba80395a62963b701b7fd25623182e474 GIT binary patch literal 466 zcmV;@0WJQCP)&sBeXnEk!_StcIcAJ2o)|* zaWI|xoOyM^ciD}Kv`55cdy0?co+KXaHO_1b8SYOpI*tz0eF<}LQ^SvXFu^m!j~k>W za2~)K(nu5jx26ezUH!0jii7P9{Aqb#hpo8#v6G5gq;}}GWtYH&31$A_pu%Yc@;&ir zHU9*P_t=W+th#R8(yO2&uQvpqR{ZTLkSBlfC6V++}-Q zKXGKccQ|vz`!ef_>F z_s*O%XQcHqR9HUXBufe>DqFb<`36^^RCA(y0{@TUq{?QF_rYv_156|ghL9CtBsX9P zUkyh741UkXcOL+FywTvCq=X@$(zZedtv3=`z>TQ?vi??P(oGav|G zfKdoSMXsvnlq4blYJ#_wEdDld#cGf&K3exYhRN^rF1fOBzh9aPTx%4pRA#OFln|0w zU?V{;fUoa6PM10jh1W61w}8vzJX|)1gQ@UD1E!4V+IV|Ejo^D3iJ>l} zS0Zh)%j@(C27-c~MJKD6qoe+Lhf-O(>Nv^TQ1g7S>!js=u;feX_p|0D=ZyjbfQCz{1MK?& zTEAfMocC;nb`AKpLS*EN_QPc&yvPa>JHe9Nh@M_dNyx+xLUZ=iV+{>- zWAg&4cbwHwzQzKQ``qto{GG0)1Rc#C%WuwG9a09=VZD)5;|Mluf}71>A?PLse%x^e zIMzZOCBbCfVGxxew5>XfvVKG*=0r;(&Wx)n(ek^u&Uweod1M!?1rs6az~TMh1D^jI z|EJ-Z!tPuILVj?+kVLsJf?sm84VQNqQT3&58Dk|kmyFl zh>y}9$2{-DN*_fxq>B;#3T;z-FGR2tln~0j3;z$N#dmKEgB6T|Q7{Ssgk;6$fjMIX P00000NkvXXu0mjfNvWgr literal 0 HcmV?d00001 diff --git a/app/assets/images/favicons/96x96.png b/app/assets/images/favicons/96x96.png new file mode 100644 index 0000000000000000000000000000000000000000..a4d73f1d7fe22f6040d9dab3fcaddae339916782 GIT binary patch literal 2557 zcmaKu`6Cky1Axa|BWCWi+>6juGURMt%-M1zVUvV~SQ+vW=3FF4$eAmtrPo=xnIQ}% zwH(WlB{Fl*`M%#D@O?i#&+{)lDUSA*g8VZ4002PH+6saCx9I=E$Mdh}^6+o~07SM% zm^p=i|8qm&k<%CHnLYC}#-cS%tb}hhy?&YjEa{@J+FT8!WM}-g@x)67LP8zC@o$$D z{wu(tqFc?EnjX4Li(f&II8=9oY)pqP28y3huoBPdeZU+73>F{7TrBuaWi#$Gy&y=-j^}u2OIWmW76SvA6OLJh_JGSnl zj!r6^X=oW;p^wwe%kJP+D4ddBn}YU`@;@Wh=x>8LyTcSB#7|DcB=`pRSY}Y;XUGzM zuC`Y5CJ1P%?yCaG*`KlDuH>y-Gi((oKOZE zcF@j8@tWO9v$`7+2Xi5Y%-fIN32k*}-PJ<4s4N)^;|_@Ys}&KekIT{@i1IDE?as7w zcH8!}3B>dM=CL3NUT zil>!fW(U>RUtRECnJSu}u*;*_Jvpv4dMOI_@z^k9@`BOc&~ewqD5y~(%#e9{EXtt9 zNJ3)&q{UI)%Rr@P_Z07LXgT9b=Y?)QMgR;)vuYj!rW!?t>9M}nlS-^LVgb`}VWi|} zN^hEe@{f6Sy=C{M$j}6|oq*IGwle53!`Fk@0~EaT$Nk(~3wF5JZKpP~SHVc?%&%z> zMHKaQyvae+3y|LYSJ|QLy-NSy@t2l28<2j{-$^CASXjbY#|RZ$JXREN@?#^#)4C$c zl^q@aX|kjqZY7Cz6Xr2#q?|$QmMm>B3nr3#U~y_$5d)jS4IsrJ>eHdE>AKH??*&4S zD@kY(yPEcf;rLPLogM=a)|w~7Nm}`G^^+dPP zp%^&OBArZE@lToU3N!t5nAHvNg1&{y)w=0;;H0%Zh1iddzTuQYf#T@|NTt z=G)i&^03End)VJIy7e8*ANFGVd}kexWCu_#hJXMpi&Nj%zHQHeSvo-2(7JvwZU!N? zm0R-$!nGY2aJ~Mvwa~2giBYlrQN~SP83^}?cItuZoZlUh@&GB_vqX;6=_MOgD)}i& zHUQka-FYN1`s8Zt07b>k!aBO>5y4BT|CkS-m}nKA_!{A6ud$ahWwDFX{W;N>0STGP zL#W$%9U)yzQ>i0`FV!W-)${9}(|JSUUvD8?wE$Paeuh8&LAWVB6Qa6^LImhJ+bebv z{3TmZUP-5jw^LJ4qpj9Nl?T~EN3C9)J7XYLy#v*XsbZ%c?!`YXIP2Oj_-5)uEe^n4lKYS#Z zG6iOS&KnxaNHVY%^w_a#o?P7N0DYaLO8y|S4{!XR<2XNYy3^-6*MXmnS4eY7=vCAq zopzC=Tq3-UF%f#EWpVM?pcQkOE0yUTdWClD(mIcT1WP^`sfyG3_8EA+BTe{2-j~hm zt`0@{!=I~;j8_r|HS!qJTno^b0LZJzJSV4UBXy>(Qr{#eFD5X9(|DID8Fz*q5G$L# z%-XI%PCe4Yf)->AA3KBPKF`9y1k&$r1YTCv0@rgL^eOu&<@v)aeAU z**r+ivt8gt>p=L(yX56p4(0xP9oFv-q54}~Zb*fo*91O;SoQd_)a5o;kCN5pXf@t# z&R)?M&P#}`)*>%($Sh1Qv9U4UKy zn*Nyl%>>D|bZOd6

U7_5XY)ACSD$gn6YOQZ@Rd9wY6SD}G~?>b>mqunCuQ`|=*D zl}e~8<0RJ-tD8)d)csviplE$9Y~w_B-E_`VLIl?Sr-ui2nvAHeog zd3F2_*f~_y=Z2|z(AXi}>RyY?cIoyFshLzK;j6!FD$?$rdr_`OI8LxT+jV3#T6>)!VUKuYj*j~W7NyK~ literal 0 HcmV?d00001 diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 053d04646..0508e568c 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -6,6 +6,10 @@ = t('dynamics.page_title') %meta{ 'http-equiv' => "X-UA-Compatible", :content => "IE=edge" } + = favicon_link_tag(image_url("favicons/16x16.png"), type: "image/png", sizes: "16x16") + = favicon_link_tag(image_url("favicons/32x32.png"), type: "image/png", sizes: "32x32") + = favicon_link_tag(image_url("favicons/96x96.png"), type: "image/png", sizes: "96x96") + = 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 From 858109c64b3997879c1ec1c57907198b3032beb2 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 17 Apr 2017 12:11:50 +0200 Subject: [PATCH 03/26] Add the complete french number part of fr.yml --- config/locales/fr.yml | 54 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 5f8a4ad9e..1a47bd2a1 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -37,13 +37,53 @@ fr: first: Premier number: - currency: - format: - unit: '€' - delimiter: ' ' - separator: ',' - precision: 2 - format: '%n %u' + currency: + format: + delimiter: " " + format: "%n %u" + precision: 2 + separator: "," + significant: false + strip_insignificant_zeros: false + unit: "€" + format: + delimiter: " " + precision: 3 + separator: "," + significant: false + strip_insignificant_zeros: false + human: + decimal_units: + format: "%n %u" + units: + billion: milliard + million: million + quadrillion: million de milliards + thousand: millier + trillion: billion + unit: '' + format: + delimiter: '' + precision: 3 + significant: true + strip_insignificant_zeros: true + storage_units: + format: "%n %u" + units: + byte: + one: octet + other: octets + gb: Go + kb: ko + mb: Mo + tb: To + percentage: + format: + delimiter: '' + format: "%n%" + precision: + format: + delimiter: '' activerecord: errors: models: From 3abbb0bdcd45a0785b99b2bf31bb4111683b0b1c Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 17 Apr 2017 12:12:19 +0200 Subject: [PATCH 04/26] Use french formatting for numbers on the Stats page --- app/views/stats/index.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/stats/index.html.haml b/app/views/stats/index.html.haml index 42d6ea90c..9eef92610 100644 --- a/app/views/stats/index.html.haml +++ b/app/views/stats/index.html.haml @@ -43,11 +43,11 @@ .stat-card.stat-card-half.big-number-card.pull-left %span.big-number-card-title TOTAL DÉMARCHES DÉMATÉRIALISÉES %span.big-number-card-number - = @procedures_count + = number_with_delimiter(@procedures_count, :locale => :fr) .stat-card.stat-card-half.big-number-card.pull-left %span.big-number-card-title TOTAL DOSSIERS DÉPOSÉS %span.big-number-card-number - = @dossiers_count + = number_with_delimiter(@dossiers_count, :locale => :fr) .clearfix From a907b9c0625f86210c184216c0a324d5218d7a79 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 29 Mar 2017 14:30:29 +0200 Subject: [PATCH 05/26] Migration: add mandatory column to type de piece justificative --- ...0_add_mandatory_column_to_types_de_piece_justificative.rb | 5 +++++ db/schema.rb | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170328142700_add_mandatory_column_to_types_de_piece_justificative.rb diff --git a/db/migrate/20170328142700_add_mandatory_column_to_types_de_piece_justificative.rb b/db/migrate/20170328142700_add_mandatory_column_to_types_de_piece_justificative.rb new file mode 100644 index 000000000..46f603b62 --- /dev/null +++ b/db/migrate/20170328142700_add_mandatory_column_to_types_de_piece_justificative.rb @@ -0,0 +1,5 @@ +class AddMandatoryColumnToTypesDePieceJustificative < ActiveRecord::Migration[5.0] + def change + add_column :types_de_piece_justificative, :mandatory, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 0ff0aa06a..e390453da 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170313140834) do +ActiveRecord::Schema.define(version: 20170328142700) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -403,6 +403,7 @@ ActiveRecord::Schema.define(version: 20170313140834) do t.integer "procedure_id" t.integer "order_place" t.string "lien_demarche" + t.boolean "mandatory", default: false end create_table "users", force: :cascade do |t| From e49ea2d0e0465d62186c693e8fa65b0c91bed30b Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 29 Mar 2017 14:38:54 +0200 Subject: [PATCH 06/26] PiecesJustificative: add field to set it mandatory small css to align the fields --- .../pieces_justificatives_fields.scss | 3 + .../admin/pieces_justificatives_controller.rb | 2 +- .../pieces_justificatives/_fields.html.haml | 61 ++++++++++--------- 3 files changed, 37 insertions(+), 29 deletions(-) create mode 100644 app/assets/stylesheets/pieces_justificatives_fields.scss diff --git a/app/assets/stylesheets/pieces_justificatives_fields.scss b/app/assets/stylesheets/pieces_justificatives_fields.scss new file mode 100644 index 000000000..12a88199c --- /dev/null +++ b/app/assets/stylesheets/pieces_justificatives_fields.scss @@ -0,0 +1,3 @@ +.pieces_justificatives_fields { + .form-inline > .form-group { vertical-align: top; } +} diff --git a/app/controllers/admin/pieces_justificatives_controller.rb b/app/controllers/admin/pieces_justificatives_controller.rb index c899e3486..0f6d14987 100644 --- a/app/controllers/admin/pieces_justificatives_controller.rb +++ b/app/controllers/admin/pieces_justificatives_controller.rb @@ -25,7 +25,7 @@ class Admin::PiecesJustificativesController < AdminController def update_params params .require(:procedure) - .permit(types_de_piece_justificative_attributes: [:libelle, :description, :id, :order_place, :lien_demarche]) + .permit(types_de_piece_justificative_attributes: [:libelle, :description, :id, :order_place, :mandatory, :lien_demarche]) end def move_up diff --git a/app/views/admin/pieces_justificatives/_fields.html.haml b/app/views/admin/pieces_justificatives/_fields.html.haml index 7cbdf5a99..82ec1d409 100644 --- a/app/views/admin/pieces_justificatives/_fields.html.haml +++ b/app/views/admin/pieces_justificatives/_fields.html.haml @@ -1,31 +1,36 @@ -= f.fields_for :types_de_piece_justificative, types_de_piece_justificative, remote: true do |ff| - .form-inline - .form-group - %h4 Libellé - = ff.text_field :libelle, class: 'form-control libelle', placeholder: 'Libellé' - .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' +.pieces_justificatives_fields + = f.fields_for :types_de_piece_justificative, types_de_piece_justificative, remote: true do |ff| + .form-inline + .form-group + %h4 Libellé + = ff.text_field :libelle, class: 'form-control libelle', placeholder: 'Libellé' + .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 + = ff.hidden_field :id + - unless ff.object.id.nil? + .form-group + %br   + = ff.object.button_up(index: ff.index, url: move_up_admin_procedure_pieces_justificatives_path(@procedure, ff.index)) + = ff.object.button_down(index: ff.index, url: move_down_admin_procedure_pieces_justificatives_path(@procedure, ff.index)) + + .form-group + %h4 Obligatoire ? + .center + = ff.check_box :mandatory - .form-group - = ff.hidden_field :order_place, value: ff.index - = ff.hidden_field :id - - unless ff.object.id.nil? .form-group %br   - = ff.object.button_up(index: ff.index, url: move_up_admin_procedure_pieces_justificatives_path(@procedure, ff.index)) - = ff.object.button_down(index: ff.index, url: move_down_admin_procedure_pieces_justificatives_path(@procedure, ff.index)) - - - .form-group - %br   - - if ff.object.id.nil? - = 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) ) + - if ff.object.id.nil? + = 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) ) From 03e9cd523ea23c223cbdb8a5c53e564f8dfcebc4 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 29 Mar 2017 21:42:52 +0200 Subject: [PATCH 07/26] PiecesJustificativesService: mandatory pj check and add test --- app/services/pieces_justificatives_service.rb | 49 ++++++----- .../pieces_justificatives_service_spec.rb | 81 +++++++++++++++++++ 2 files changed, 112 insertions(+), 18 deletions(-) create mode 100644 spec/services/pieces_justificatives_service_spec.rb diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index 266c4fffa..2f2d1eb16 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -1,25 +1,21 @@ class PiecesJustificativesService - def self.upload! dossier, user, params - errors = '' + def self.upload!(dossier, user, params) + tpj_contents = dossier.types_de_piece_justificative + .map { |tpj| [tpj, params["piece_justificative_#{tpj.id}"]] } + .select { |_, content| content } - dossier.types_de_piece_justificative.each do |type_de_pieces_justificatives| - unless params["piece_justificative_#{type_de_pieces_justificatives.id}"].nil? + without_virus, with_virus = tpj_contents + .partition { |_, content| ClamavService.safe_file?(content.path) } - if ClamavService.safe_file? params["piece_justificative_#{type_de_pieces_justificatives.id}"].path - piece_justificative = PieceJustificative.new(content: params["piece_justificative_#{type_de_pieces_justificatives.id}"], - dossier: dossier, - type_de_piece_justificative: type_de_pieces_justificatives, - user: user) + errors = with_virus + .map { |_, content| content.original_filename + ': Virus détecté !!
' } - unless piece_justificative.save - errors << piece_justificative.errors.messages[:content][0]+" (#{piece_justificative.libelle})"+"
" - end - else - errors << params["piece_justificative_#{type_de_pieces_justificatives.id}"].original_filename+": Virus détecté !!"+"
" - end - end - end - errors + errors += without_virus + .map { |tpj, content| save_pj(content, dossier, tpj, user) } + + errors += missing_pj_error_messages(dossier) + + errors.join end def self.upload_one! dossier, user, params @@ -37,4 +33,21 @@ class PiecesJustificativesService piece_justificative end + + def self.save_pj(content, dossier, tpj, user) + pj = PieceJustificative.new(content: content, + dossier: dossier, + type_de_piece_justificative: tpj, + user: user) + + pj.save ? '' : "le fichier #{pj.libelle} n'a pas pu être sauvegardé
" + end + + def self.missing_pj_error_messages(dossier) + mandatory_pjs = dossier.types_de_piece_justificative.select(&:mandatory) + present_pjs = dossier.pieces_justificatives.map(&:type_de_piece_justificative) + missing_pjs = mandatory_pjs - present_pjs + + missing_pjs.map { |pj| "La pièce jointe #{pj.libelle} doit être fournie.
" } + end end diff --git a/spec/services/pieces_justificatives_service_spec.rb b/spec/services/pieces_justificatives_service_spec.rb new file mode 100644 index 000000000..8f10f4eb8 --- /dev/null +++ b/spec/services/pieces_justificatives_service_spec.rb @@ -0,0 +1,81 @@ +require 'spec_helper' + +describe PiecesJustificativesService do + let(:user) { create(:user) } + let(:safe_file) { true } + + before :each do + allow(ClamavService).to receive(:safe_file?).and_return(safe_file) + end + + describe 'self.upload!' do + let(:hash) { {} } + let!(:tpj_not_mandatory) do + TypeDePieceJustificative.create(libelle: 'not mandatory', mandatory: false) + end + let!(:tpj_mandatory) do + TypeDePieceJustificative.create(libelle: 'justificatif', mandatory: true) + end + let(:procedure) { Procedure.create(types_de_piece_justificative: tpjs) } + let(:dossier) { Dossier.create(procedure: procedure) } + let(:errors) { PiecesJustificativesService.upload!(dossier, user, hash) } + + context 'when no piece justificative is required' do + let(:tpjs) { [tpj_not_mandatory] } + + context 'when no params are given' do + it { expect(errors).to eq('') } + end + + context 'when sometihing wrong with file save' do + let(:hash) do + { + "piece_justificative_#{tpj_not_mandatory.id}" => + double(path: '', original_filename: 'file') + } + end + + it { expect(errors).to eq("le fichier not mandatory n'a pas pu être sauvegardé
") } + end + + context 'when a virus is provided' do + let(:safe_file) { false } + let(:hash) do + { + "piece_justificative_#{tpj_not_mandatory.id}" => + double(path: '', original_filename: 'bad_file') + } + end + + it { expect(errors).to eq('bad_file: Virus détecté !!
') } + end + end + + context 'when a piece justificative is required' do + let(:tpjs) { [tpj_mandatory] } + + context 'when no params are given' do + it { expect(errors).to eq('La pièce jointe justificatif doit être fournie.
') } + end + + context 'when the piece justificative is provided' do + before :each do + # we are messing around piece_justificative + # because directly doubling carrierwave params seems complicated + + allow(PiecesJustificativesService).to receive(:save_pj).and_return('') + piece_justificative_double = double(type_de_piece_justificative: tpj_mandatory) + expect(dossier).to receive(:pieces_justificatives).and_return([piece_justificative_double]) + end + + let(:hash) do + { + "piece_justificative_#{tpj_mandatory.id}" => double(path: '') + } + end + + it { expect(errors).to eq('') } + end + end + end +end From 591ed2037e4e9e9b9fbb724ee5053f73394cc196 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 29 Mar 2017 21:58:26 +0200 Subject: [PATCH 08/26] PiecesJustificativesServices: refactor upload_one! --- app/services/pieces_justificatives_service.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index 2f2d1eb16..8dc309df8 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -19,19 +19,20 @@ class PiecesJustificativesService end def self.upload_one! dossier, user, params - if ClamavService.safe_file? params[:piece_justificative][:content].path - piece_justificative = PieceJustificative.new(content: params[:piece_justificative][:content], - dossier: dossier, - type_de_piece_justificative: nil, - user: user) + content = params[:piece_justificative][:content] + if ClamavService.safe_file? content.path + pj = PieceJustificative.new(content: content, + dossier: dossier, + type_de_piece_justificative: nil, + user: user) - piece_justificative.save + pj.save else - piece_justificative = PieceJustificative.new - piece_justificative.errors.add(:content, params[:piece_justificative][:content].original_filename+": Virus détecté !!") + pj = PieceJustificative.new + pj.errors.add(:content, content.original_filename + ': Virus détecté !!') end - piece_justificative + pj end def self.save_pj(content, dossier, tpj, user) From 367b7c6ae169fe80224d65dd0c1544bf889023ff Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 30 Mar 2017 09:50:30 +0200 Subject: [PATCH 09/26] DescriptionController: use common system to redirect with errors --- .../private_formulaires_controller.rb | 2 +- .../users/description_controller.rb | 24 ++++++++----------- app/services/champs_service.rb | 6 +---- app/services/pieces_justificatives_service.rb | 9 ++++--- spec/services/champs_service_spec.rb | 2 +- .../pieces_justificatives_service_spec.rb | 10 ++++---- 6 files changed, 22 insertions(+), 31 deletions(-) diff --git a/app/controllers/backoffice/private_formulaires_controller.rb b/app/controllers/backoffice/private_formulaires_controller.rb index 81a728085..3c62ad362 100644 --- a/app/controllers/backoffice/private_formulaires_controller.rb +++ b/app/controllers/backoffice/private_formulaires_controller.rb @@ -10,7 +10,7 @@ class Backoffice::PrivateFormulairesController < ApplicationController if champs_service_errors.empty? flash[:notice] = "Formulaire enregistré" else - flash[:alert] = (champs_service_errors.inject('') { |acc, error| acc+= error[:message]+'
' }).html_safe + flash[:alert] = champs_service_errors.join('
').html_safe end end diff --git a/app/controllers/users/description_controller.rb b/app/controllers/users/description_controller.rb index a45a402fb..49664c5b6 100644 --- a/app/controllers/users/description_controller.rb +++ b/app/controllers/users/description_controller.rb @@ -38,25 +38,16 @@ class Users::DescriptionController < UsersController params, check_mandatory_fields - unless champs_service_errors.empty? - flash.alert = (champs_service_errors.inject('') { |acc, error| acc+= error[:message]+'
' }).html_safe - return redirect_to users_dossier_description_path(dossier_id: @dossier.id) - end + return redirect_to_description_with_errors(@dossier, champs_service_errors) if champs_service_errors.any? end if @procedure.cerfa_flag? && params[:cerfa_pdf] cerfa = Cerfa.new(content: params[:cerfa_pdf], dossier: @dossier, user: current_user) - unless cerfa.save - flash.alert = cerfa.errors.full_messages.join('
').html_safe - return redirect_to users_dossier_description_path(dossier_id: @dossier.id) - end + return redirect_to_description_with_errors(@dossier, cerfa.errors.full_messages) unless cerfa.save end errors_upload = PiecesJustificativesService.upload!(@dossier, current_user, params) - unless errors_upload.empty? - flash.alert = errors_upload.html_safe - return redirect_to users_dossier_description_path(dossier_id: @dossier.id) - end + return redirect_to_description_with_errors(@dossier, errors_upload) if errors_upload.any? if draft_submission? flash.notice = 'Votre brouillon a bien été sauvegardé.' @@ -88,9 +79,9 @@ class Users::DescriptionController < UsersController if !((errors_upload = PiecesJustificativesService.upload!(@dossier, current_user, params)).empty?) if flash.alert.nil? - flash.alert = errors_upload.html_safe + flash.alert = errors_upload.join('
').html_safe else - flash.alert = (flash.alert + '
' + errors_upload.html_safe).html_safe + flash.alert = (flash.alert + '
' + errors_upload.join('
').html_safe).html_safe end else @@ -111,6 +102,11 @@ class Users::DescriptionController < UsersController private + def redirect_to_description_with_errors(dossier, errors) + flash.alert = errors.join('
').html_safe + redirect_to users_dossier_description_path(dossier_id: dossier.id) + end + def draft_submission? params[:submit] && params[:submit].keys.first == 'brouillon' end diff --git a/app/services/champs_service.rb b/app/services/champs_service.rb index 31b53973f..b35ec4d7b 100644 --- a/app/services/champs_service.rb +++ b/app/services/champs_service.rb @@ -31,11 +31,7 @@ class ChampsService def build_error_messages(champs) champs.select(&:mandatory_and_blank?) - .map { |c| build_champ_error_message(c) } - end - - def build_champ_error_message(champ) - { message: "Le champ #{champ.libelle} doit être rempli." } + .map { |c| "Le champ #{c.libelle} doit être rempli." } end end end diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index 8dc309df8..6b10ecbeb 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -8,14 +8,13 @@ class PiecesJustificativesService .partition { |_, content| ClamavService.safe_file?(content.path) } errors = with_virus - .map { |_, content| content.original_filename + ': Virus détecté !!
' } + .map { |_, content| content.original_filename + ': Virus détecté !!' } errors += without_virus .map { |tpj, content| save_pj(content, dossier, tpj, user) } + .reject(&:empty?) errors += missing_pj_error_messages(dossier) - - errors.join end def self.upload_one! dossier, user, params @@ -41,7 +40,7 @@ class PiecesJustificativesService type_de_piece_justificative: tpj, user: user) - pj.save ? '' : "le fichier #{pj.libelle} n'a pas pu être sauvegardé
" + pj.save ? '' : "le fichier #{pj.libelle} n'a pas pu être sauvegardé" end def self.missing_pj_error_messages(dossier) @@ -49,6 +48,6 @@ class PiecesJustificativesService present_pjs = dossier.pieces_justificatives.map(&:type_de_piece_justificative) missing_pjs = mandatory_pjs - present_pjs - missing_pjs.map { |pj| "La pièce jointe #{pj.libelle} doit être fournie.
" } + missing_pjs.map { |pj| "La pièce jointe #{pj.libelle} doit être fournie." } end end diff --git a/spec/services/champs_service_spec.rb b/spec/services/champs_service_spec.rb index 4e8ce53a1..ee0047ea2 100644 --- a/spec/services/champs_service_spec.rb +++ b/spec/services/champs_service_spec.rb @@ -34,7 +34,7 @@ describe ChampsService do end it 'adds error for the missing mandatory champ' do - expect(@errors).to match([{ message: 'Le champ mandatory doit être rempli.' }]) + expect(@errors).to match(['Le champ mandatory doit être rempli.']) end end diff --git a/spec/services/pieces_justificatives_service_spec.rb b/spec/services/pieces_justificatives_service_spec.rb index 8f10f4eb8..922befc4e 100644 --- a/spec/services/pieces_justificatives_service_spec.rb +++ b/spec/services/pieces_justificatives_service_spec.rb @@ -24,7 +24,7 @@ describe PiecesJustificativesService do let(:tpjs) { [tpj_not_mandatory] } context 'when no params are given' do - it { expect(errors).to eq('') } + it { expect(errors).to eq([]) } end context 'when sometihing wrong with file save' do @@ -35,7 +35,7 @@ describe PiecesJustificativesService do } end - it { expect(errors).to eq("le fichier not mandatory n'a pas pu être sauvegardé
") } + it { expect(errors).to match(["le fichier not mandatory n'a pas pu être sauvegardé"]) } end context 'when a virus is provided' do @@ -47,7 +47,7 @@ describe PiecesJustificativesService do } end - it { expect(errors).to eq('bad_file: Virus détecté !!
') } + it { expect(errors).to match(['bad_file: Virus détecté !!']) } end end @@ -55,7 +55,7 @@ describe PiecesJustificativesService do let(:tpjs) { [tpj_mandatory] } context 'when no params are given' do - it { expect(errors).to eq('La pièce jointe justificatif doit être fournie.
') } + it { expect(errors).to match(['La pièce jointe justificatif doit être fournie.']) } end context 'when the piece justificative is provided' do @@ -74,7 +74,7 @@ describe PiecesJustificativesService do } end - it { expect(errors).to eq('') } + it { expect(errors).to match([]) } end end end From 4c74b04a91e7eea5f7b6d57ab7838cd94d66d66a Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Tue, 18 Apr 2017 17:33:24 +0200 Subject: [PATCH 10/26] Commentaire: use fr local to display date --- app/models/commentaire.rb | 2 +- config/locales/fr.yml | 53 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/app/models/commentaire.rb b/app/models/commentaire.rb index 09c147dd4..0e39e5eba 100644 --- a/app/models/commentaire.rb +++ b/app/models/commentaire.rb @@ -7,7 +7,7 @@ class Commentaire < ActiveRecord::Base after_save :internal_notification def header - "#{email}, " + created_at.localtime.strftime('%d %b %Y %H:%M') + "#{email}, " + I18n.l(created_at.localtime, format: '%d %b %Y %H:%M') end private diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 1a47bd2a1..d67a7166c 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -189,6 +189,59 @@ fr: extension_white_list_error: "Le format de fichier de la pièce jointe n'est pas valide." procedure_archived: "Cette démarche en ligne a été fermée, il n'est plus possible de déposer de dossier." + date: + abbr_day_names: + - dim + - lun + - mar + - mer + - jeu + - ven + - sam + abbr_month_names: + - + - jan. + - fév. + - mar. + - avr. + - mai + - juin + - juil. + - août + - sept. + - oct. + - nov. + - déc. + day_names: + - dimanche + - lundi + - mardi + - mercredi + - jeudi + - vendredi + - samedi + formats: + default: "%d/%m/%Y" + short: "%e %b" + long: "%e %B %Y" + month_names: + - + - janvier + - février + - mars + - avril + - mai + - juin + - juillet + - août + - septembre + - octobre + - novembre + - décembre + order: + - :day + - :month + - :year datetime: distance_in_words: about_x_hours: From 8e7e7a8ab49dc85c10452a387382b93206a07be4 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 19 Apr 2017 10:05:10 +0200 Subject: [PATCH 11/26] Stats Index: remove useless locale --- app/views/stats/index.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/stats/index.html.haml b/app/views/stats/index.html.haml index 9eef92610..19048dfe1 100644 --- a/app/views/stats/index.html.haml +++ b/app/views/stats/index.html.haml @@ -43,11 +43,11 @@ .stat-card.stat-card-half.big-number-card.pull-left %span.big-number-card-title TOTAL DÉMARCHES DÉMATÉRIALISÉES %span.big-number-card-number - = number_with_delimiter(@procedures_count, :locale => :fr) + = number_with_delimiter(@procedures_count) .stat-card.stat-card-half.big-number-card.pull-left %span.big-number-card-title TOTAL DOSSIERS DÉPOSÉS %span.big-number-card-number - = number_with_delimiter(@dossiers_count, :locale => :fr) + = number_with_delimiter(@dossiers_count) .clearfix From e0828dda135bd0b4fd4e7e45824ae7f03542dbbc Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 19 Apr 2017 10:16:30 +0200 Subject: [PATCH 12/26] PiecesJustificativesService: save_pj returns nil if no errors --- app/services/pieces_justificatives_service.rb | 4 ++-- spec/services/pieces_justificatives_service_spec.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index 6b10ecbeb..7be9e0dc2 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -12,7 +12,7 @@ class PiecesJustificativesService errors += without_virus .map { |tpj, content| save_pj(content, dossier, tpj, user) } - .reject(&:empty?) + .compact() errors += missing_pj_error_messages(dossier) end @@ -40,7 +40,7 @@ class PiecesJustificativesService type_de_piece_justificative: tpj, user: user) - pj.save ? '' : "le fichier #{pj.libelle} n'a pas pu être sauvegardé" + pj.save ? nil : "le fichier #{pj.libelle} n'a pas pu être sauvegardé" end def self.missing_pj_error_messages(dossier) diff --git a/spec/services/pieces_justificatives_service_spec.rb b/spec/services/pieces_justificatives_service_spec.rb index 922befc4e..7a734bc48 100644 --- a/spec/services/pieces_justificatives_service_spec.rb +++ b/spec/services/pieces_justificatives_service_spec.rb @@ -63,7 +63,7 @@ describe PiecesJustificativesService do # we are messing around piece_justificative # because directly doubling carrierwave params seems complicated - allow(PiecesJustificativesService).to receive(:save_pj).and_return('') + allow(PiecesJustificativesService).to receive(:save_pj).and_return(nil) piece_justificative_double = double(type_de_piece_justificative: tpj_mandatory) expect(dossier).to receive(:pieces_justificatives).and_return([piece_justificative_double]) end From 395c9d5bb15b8eff2999e63a61b83c5276699bbe Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 19 Apr 2017 10:20:32 +0200 Subject: [PATCH 13/26] PiecesJustificativesService: improve error message when the file cannot be saved --- app/services/pieces_justificatives_service.rb | 2 +- spec/services/pieces_justificatives_service_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index 7be9e0dc2..3bc0291c4 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -40,7 +40,7 @@ class PiecesJustificativesService type_de_piece_justificative: tpj, user: user) - pj.save ? nil : "le fichier #{pj.libelle} n'a pas pu être sauvegardé" + pj.save ? nil : "le fichier #{content.original_filename} (#{pj.libelle}) n'a pas pu être sauvegardé" end def self.missing_pj_error_messages(dossier) diff --git a/spec/services/pieces_justificatives_service_spec.rb b/spec/services/pieces_justificatives_service_spec.rb index 7a734bc48..b9181c01e 100644 --- a/spec/services/pieces_justificatives_service_spec.rb +++ b/spec/services/pieces_justificatives_service_spec.rb @@ -31,11 +31,11 @@ describe PiecesJustificativesService do let(:hash) do { "piece_justificative_#{tpj_not_mandatory.id}" => - double(path: '', original_filename: 'file') + double(path: '', original_filename: 'filename') } end - it { expect(errors).to match(["le fichier not mandatory n'a pas pu être sauvegardé"]) } + it { expect(errors).to match(["le fichier filename (not mandatory) n'a pas pu être sauvegardé"]) } end context 'when a virus is provided' do From 21d7a960626247c33bb2ba2363d19eec691ba36f Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 19 Apr 2017 10:22:30 +0200 Subject: [PATCH 14/26] PiecesJustificativesService: less violent error message in case of virus --- app/services/pieces_justificatives_service.rb | 2 +- spec/services/pieces_justificatives_service_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index 3bc0291c4..dd611550b 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -8,7 +8,7 @@ class PiecesJustificativesService .partition { |_, content| ClamavService.safe_file?(content.path) } errors = with_virus - .map { |_, content| content.original_filename + ': Virus détecté !!' } + .map { |_, content| content.original_filename + ' : virus détecté' } errors += without_virus .map { |tpj, content| save_pj(content, dossier, tpj, user) } diff --git a/spec/services/pieces_justificatives_service_spec.rb b/spec/services/pieces_justificatives_service_spec.rb index b9181c01e..d6ac03c87 100644 --- a/spec/services/pieces_justificatives_service_spec.rb +++ b/spec/services/pieces_justificatives_service_spec.rb @@ -47,7 +47,7 @@ describe PiecesJustificativesService do } end - it { expect(errors).to match(['bad_file: Virus détecté !!']) } + it { expect(errors).to match(['bad_file : virus détecté']) } end end From 71542f6a3a947cae0f0be5c1f3ea0167daafcde1 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 19 Apr 2017 10:24:08 +0200 Subject: [PATCH 15/26] PiecesJustificativesService: more explicit selection of content --- app/services/pieces_justificatives_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index dd611550b..1298897e5 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -2,7 +2,7 @@ class PiecesJustificativesService def self.upload!(dossier, user, params) tpj_contents = dossier.types_de_piece_justificative .map { |tpj| [tpj, params["piece_justificative_#{tpj.id}"]] } - .select { |_, content| content } + .select { |_, content| content.present? } without_virus, with_virus = tpj_contents .partition { |_, content| ClamavService.safe_file?(content.path) } From 157d1818b2917108b816402c310ecb80c22efaad Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 10 Apr 2017 12:29:14 +0200 Subject: [PATCH 16/26] DescriptionController: move instance var to local var --- .../users/description_controller.rb | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/controllers/users/description_controller.rb b/app/controllers/users/description_controller.rb index 49664c5b6..af105cdcc 100644 --- a/app/controllers/users/description_controller.rb +++ b/app/controllers/users/description_controller.rb @@ -24,41 +24,41 @@ class Users::DescriptionController < UsersController end def update - @dossier = current_user_dossier - @procedure = @dossier.procedure + dossier = current_user_dossier + procedure = dossier.procedure - return head :forbidden unless @dossier.can_be_initiated? + return head :forbidden unless dossier.can_be_initiated? - @champs = @dossier.ordered_champs + @champs = dossier.ordered_champs check_mandatory_fields = !draft_submission? if params[:champs] - champs_service_errors = ChampsService.save_champs @dossier.champs, + champs_service_errors = ChampsService.save_champs dossier.champs, params, check_mandatory_fields - return redirect_to_description_with_errors(@dossier, champs_service_errors) if champs_service_errors.any? + return redirect_to_description_with_errors(dossier, champs_service_errors) if champs_service_errors.any? end - if @procedure.cerfa_flag? && params[:cerfa_pdf] - cerfa = Cerfa.new(content: params[:cerfa_pdf], dossier: @dossier, user: current_user) - return redirect_to_description_with_errors(@dossier, cerfa.errors.full_messages) unless cerfa.save + if procedure.cerfa_flag? && params[:cerfa_pdf] + cerfa = Cerfa.new(content: params[:cerfa_pdf], dossier: dossier, user: current_user) + return redirect_to_description_with_errors(dossier, cerfa.errors.full_messages) unless cerfa.save end - errors_upload = PiecesJustificativesService.upload!(@dossier, current_user, params) - return redirect_to_description_with_errors(@dossier, errors_upload) if errors_upload.any? + errors_upload = PiecesJustificativesService.upload!(dossier, current_user, params) + return redirect_to_description_with_errors(dossier, errors_upload) if errors_upload.any? if draft_submission? flash.notice = 'Votre brouillon a bien été sauvegardé.' redirect_to url_for(controller: :dossiers, action: :index, liste: :brouillon) else - if @dossier.draft? - @dossier.initiated! - NotificationMailer.send_notification(@dossier, @dossier.procedure.initiated_mail).deliver_now! + if dossier.draft? + dossier.initiated! + NotificationMailer.send_notification(dossier, procedure.initiated_mail).deliver_now! end flash.notice = 'Félicitations, votre demande a bien été enregistrée.' - redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: @dossier.id) + redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: dossier.id) end end From 866a54085c09d3c4094655709b8deb1d91f0d179 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 30 Mar 2017 10:41:20 +0200 Subject: [PATCH 17/26] DescriptionController: cosmetic --- app/controllers/users/description_controller.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/controllers/users/description_controller.rb b/app/controllers/users/description_controller.rb index af105cdcc..9b7fba56d 100644 --- a/app/controllers/users/description_controller.rb +++ b/app/controllers/users/description_controller.rb @@ -34,10 +34,8 @@ class Users::DescriptionController < UsersController check_mandatory_fields = !draft_submission? if params[:champs] - champs_service_errors = ChampsService.save_champs dossier.champs, - params, - check_mandatory_fields - + champs_service_errors = + ChampsService.save_champs(dossier.champs, params, check_mandatory_fields) return redirect_to_description_with_errors(dossier, champs_service_errors) if champs_service_errors.any? end From eb3bb63a8f2fab2e36d041e49ce9f65158a9098c Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 30 Mar 2017 10:41:39 +0200 Subject: [PATCH 18/26] DescriptionController: remove useless @champs --- app/controllers/users/description_controller.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/controllers/users/description_controller.rb b/app/controllers/users/description_controller.rb index 9b7fba56d..7c42c3cdd 100644 --- a/app/controllers/users/description_controller.rb +++ b/app/controllers/users/description_controller.rb @@ -28,9 +28,6 @@ class Users::DescriptionController < UsersController procedure = dossier.procedure return head :forbidden unless dossier.can_be_initiated? - - @champs = dossier.ordered_champs - check_mandatory_fields = !draft_submission? if params[:champs] From 4cd21580fb4e9706940ec36add36379a9ebfcfb7 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 30 Mar 2017 11:17:22 +0200 Subject: [PATCH 19/26] DescriptionController: move html_safe to the view html_safe could not work upon redirection as stated here : https://groups.google.com/forum/#!topic/rubyonrails-core/z52zgDgUmbs --- app/controllers/users/description_controller.rb | 2 +- app/views/layouts/_flash_messages.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/users/description_controller.rb b/app/controllers/users/description_controller.rb index 7c42c3cdd..69e17b4a8 100644 --- a/app/controllers/users/description_controller.rb +++ b/app/controllers/users/description_controller.rb @@ -98,7 +98,7 @@ class Users::DescriptionController < UsersController private def redirect_to_description_with_errors(dossier, errors) - flash.alert = errors.join('
').html_safe + flash.alert = errors.join('
') redirect_to users_dossier_description_path(dossier_id: dossier.id) end diff --git a/app/views/layouts/_flash_messages.html.haml b/app/views/layouts/_flash_messages.html.haml index 2ed1b4013..a661dcdbd 100644 --- a/app/views/layouts/_flash_messages.html.haml +++ b/app/views/layouts/_flash_messages.html.haml @@ -4,4 +4,4 @@ = flash.notice - if flash.alert .alert.alert-danger - = flash.alert + = flash.alert.html_safe From ba4ee68019eb8624a6324ced6d740ab8e4dcdc26 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 6 Apr 2017 18:09:41 +0200 Subject: [PATCH 20/26] Use masculine ordinal indicator instead of the degree sign MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s the right way to contract “numéro” We should use the superscript lowercase o but it’s hard to do in places where only raw text is available --- app/assets/javascripts/carte/cadastre.js | 2 +- app/decorators/notification_decorator.rb | 2 +- app/mailers/notification_mailer.rb | 2 +- app/models/mails/closed_mail.rb | 2 +- app/models/mails/initiated_mail.rb | 2 +- app/models/mails/received_mail.rb | 2 +- app/models/mails/refused_mail.rb | 2 +- app/models/mails/without_continuation_mail.rb | 2 +- app/models/notification.rb | 2 +- app/models/preference_list_dossier.rb | 2 +- app/services/notification_service.rb | 2 +- app/views/cgu/index.html.haml | 8 ++++---- ...ft_panel_backoffice_dossierscontroller_index.html.haml | 2 +- app/views/mails/closed_mail.html.haml | 2 +- app/views/mails/initiated_mail.html.haml | 2 +- app/views/mails/received_mail.html.haml | 2 +- app/views/mails/refused_mail.html.haml | 2 +- app/views/mails/without_continuation_mail.html.haml | 2 +- config/locales/dynamics/fr.yml | 2 +- ...901082824_initiated_all_received_mail_for_procedure.rb | 4 ++-- spec/factories/mail_templates.rb | 4 ++-- spec/mailers/notification_mailer_spec.rb | 2 +- spec/models/preference_list_dossier_spec.rb | 2 +- 23 files changed, 28 insertions(+), 28 deletions(-) diff --git a/app/assets/javascripts/carte/cadastre.js b/app/assets/javascripts/carte/cadastre.js index ea9de02a8..d46cfecfd 100644 --- a/app/assets/javascripts/carte/cadastre.js +++ b/app/assets/javascripts/carte/cadastre.js @@ -33,7 +33,7 @@ function display_cadastre(cadastre_array) { else if (cadastre_array.length > 0) { cadastre_array.forEach(function (cadastre) { - $("#cadastre.list ul").append('

  • Parcelle n°' + cadastre.numero + ' - Feuille ' + cadastre.code_arr + ' ' + cadastre.section + ' ' + cadastre.feuille+ '
  • '); + $("#cadastre.list ul").append('
  • Parcelle nº' + cadastre.numero + ' - Feuille ' + cadastre.code_arr + ' ' + cadastre.section + ' ' + cadastre.feuille+ '
  • '); cadastreItems.addData(cadastre.geometry); }); diff --git a/app/decorators/notification_decorator.rb b/app/decorators/notification_decorator.rb index 0763f1dc2..e020dcbca 100644 --- a/app/decorators/notification_decorator.rb +++ b/app/decorators/notification_decorator.rb @@ -3,6 +3,6 @@ class NotificationDecorator < Draper::Decorator def index_display ['champs', 'piece_justificative'].include?(type_notif) ? type = liste.join(" ") : type = liste.last - { dossier: "Dossier n°#{dossier.id}", date: created_at.strftime('%d/%m %H:%M'), type: type } + { dossier: "Dossier nº#{dossier.id}", date: created_at.strftime('%d/%m %H:%M'), type: type } end end diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb index 185543d22..f00e90c93 100644 --- a/app/mailers/notification_mailer.rb +++ b/app/mailers/notification_mailer.rb @@ -12,7 +12,7 @@ class NotificationMailer < ApplicationMailer end def new_answer dossier - send_mail dossier, "Nouveau message pour votre dossier TPS N°#{dossier.id}" + send_mail dossier, "Nouveau message pour votre dossier TPS Nº#{dossier.id}" end private diff --git a/app/models/mails/closed_mail.rb b/app/models/mails/closed_mail.rb index 3db0d84dc..58dbff537 100644 --- a/app/models/mails/closed_mail.rb +++ b/app/models/mails/closed_mail.rb @@ -3,7 +3,7 @@ module Mails include MailTemplateConcern DISPLAYED_NAME = "Accusé d'acceptation" - DEFAULT_OBJECT = 'Votre dossier TPS N°--numero_dossier-- a été accepté' + DEFAULT_OBJECT = 'Votre dossier TPS Nº--numero_dossier-- a été accepté' end end diff --git a/app/models/mails/initiated_mail.rb b/app/models/mails/initiated_mail.rb index e39aa0e7a..b7083b178 100644 --- a/app/models/mails/initiated_mail.rb +++ b/app/models/mails/initiated_mail.rb @@ -3,7 +3,7 @@ module Mails include MailTemplateConcern DISPLAYED_NAME = 'Accusé de réception' - DEFAULT_OBJECT = 'Votre dossier TPS N°--numero_dossier-- a été bien reçu' + DEFAULT_OBJECT = 'Votre dossier TPS Nº--numero_dossier-- a été bien reçu' end end diff --git a/app/models/mails/received_mail.rb b/app/models/mails/received_mail.rb index 41344f6ca..c9ce55f45 100644 --- a/app/models/mails/received_mail.rb +++ b/app/models/mails/received_mail.rb @@ -3,7 +3,7 @@ module Mails include MailTemplateConcern DISPLAYED_NAME = 'Accusé de passage en instruction' - DEFAULT_OBJECT = 'Votre dossier TPS N°--numero_dossier-- va être instruit' + DEFAULT_OBJECT = 'Votre dossier TPS Nº--numero_dossier-- va être instruit' end end diff --git a/app/models/mails/refused_mail.rb b/app/models/mails/refused_mail.rb index a1a1af8b4..18e27c4b1 100644 --- a/app/models/mails/refused_mail.rb +++ b/app/models/mails/refused_mail.rb @@ -3,7 +3,7 @@ module Mails include MailTemplateConcern DISPLAYED_NAME = 'Accusé de rejet du dossier' - DEFAULT_OBJECT = 'Votre dossier TPS N°--numero_dossier-- a été refusé' + DEFAULT_OBJECT = 'Votre dossier TPS Nº--numero_dossier-- a été refusé' end end diff --git a/app/models/mails/without_continuation_mail.rb b/app/models/mails/without_continuation_mail.rb index da9724cf6..01e666de5 100644 --- a/app/models/mails/without_continuation_mail.rb +++ b/app/models/mails/without_continuation_mail.rb @@ -3,7 +3,7 @@ module Mails include MailTemplateConcern DISPLAYED_NAME = 'Accusé de classement sans suite' - DEFAULT_OBJECT = 'Votre dossier TPS N°--numero_dossier-- a été classé sans suite' + DEFAULT_OBJECT = 'Votre dossier TPS Nº--numero_dossier-- a été classé sans suite' end end diff --git a/app/models/notification.rb b/app/models/notification.rb index 4ff810f37..9d1230a33 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -13,7 +13,7 @@ class Notification < ActiveRecord::Base # def broadcast_notification # ActionCable.server.broadcast 'notifications', - # message: "Dossier n°#{self.dossier.id} : #{self.liste.last}", + # message: "Dossier nº#{self.dossier.id} : #{self.liste.last}", # dossier: {id: self.dossier.id} # end end diff --git a/app/models/preference_list_dossier.rb b/app/models/preference_list_dossier.rb index b7880d5c1..60ec5b82c 100644 --- a/app/models/preference_list_dossier.rb +++ b/app/models/preference_list_dossier.rb @@ -36,7 +36,7 @@ class PreferenceListDossier < ActiveRecord::Base table = nil { - dossier_id: create_column('N°', table, 'id', 'id', 1), + dossier_id: create_column('Nº', table, 'id', 'id', 1), created_at: create_column('Créé le', table, 'created_at', 'first_creation', 2), updated_at: create_column('Mise à jour le', table, 'updated_at', 'last_update', 2), state: create_column('État', table, 'state', 'display_state', 1) diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 01bfe97e3..02e5dbf4b 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -34,7 +34,7 @@ class NotificationService when 'champs' attribut when 'submitted' - "Le dossier n°#{@dossier_id} a été déposé." + "Le dossier nº#{@dossier_id} a été déposé." else 'Notification par défaut' end diff --git a/app/views/cgu/index.html.haml b/app/views/cgu/index.html.haml index 7f2116cd0..5f1448c24 100644 --- a/app/views/cgu/index.html.haml +++ b/app/views/cgu/index.html.haml @@ -35,7 +35,7 @@ %br/ Code APE 6202A %br/ - N° TVA : FR 22 424 761 419 + Nº TVA : FR 22 424 761 419 %br/ Siège social : 2 rue Kellermann - 59100 Roubaix - France. %br @@ -61,7 +61,7 @@ Déclaration CNIL %p Le SGMAP a procédé à la déclaration CNIL de TPS. Celle-ci porte le numéro "1986658 v 0" à la date du 30 août 2016. Néanmoins les administrations devront procéder à une déclaration complémentaire auprès de la CNIL si les données du formulaire qu’elles ont produit comportent des données de la nature suivante : %ul - %li N° de sécurité sociale, + %li Nº de sécurité sociale, %li Infractions, condamnations, mesures de sécurité, %li %a{ :href => "https://www.declaration.cnil.fr/declarations/declaration/donneesSensibles_DN.display.action" } Opinions philosophiques, politiques, religieuses, syndicales, vie sexuelle, données de santé, origine raciale. @@ -77,10 +77,10 @@ Traitement des données à caractère personnel %h4 Données personnelles : %p - En application de la loi n°78-17 Informatique et Libertés du 6 janvier 1978, vous disposez d'un droit d'accès, de rectification, de modification et de suppression concernant les données qui vous concernent. Vous pouvez exercer ce droit à travers la rubrique + En application de la loi nº78-17 Informatique et Libertés du 6 janvier 1978, vous disposez d'un droit d'accès, de rectification, de modification et de suppression concernant les données qui vous concernent. Vous pouvez exercer ce droit à travers la rubrique %a{ :href => "http://www.faire-simple.gouv.fr/contact" } Contact %h4 Données de connexion : - %p Conformément à la loi n°2004-575 du 21 juin 2004 pour la confiance dans l’économie numérique, certaines données de connexion sont conservées par le service aux fins de protection contre les intrusions et de poursuites judiciaires le cas échéant. Ces données sont conservées pendant un an. + %p Conformément à la loi nº2004-575 du 21 juin 2004 pour la confiance dans l’économie numérique, certaines données de connexion sont conservées par le service aux fins de protection contre les intrusions et de poursuites judiciaires le cas échéant. Ces données sont conservées pendant un an. %br %h3#entreprise_information diff --git a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml index cd378550c..a4c6a4c8e 100644 --- a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml +++ b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml @@ -39,6 +39,6 @@ - @facade_data_view.dossiers_with_unread_notifications.each do |dossier| = link_to backoffice_dossier_path(dossier.id) do .notification - .dossier-index= "Dossier n°#{dossier.id}" + .dossier-index= "Dossier nº#{dossier.id}" .updated-at-index= dossier.first_unread_notification.created_at.strftime('%d/%m %H:%M') .count= dossier.unreaded_notifications.count diff --git a/app/views/mails/closed_mail.html.haml b/app/views/mails/closed_mail.html.haml index 636817517..3afbbd0cb 100644 --- a/app/views/mails/closed_mail.html.haml +++ b/app/views/mails/closed_mail.html.haml @@ -1,7 +1,7 @@ Bonjour %br %br -Votre dossier N°--numero_dossier-- a été accepté. +Votre dossier Nº--numero_dossier-- a été accepté. %br %br A tout moment, vous pouvez consulter le contenu de vos dossiers et les éventuels commentaires de l'administration à cette adresse : --lien_dossier-- diff --git a/app/views/mails/initiated_mail.html.haml b/app/views/mails/initiated_mail.html.haml index d1e0ab917..e3b5f3ec6 100644 --- a/app/views/mails/initiated_mail.html.haml +++ b/app/views/mails/initiated_mail.html.haml @@ -1,7 +1,7 @@ Bonjour %br %br -Votre administration vous confirme la bonne réception de votre dossier n°--numero_dossier--. +Votre administration vous confirme la bonne réception de votre dossier nº--numero_dossier--. %br %br A tout moment, vous pouvez consulter le contenu de vos dossiers et les éventuels commentaires de l'administration à cette adresse : --lien_dossier-- diff --git a/app/views/mails/received_mail.html.haml b/app/views/mails/received_mail.html.haml index bc0b64ffa..5a17aa07c 100644 --- a/app/views/mails/received_mail.html.haml +++ b/app/views/mails/received_mail.html.haml @@ -1,7 +1,7 @@ Bonjour %br %br -Votre administration vous confirme la bonne réception de votre dossier n°--numero_dossier--. Celui-ci sera instruit dans le délai légal déclaré par votre interlocuteur. +Votre administration vous confirme la bonne réception de votre dossier nº--numero_dossier--. Celui-ci sera instruit dans le délai légal déclaré par votre interlocuteur. %br %br Bonne journée diff --git a/app/views/mails/refused_mail.html.haml b/app/views/mails/refused_mail.html.haml index d98bacab6..22968c704 100644 --- a/app/views/mails/refused_mail.html.haml +++ b/app/views/mails/refused_mail.html.haml @@ -1,7 +1,7 @@ Bonjour %br %br -Votre dossier N°--numero_dossier-- a été refusé. +Votre dossier Nº--numero_dossier-- a été refusé. %br %br Pour en savoir plus sur le motif du refus, vous pouvez consulter le contenu de vos dossiers et les éventuels commentaires de l'administration à cette adresse : --lien_dossier-- diff --git a/app/views/mails/without_continuation_mail.html.haml b/app/views/mails/without_continuation_mail.html.haml index 5277c51a6..77fa27d0e 100644 --- a/app/views/mails/without_continuation_mail.html.haml +++ b/app/views/mails/without_continuation_mail.html.haml @@ -1,7 +1,7 @@ Bonjour %br %br -Votre dossier N°--numero_dossier-- a été classé sans suite. +Votre dossier Nº--numero_dossier-- a été classé sans suite. %br %br Pour en savoir plus sur les raisons de ce classement sans suite, vous pouvez consulter le contenu de vos dossiers et les éventuels commentaires de l'administration à cette adresse : --lien_dossier-- diff --git a/config/locales/dynamics/fr.yml b/config/locales/dynamics/fr.yml index 72c3aa0f2..74931a96b 100644 --- a/config/locales/dynamics/fr.yml +++ b/config/locales/dynamics/fr.yml @@ -23,7 +23,7 @@ fr: dossiers: depositaite: "Dépositaire" - numéro: 'Dossier n°' + numéro: 'Dossier nº' followers: title: "Personnes suivant l'activité de ce dossier" empty: "Aucune personne ne suit ce dossier" diff --git a/db/migrate/20160901082824_initiated_all_received_mail_for_procedure.rb b/db/migrate/20160901082824_initiated_all_received_mail_for_procedure.rb index 225745646..e5bb6db7a 100644 --- a/db/migrate/20160901082824_initiated_all_received_mail_for_procedure.rb +++ b/db/migrate/20160901082824_initiated_all_received_mail_for_procedure.rb @@ -11,11 +11,11 @@ class InitiatedAllReceivedMailForProcedure < ActiveRecord::Migration before_save :default_values def default_values - self.object ||= "[TPS] Accusé de réception pour votre dossier n°--numero_dossier--" + self.object ||= "[TPS] Accusé de réception pour votre dossier nº--numero_dossier--" self.body ||= "Bonjour,

    - Votre administration vous confirme la bonne réception de votre dossier n°--numero_dossier-- complet. Celui-ci sera instruit dans le délais légal déclaré par votre interlocuteur.
    + Votre administration vous confirme la bonne réception de votre dossier nº--numero_dossier-- complet. Celui-ci sera instruit dans le délais légal déclaré par votre interlocuteur.

    En vous souhaitant une bonne journée,
    diff --git a/spec/factories/mail_templates.rb b/spec/factories/mail_templates.rb index aac0d3615..a3940bca8 100644 --- a/spec/factories/mail_templates.rb +++ b/spec/factories/mail_templates.rb @@ -13,8 +13,8 @@ FactoryGirl.define do end trait :dossier_received do - object "[TPS] Accusé de réception pour votre dossier n°--numero_dossier--" - body "Votre administration vous confirme la bonne réception de votre dossier n°--numero_dossier--" + object "[TPS] Accusé de réception pour votre dossier nº--numero_dossier--" + body "Votre administration vous confirme la bonne réception de votre dossier nº--numero_dossier--" type 'MailReceived' end end diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb index 0f9aeba80..e1a634917 100644 --- a/spec/mailers/notification_mailer_spec.rb +++ b/spec/mailers/notification_mailer_spec.rb @@ -19,6 +19,6 @@ RSpec.describe NotificationMailer, type: :mailer do it { expect(subject.body).to match('Un nouveau message est disponible dans votre espace TPS.') } it { expect(subject.body).to include("Pour le consulter, merci de vous rendre sur #{users_dossier_recapitulatif_url(dossier_id: dossier.id)}") } - it { expect(subject.subject).to eq("Nouveau message pour votre dossier TPS N°#{dossier.id}") } + it { expect(subject.subject).to eq("Nouveau message pour votre dossier TPS Nº#{dossier.id}") } end end diff --git a/spec/models/preference_list_dossier_spec.rb b/spec/models/preference_list_dossier_spec.rb index 76abc8441..c54163e12 100644 --- a/spec/models/preference_list_dossier_spec.rb +++ b/spec/models/preference_list_dossier_spec.rb @@ -26,7 +26,7 @@ describe PreferenceListDossier do describe 'dossier_id' do subject { super()[:dossier_id] } - it { expect(subject[:libelle]).to eq 'N°' } + it { expect(subject[:libelle]).to eq 'Nº' } it { expect(subject[:table]).to be_nil } it { expect(subject[:attr]).to eq 'id' } it { expect(subject[:attr_decorate]).to eq 'id' } From aa41349f0cc551ec1aafefcc5e8635568b52bf30 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 6 Apr 2017 18:13:20 +0200 Subject: [PATCH 21/26] =?UTF-8?q?Lowercase=20the=20=E2=80=9Cn=E2=80=9D=20o?= =?UTF-8?q?f=20=E2=80=9Cnum=C3=A9ro=E2=80=9D=20contraction=20where=20neede?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/mailers/notification_mailer.rb | 2 +- app/models/mails/closed_mail.rb | 2 +- app/models/mails/initiated_mail.rb | 2 +- app/models/mails/received_mail.rb | 2 +- app/models/mails/refused_mail.rb | 2 +- app/models/mails/without_continuation_mail.rb | 2 +- app/views/mails/closed_mail.html.haml | 2 +- app/views/mails/refused_mail.html.haml | 2 +- app/views/mails/without_continuation_mail.html.haml | 2 +- spec/mailers/notification_mailer_spec.rb | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb index f00e90c93..15309f718 100644 --- a/app/mailers/notification_mailer.rb +++ b/app/mailers/notification_mailer.rb @@ -12,7 +12,7 @@ class NotificationMailer < ApplicationMailer end def new_answer dossier - send_mail dossier, "Nouveau message pour votre dossier TPS Nº#{dossier.id}" + send_mail dossier, "Nouveau message pour votre dossier TPS nº#{dossier.id}" end private diff --git a/app/models/mails/closed_mail.rb b/app/models/mails/closed_mail.rb index 58dbff537..119cd4f61 100644 --- a/app/models/mails/closed_mail.rb +++ b/app/models/mails/closed_mail.rb @@ -3,7 +3,7 @@ module Mails include MailTemplateConcern DISPLAYED_NAME = "Accusé d'acceptation" - DEFAULT_OBJECT = 'Votre dossier TPS Nº--numero_dossier-- a été accepté' + DEFAULT_OBJECT = 'Votre dossier TPS nº--numero_dossier-- a été accepté' end end diff --git a/app/models/mails/initiated_mail.rb b/app/models/mails/initiated_mail.rb index b7083b178..3419c3692 100644 --- a/app/models/mails/initiated_mail.rb +++ b/app/models/mails/initiated_mail.rb @@ -3,7 +3,7 @@ module Mails include MailTemplateConcern DISPLAYED_NAME = 'Accusé de réception' - DEFAULT_OBJECT = 'Votre dossier TPS Nº--numero_dossier-- a été bien reçu' + DEFAULT_OBJECT = 'Votre dossier TPS nº--numero_dossier-- a été bien reçu' end end diff --git a/app/models/mails/received_mail.rb b/app/models/mails/received_mail.rb index c9ce55f45..8ffda8e21 100644 --- a/app/models/mails/received_mail.rb +++ b/app/models/mails/received_mail.rb @@ -3,7 +3,7 @@ module Mails include MailTemplateConcern DISPLAYED_NAME = 'Accusé de passage en instruction' - DEFAULT_OBJECT = 'Votre dossier TPS Nº--numero_dossier-- va être instruit' + DEFAULT_OBJECT = 'Votre dossier TPS nº--numero_dossier-- va être instruit' end end diff --git a/app/models/mails/refused_mail.rb b/app/models/mails/refused_mail.rb index 18e27c4b1..01f138aca 100644 --- a/app/models/mails/refused_mail.rb +++ b/app/models/mails/refused_mail.rb @@ -3,7 +3,7 @@ module Mails include MailTemplateConcern DISPLAYED_NAME = 'Accusé de rejet du dossier' - DEFAULT_OBJECT = 'Votre dossier TPS Nº--numero_dossier-- a été refusé' + DEFAULT_OBJECT = 'Votre dossier TPS nº--numero_dossier-- a été refusé' end end diff --git a/app/models/mails/without_continuation_mail.rb b/app/models/mails/without_continuation_mail.rb index 01e666de5..b5dfdd638 100644 --- a/app/models/mails/without_continuation_mail.rb +++ b/app/models/mails/without_continuation_mail.rb @@ -3,7 +3,7 @@ module Mails include MailTemplateConcern DISPLAYED_NAME = 'Accusé de classement sans suite' - DEFAULT_OBJECT = 'Votre dossier TPS Nº--numero_dossier-- a été classé sans suite' + DEFAULT_OBJECT = 'Votre dossier TPS nº--numero_dossier-- a été classé sans suite' end end diff --git a/app/views/mails/closed_mail.html.haml b/app/views/mails/closed_mail.html.haml index 3afbbd0cb..0fa0287b1 100644 --- a/app/views/mails/closed_mail.html.haml +++ b/app/views/mails/closed_mail.html.haml @@ -1,7 +1,7 @@ Bonjour %br %br -Votre dossier Nº--numero_dossier-- a été accepté. +Votre dossier nº--numero_dossier-- a été accepté. %br %br A tout moment, vous pouvez consulter le contenu de vos dossiers et les éventuels commentaires de l'administration à cette adresse : --lien_dossier-- diff --git a/app/views/mails/refused_mail.html.haml b/app/views/mails/refused_mail.html.haml index 22968c704..d3510d160 100644 --- a/app/views/mails/refused_mail.html.haml +++ b/app/views/mails/refused_mail.html.haml @@ -1,7 +1,7 @@ Bonjour %br %br -Votre dossier Nº--numero_dossier-- a été refusé. +Votre dossier nº--numero_dossier-- a été refusé. %br %br Pour en savoir plus sur le motif du refus, vous pouvez consulter le contenu de vos dossiers et les éventuels commentaires de l'administration à cette adresse : --lien_dossier-- diff --git a/app/views/mails/without_continuation_mail.html.haml b/app/views/mails/without_continuation_mail.html.haml index 77fa27d0e..4742dadbe 100644 --- a/app/views/mails/without_continuation_mail.html.haml +++ b/app/views/mails/without_continuation_mail.html.haml @@ -1,7 +1,7 @@ Bonjour %br %br -Votre dossier Nº--numero_dossier-- a été classé sans suite. +Votre dossier nº--numero_dossier-- a été classé sans suite. %br %br Pour en savoir plus sur les raisons de ce classement sans suite, vous pouvez consulter le contenu de vos dossiers et les éventuels commentaires de l'administration à cette adresse : --lien_dossier-- diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb index e1a634917..8686c5e55 100644 --- a/spec/mailers/notification_mailer_spec.rb +++ b/spec/mailers/notification_mailer_spec.rb @@ -19,6 +19,6 @@ RSpec.describe NotificationMailer, type: :mailer do it { expect(subject.body).to match('Un nouveau message est disponible dans votre espace TPS.') } it { expect(subject.body).to include("Pour le consulter, merci de vous rendre sur #{users_dossier_recapitulatif_url(dossier_id: dossier.id)}") } - it { expect(subject.subject).to eq("Nouveau message pour votre dossier TPS Nº#{dossier.id}") } + it { expect(subject.subject).to eq("Nouveau message pour votre dossier TPS nº#{dossier.id}") } end end From ddf02ccd6deb0bea02fa26fa5153b160934a62e3 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 6 Apr 2017 18:16:11 +0200 Subject: [PATCH 22/26] =?UTF-8?q?Use=20a=20non-breaking=20space=20after=20?= =?UTF-8?q?the=20=E2=80=9Cnum=C3=A9ro=E2=80=9D=20contraction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/javascripts/carte/cadastre.js | 2 +- app/decorators/notification_decorator.rb | 2 +- app/mailers/notification_mailer.rb | 2 +- app/models/mails/closed_mail.rb | 2 +- app/models/mails/initiated_mail.rb | 2 +- app/models/mails/received_mail.rb | 2 +- app/models/mails/refused_mail.rb | 2 +- app/models/mails/without_continuation_mail.rb | 2 +- app/models/notification.rb | 2 +- app/services/notification_service.rb | 2 +- app/views/cgu/index.html.haml | 8 ++++---- ...ft_panel_backoffice_dossierscontroller_index.html.haml | 2 +- app/views/mails/closed_mail.html.haml | 2 +- app/views/mails/initiated_mail.html.haml | 2 +- app/views/mails/received_mail.html.haml | 2 +- app/views/mails/refused_mail.html.haml | 2 +- app/views/mails/without_continuation_mail.html.haml | 2 +- config/locales/dynamics/fr.yml | 2 +- ...901082824_initiated_all_received_mail_for_procedure.rb | 2 +- spec/factories/mail_templates.rb | 4 ++-- spec/mailers/notification_mailer_spec.rb | 2 +- 21 files changed, 25 insertions(+), 25 deletions(-) diff --git a/app/assets/javascripts/carte/cadastre.js b/app/assets/javascripts/carte/cadastre.js index d46cfecfd..81bff065c 100644 --- a/app/assets/javascripts/carte/cadastre.js +++ b/app/assets/javascripts/carte/cadastre.js @@ -33,7 +33,7 @@ function display_cadastre(cadastre_array) { else if (cadastre_array.length > 0) { cadastre_array.forEach(function (cadastre) { - $("#cadastre.list ul").append('
  • Parcelle nº' + cadastre.numero + ' - Feuille ' + cadastre.code_arr + ' ' + cadastre.section + ' ' + cadastre.feuille+ '
  • '); + $("#cadastre.list ul").append('
  • Parcelle nº ' + cadastre.numero + ' - Feuille ' + cadastre.code_arr + ' ' + cadastre.section + ' ' + cadastre.feuille+ '
  • '); cadastreItems.addData(cadastre.geometry); }); diff --git a/app/decorators/notification_decorator.rb b/app/decorators/notification_decorator.rb index e020dcbca..23cc86273 100644 --- a/app/decorators/notification_decorator.rb +++ b/app/decorators/notification_decorator.rb @@ -3,6 +3,6 @@ class NotificationDecorator < Draper::Decorator def index_display ['champs', 'piece_justificative'].include?(type_notif) ? type = liste.join(" ") : type = liste.last - { dossier: "Dossier nº#{dossier.id}", date: created_at.strftime('%d/%m %H:%M'), type: type } + { dossier: "Dossier nº #{dossier.id}", date: created_at.strftime('%d/%m %H:%M'), type: type } end end diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb index 15309f718..1fa5265ea 100644 --- a/app/mailers/notification_mailer.rb +++ b/app/mailers/notification_mailer.rb @@ -12,7 +12,7 @@ class NotificationMailer < ApplicationMailer end def new_answer dossier - send_mail dossier, "Nouveau message pour votre dossier TPS nº#{dossier.id}" + send_mail dossier, "Nouveau message pour votre dossier TPS nº #{dossier.id}" end private diff --git a/app/models/mails/closed_mail.rb b/app/models/mails/closed_mail.rb index 119cd4f61..2d113f71d 100644 --- a/app/models/mails/closed_mail.rb +++ b/app/models/mails/closed_mail.rb @@ -3,7 +3,7 @@ module Mails include MailTemplateConcern DISPLAYED_NAME = "Accusé d'acceptation" - DEFAULT_OBJECT = 'Votre dossier TPS nº--numero_dossier-- a été accepté' + DEFAULT_OBJECT = 'Votre dossier TPS nº --numero_dossier-- a été accepté' end end diff --git a/app/models/mails/initiated_mail.rb b/app/models/mails/initiated_mail.rb index 3419c3692..4f401e65e 100644 --- a/app/models/mails/initiated_mail.rb +++ b/app/models/mails/initiated_mail.rb @@ -3,7 +3,7 @@ module Mails include MailTemplateConcern DISPLAYED_NAME = 'Accusé de réception' - DEFAULT_OBJECT = 'Votre dossier TPS nº--numero_dossier-- a été bien reçu' + DEFAULT_OBJECT = 'Votre dossier TPS nº --numero_dossier-- a été bien reçu' end end diff --git a/app/models/mails/received_mail.rb b/app/models/mails/received_mail.rb index 8ffda8e21..be65a36b2 100644 --- a/app/models/mails/received_mail.rb +++ b/app/models/mails/received_mail.rb @@ -3,7 +3,7 @@ module Mails include MailTemplateConcern DISPLAYED_NAME = 'Accusé de passage en instruction' - DEFAULT_OBJECT = 'Votre dossier TPS nº--numero_dossier-- va être instruit' + DEFAULT_OBJECT = 'Votre dossier TPS nº --numero_dossier-- va être instruit' end end diff --git a/app/models/mails/refused_mail.rb b/app/models/mails/refused_mail.rb index 01f138aca..281788535 100644 --- a/app/models/mails/refused_mail.rb +++ b/app/models/mails/refused_mail.rb @@ -3,7 +3,7 @@ module Mails include MailTemplateConcern DISPLAYED_NAME = 'Accusé de rejet du dossier' - DEFAULT_OBJECT = 'Votre dossier TPS nº--numero_dossier-- a été refusé' + DEFAULT_OBJECT = 'Votre dossier TPS nº --numero_dossier-- a été refusé' end end diff --git a/app/models/mails/without_continuation_mail.rb b/app/models/mails/without_continuation_mail.rb index b5dfdd638..3d3bd8f74 100644 --- a/app/models/mails/without_continuation_mail.rb +++ b/app/models/mails/without_continuation_mail.rb @@ -3,7 +3,7 @@ module Mails include MailTemplateConcern DISPLAYED_NAME = 'Accusé de classement sans suite' - DEFAULT_OBJECT = 'Votre dossier TPS nº--numero_dossier-- a été classé sans suite' + DEFAULT_OBJECT = 'Votre dossier TPS nº --numero_dossier-- a été classé sans suite' end end diff --git a/app/models/notification.rb b/app/models/notification.rb index 9d1230a33..2d93de8b3 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -13,7 +13,7 @@ class Notification < ActiveRecord::Base # def broadcast_notification # ActionCable.server.broadcast 'notifications', - # message: "Dossier nº#{self.dossier.id} : #{self.liste.last}", + # message: "Dossier nº #{self.dossier.id} : #{self.liste.last}", # dossier: {id: self.dossier.id} # end end diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 02e5dbf4b..18415ebbd 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -34,7 +34,7 @@ class NotificationService when 'champs' attribut when 'submitted' - "Le dossier nº#{@dossier_id} a été déposé." + "Le dossier nº #{@dossier_id} a été déposé." else 'Notification par défaut' end diff --git a/app/views/cgu/index.html.haml b/app/views/cgu/index.html.haml index 5f1448c24..779d6ff83 100644 --- a/app/views/cgu/index.html.haml +++ b/app/views/cgu/index.html.haml @@ -35,7 +35,7 @@ %br/ Code APE 6202A %br/ - Nº TVA : FR 22 424 761 419 + Nº TVA : FR 22 424 761 419 %br/ Siège social : 2 rue Kellermann - 59100 Roubaix - France. %br @@ -61,7 +61,7 @@ Déclaration CNIL %p Le SGMAP a procédé à la déclaration CNIL de TPS. Celle-ci porte le numéro "1986658 v 0" à la date du 30 août 2016. Néanmoins les administrations devront procéder à une déclaration complémentaire auprès de la CNIL si les données du formulaire qu’elles ont produit comportent des données de la nature suivante : %ul - %li Nº de sécurité sociale, + %li Nº de sécurité sociale, %li Infractions, condamnations, mesures de sécurité, %li %a{ :href => "https://www.declaration.cnil.fr/declarations/declaration/donneesSensibles_DN.display.action" } Opinions philosophiques, politiques, religieuses, syndicales, vie sexuelle, données de santé, origine raciale. @@ -77,10 +77,10 @@ Traitement des données à caractère personnel %h4 Données personnelles : %p - En application de la loi nº78-17 Informatique et Libertés du 6 janvier 1978, vous disposez d'un droit d'accès, de rectification, de modification et de suppression concernant les données qui vous concernent. Vous pouvez exercer ce droit à travers la rubrique + En application de la loi nº 78-17 Informatique et Libertés du 6 janvier 1978, vous disposez d'un droit d'accès, de rectification, de modification et de suppression concernant les données qui vous concernent. Vous pouvez exercer ce droit à travers la rubrique %a{ :href => "http://www.faire-simple.gouv.fr/contact" } Contact %h4 Données de connexion : - %p Conformément à la loi nº2004-575 du 21 juin 2004 pour la confiance dans l’économie numérique, certaines données de connexion sont conservées par le service aux fins de protection contre les intrusions et de poursuites judiciaires le cas échéant. Ces données sont conservées pendant un an. + %p Conformément à la loi nº 2004-575 du 21 juin 2004 pour la confiance dans l’économie numérique, certaines données de connexion sont conservées par le service aux fins de protection contre les intrusions et de poursuites judiciaires le cas échéant. Ces données sont conservées pendant un an. %br %h3#entreprise_information diff --git a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml index a4c6a4c8e..d99573c44 100644 --- a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml +++ b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml @@ -39,6 +39,6 @@ - @facade_data_view.dossiers_with_unread_notifications.each do |dossier| = link_to backoffice_dossier_path(dossier.id) do .notification - .dossier-index= "Dossier nº#{dossier.id}" + .dossier-index= "Dossier nº #{dossier.id}" .updated-at-index= dossier.first_unread_notification.created_at.strftime('%d/%m %H:%M') .count= dossier.unreaded_notifications.count diff --git a/app/views/mails/closed_mail.html.haml b/app/views/mails/closed_mail.html.haml index 0fa0287b1..ac3153c9a 100644 --- a/app/views/mails/closed_mail.html.haml +++ b/app/views/mails/closed_mail.html.haml @@ -1,7 +1,7 @@ Bonjour %br %br -Votre dossier nº--numero_dossier-- a été accepté. +Votre dossier nº --numero_dossier-- a été accepté. %br %br A tout moment, vous pouvez consulter le contenu de vos dossiers et les éventuels commentaires de l'administration à cette adresse : --lien_dossier-- diff --git a/app/views/mails/initiated_mail.html.haml b/app/views/mails/initiated_mail.html.haml index e3b5f3ec6..ce3ae6324 100644 --- a/app/views/mails/initiated_mail.html.haml +++ b/app/views/mails/initiated_mail.html.haml @@ -1,7 +1,7 @@ Bonjour %br %br -Votre administration vous confirme la bonne réception de votre dossier nº--numero_dossier--. +Votre administration vous confirme la bonne réception de votre dossier nº --numero_dossier--. %br %br A tout moment, vous pouvez consulter le contenu de vos dossiers et les éventuels commentaires de l'administration à cette adresse : --lien_dossier-- diff --git a/app/views/mails/received_mail.html.haml b/app/views/mails/received_mail.html.haml index 5a17aa07c..113139052 100644 --- a/app/views/mails/received_mail.html.haml +++ b/app/views/mails/received_mail.html.haml @@ -1,7 +1,7 @@ Bonjour %br %br -Votre administration vous confirme la bonne réception de votre dossier nº--numero_dossier--. Celui-ci sera instruit dans le délai légal déclaré par votre interlocuteur. +Votre administration vous confirme la bonne réception de votre dossier nº --numero_dossier--. Celui-ci sera instruit dans le délai légal déclaré par votre interlocuteur. %br %br Bonne journée diff --git a/app/views/mails/refused_mail.html.haml b/app/views/mails/refused_mail.html.haml index d3510d160..900942f26 100644 --- a/app/views/mails/refused_mail.html.haml +++ b/app/views/mails/refused_mail.html.haml @@ -1,7 +1,7 @@ Bonjour %br %br -Votre dossier nº--numero_dossier-- a été refusé. +Votre dossier nº --numero_dossier-- a été refusé. %br %br Pour en savoir plus sur le motif du refus, vous pouvez consulter le contenu de vos dossiers et les éventuels commentaires de l'administration à cette adresse : --lien_dossier-- diff --git a/app/views/mails/without_continuation_mail.html.haml b/app/views/mails/without_continuation_mail.html.haml index 4742dadbe..03ab071cc 100644 --- a/app/views/mails/without_continuation_mail.html.haml +++ b/app/views/mails/without_continuation_mail.html.haml @@ -1,7 +1,7 @@ Bonjour %br %br -Votre dossier nº--numero_dossier-- a été classé sans suite. +Votre dossier nº --numero_dossier-- a été classé sans suite. %br %br Pour en savoir plus sur les raisons de ce classement sans suite, vous pouvez consulter le contenu de vos dossiers et les éventuels commentaires de l'administration à cette adresse : --lien_dossier-- diff --git a/config/locales/dynamics/fr.yml b/config/locales/dynamics/fr.yml index 74931a96b..9846ccec1 100644 --- a/config/locales/dynamics/fr.yml +++ b/config/locales/dynamics/fr.yml @@ -23,7 +23,7 @@ fr: dossiers: depositaite: "Dépositaire" - numéro: 'Dossier nº' + numéro: 'Dossier nº ' followers: title: "Personnes suivant l'activité de ce dossier" empty: "Aucune personne ne suit ce dossier" diff --git a/db/migrate/20160901082824_initiated_all_received_mail_for_procedure.rb b/db/migrate/20160901082824_initiated_all_received_mail_for_procedure.rb index e5bb6db7a..89e5f03cd 100644 --- a/db/migrate/20160901082824_initiated_all_received_mail_for_procedure.rb +++ b/db/migrate/20160901082824_initiated_all_received_mail_for_procedure.rb @@ -11,7 +11,7 @@ class InitiatedAllReceivedMailForProcedure < ActiveRecord::Migration before_save :default_values def default_values - self.object ||= "[TPS] Accusé de réception pour votre dossier nº--numero_dossier--" + self.object ||= "[TPS] Accusé de réception pour votre dossier nº --numero_dossier--" self.body ||= "Bonjour,

    diff --git a/spec/factories/mail_templates.rb b/spec/factories/mail_templates.rb index a3940bca8..2f3a72122 100644 --- a/spec/factories/mail_templates.rb +++ b/spec/factories/mail_templates.rb @@ -13,8 +13,8 @@ FactoryGirl.define do end trait :dossier_received do - object "[TPS] Accusé de réception pour votre dossier nº--numero_dossier--" - body "Votre administration vous confirme la bonne réception de votre dossier nº--numero_dossier--" + object "[TPS] Accusé de réception pour votre dossier nº --numero_dossier--" + body "Votre administration vous confirme la bonne réception de votre dossier nº --numero_dossier--" type 'MailReceived' end end diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb index 8686c5e55..4c8f26fc1 100644 --- a/spec/mailers/notification_mailer_spec.rb +++ b/spec/mailers/notification_mailer_spec.rb @@ -19,6 +19,6 @@ RSpec.describe NotificationMailer, type: :mailer do it { expect(subject.body).to match('Un nouveau message est disponible dans votre espace TPS.') } it { expect(subject.body).to include("Pour le consulter, merci de vous rendre sur #{users_dossier_recapitulatif_url(dossier_id: dossier.id)}") } - it { expect(subject.subject).to eq("Nouveau message pour votre dossier TPS nº#{dossier.id}") } + it { expect(subject.subject).to eq("Nouveau message pour votre dossier TPS nº #{dossier.id}") } end end From 9071656b5514b9444e7cab90ac6b07faef039dfe Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Wed, 5 Apr 2017 10:00:15 +0200 Subject: [PATCH 23/26] Use #each instead of #map where appropriated --- app/controllers/users/carte_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/users/carte_controller.rb b/app/controllers/users/carte_controller.rb index 0b8a328e9..f38f52ab5 100644 --- a/app/controllers/users/carte_controller.rb +++ b/app/controllers/users/carte_controller.rb @@ -15,8 +15,8 @@ class Users::CarteController < UsersController def save dossier = current_user_dossier - dossier.quartier_prioritaires.map(&:destroy) - dossier.cadastres.map(&:destroy) + dossier.quartier_prioritaires.each(&:destroy) + dossier.cadastres.each(&:destroy) unless params[:json_latlngs].blank? ModuleApiCartoService.save_qp! dossier, params[:json_latlngs] From b00eb914da9e13b883875eaa67baab101d758417 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Wed, 5 Apr 2017 10:22:37 +0200 Subject: [PATCH 24/26] Use case statements instead of if statements where appropriated --- app/controllers/users/sessions_controller.rb | 5 +- app/decorators/user_decorator.rb | 8 +- app/models/dossier.rb | 74 ++++++++++--------- app/services/accompagnateur_service.rb | 5 +- .../dossiers/_state_description.html.haml | 13 ++-- .../champs/_render_list_champs.html.haml | 25 ++++--- .../dossiers/_state_description.html.haml | 17 +++-- config/deploy.rb | 5 +- 8 files changed, 82 insertions(+), 70 deletions(-) diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb index fee9dfad2..3e8efd878 100644 --- a/app/controllers/users/sessions_controller.rb +++ b/app/controllers/users/sessions_controller.rb @@ -54,10 +54,11 @@ class Users::SessionsController < Sessions::SessionsController sign_out :user - if connected_with_france_connect == 'entreprise' + case connected_with_france_connect + when 'entreprise' redirect_to FRANCE_CONNECT.entreprise_logout_endpoint return - elsif connected_with_france_connect == 'particulier' + when 'particulier' redirect_to FRANCE_CONNECT.particulier_logout_endpoint return end diff --git a/app/decorators/user_decorator.rb b/app/decorators/user_decorator.rb index d870ccd0a..8f77dc857 100644 --- a/app/decorators/user_decorator.rb +++ b/app/decorators/user_decorator.rb @@ -2,8 +2,12 @@ class UserDecorator < Draper::Decorator delegate_all def gender_fr - return 'M.' if gender == 'male' - return 'Mme' if gender == 'female' + case gender + when 'male' + 'M.' + when 'female' + 'Mme' + end end def birthdate_fr diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 14026026f..731320a5f 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -111,47 +111,49 @@ class Dossier < ActiveRecord::Base fail 'role is not valid' end - if role == 'user' + case role + when 'user' case action - when 'initiate' - if draft? - initiated! - end - when 'update' - if replied? - updated! - end - when 'comment' - if replied? - updated! - end + when 'initiate' + if draft? + initiated! + end + when 'update' + if replied? + updated! + end + when 'comment' + if replied? + updated! + end end - elsif role == 'gestionnaire' + when 'gestionnaire' case action - when 'comment' - if updated? - replied! - elsif initiated? - replied! - end - when 'follow' - if initiated? - updated! - end - when 'close' - if received? - closed! - end - when 'refuse' - if received? - refused! - end - when 'without_continuation' - if received? - without_continuation! - end + when 'comment' + if updated? + replied! + elsif initiated? + replied! + end + when 'follow' + if initiated? + updated! + end + when 'close' + if received? + closed! + end + when 'refuse' + if received? + refused! + end + when 'without_continuation' + if received? + without_continuation! + end end end + state end diff --git a/app/services/accompagnateur_service.rb b/app/services/accompagnateur_service.rb index d526167a0..3c4129e4c 100644 --- a/app/services/accompagnateur_service.rb +++ b/app/services/accompagnateur_service.rb @@ -9,9 +9,10 @@ class AccompagnateurService end def change_assignement! - if @to == ASSIGN + case @to + when ASSIGN AssignTo.create(gestionnaire: @accompagnateur, procedure: @procedure) - elsif @to == NOT_ASSIGN + when NOT_ASSIGN AssignTo.where(gestionnaire: @accompagnateur, procedure: @procedure).delete_all end end diff --git a/app/views/backoffice/dossiers/_state_description.html.haml b/app/views/backoffice/dossiers/_state_description.html.haml index b7d58ceea..345b3fecf 100644 --- a/app/views/backoffice/dossiers/_state_description.html.haml +++ b/app/views/backoffice/dossiers/_state_description.html.haml @@ -5,17 +5,18 @@ .col-md-1.col-lg-1.col-sm-1.col-xs-1.col-sm-1.col-xs-1 .fa.fa-info-circle.text-info{ style: 'font-size: 2em; margin-top: 20%;' } .col-xs-11 - - if dossiers_list_facade.liste == 'nouveaux' + - case dossiers_list_facade.liste + - when 'nouveaux' Tous les dossiers présents dans cette liste sont ceux qui %b n'ont jamais été ouvert par votre service. Il attende une première lecture et intervention de votre part. - - elsif dossiers_list_facade.liste == 'a_traiter' + - when 'a_traiter' Tous les dossiers présents dans cette liste sont ceux qui sont %b en cours de construction avec l'usager. Ils ne sont pas figés et ne sont donc pas complets. - - elsif dossiers_list_facade.liste == 'fige' + - when 'fige' Tous les dossiers présents dans cette liste ont été déclarés %b complets @@ -23,14 +24,14 @@ %b plus modifiables par l'usager. Ils attendent donc leurs dépots officiels qui doit être effectué par l'usager. - - elsif dossiers_list_facade.liste == 'deposes' + - when 'deposes' Tous les dossiers présents dans cette liste ont été %b officiellement déposé par l'usager pour examen. Il faut donc que vous confirmiez par "accusé de réception" la bonne réception de toutes les informations et documents demandés avant examen final. - - elsif dossiers_list_facade.liste == 'a_instruire' + - when 'a_instruire' Tous les dossiers présents dans cette liste sont à instruire. Ceux sont tous les dossiers %b qui ont reçu bonne réception. - - elsif dossiers_list_facade.liste == 'termine' + - when 'termine' Tous les dossiers présents dans cette liste sont considérés comme cloturé car ils ont tous reçu un verdict final qui peut être "Validé", "Refusé" ou "Sans suite". diff --git a/app/views/users/description/champs/_render_list_champs.html.haml b/app/views/users/description/champs/_render_list_champs.html.haml index 0d1f91f76..01c395d33 100644 --- a/app/views/users/description/champs/_render_list_champs.html.haml +++ b/app/views/users/description/champs/_render_list_champs.html.haml @@ -11,40 +11,41 @@ - if champ.mandatory? * - - if champ.type_champ == 'textarea' + - case champ.type_champ + - when 'textarea' = render partial: 'users/description/champs/textarea', locals: { champ: champ } - - elsif champ.type_champ == 'checkbox' + - when 'checkbox' = render partial: 'users/description/champs/checkbox', locals: { champ: champ } - - elsif champ.type_champ == 'civilite' + - when 'civilite' = render partial: 'users/description/champs/civilite', locals: { champ: champ } - - elsif champ.type_champ == 'datetime' + - when 'datetime' = render partial: 'users/description/champs/datetime', locals: { champ: champ } - - elsif champ.type_champ == 'yes_no' + - when 'yes_no' = render partial: 'users/description/champs/yes_no', locals: { champ: champ } - - elsif %w(drop_down_list multiple_drop_down_list).include?(champ.type_champ) + - when 'drop_down_list', 'multiple_drop_down_list' = render partial: 'users/description/champs/drop_down_list', locals: { champ: champ } - - elsif champ.type_champ == 'pays' + - when 'pays' = render partial: 'users/description/champs/pays', locals: { champ: champ } - - elsif champ.type_champ == 'regions' + - when 'regions' = render partial: 'users/description/champs/regions', locals: { champ: champ } - - elsif champ.type_champ == 'engagement' + - when 'engagement' = render partial: 'users/description/champs/engagement', locals: { champ: champ } - - elsif champ.type_champ == 'departements' + - when 'departements' = render partial: 'users/description/champs/departements', locals: { champ: champ } - - elsif champ.type_champ == 'dossier_link' + - when 'dossier_link' = render partial: 'users/description/champs/dossier_link', locals: { champ: champ } - - elsif champ.type_champ == 'explication' + - when 'explication' - else %input.form-control{ name: "champs['#{champ.id}']", diff --git a/app/views/users/dossiers/_state_description.html.haml b/app/views/users/dossiers/_state_description.html.haml index 52d13cab2..27674ad2b 100644 --- a/app/views/users/dossiers/_state_description.html.haml +++ b/app/views/users/dossiers/_state_description.html.haml @@ -5,33 +5,34 @@ .col-md-1.col-lg-1.col-sm-1.col-xs-1 .fa.fa-info-circle.text-info{ style: 'font-size: 2em; margin-top: 20%;' } .col-xs-11 - - if dossiers_list_facade.liste == 'brouillon' + - case dossiers_list_facade.liste + - when 'brouillon' Les dossiers présents dans cette liste %b n'ont pas encore été soumis aux services instructeurs. Ils ne sont visibles que par vous. - - elsif dossiers_list_facade.liste == 'nouveaux' + - when 'nouveaux' Les dossiers présents dans cette liste %b n'ont pas encore été ouverts par les services instructeurs. Une notification vous sera envoyée quand votre demande aura été étudiée. - - elsif dossiers_list_facade.liste == 'a_traiter' + - when 'a_traiter' Les dossiers présents dans cette liste sont %b visibles par les services instructeurs. %br Ces dossiers ne sont pas encore figés et peuvent être modifiés à souhait. - - elsif dossiers_list_facade.liste == 'en_attente' + - when 'en_attente' Les dossiers présents dans cette liste sont %b en cours de relecture par les services instructeurs. Il reviendra vers vous si des informations ou documents sont manquants pour le futur examen de votre dossier. - - elsif dossiers_list_facade.liste == 'valides' + - when 'valides' Les dossiers présents dans cette liste ont été %b relus et considérés comme complets pour examen par les services instructeurs. Ceux-ci ne peuvent maintenant plus être modifiés. Il faut que vous procédiez à leur dépôt afin qu'une décision finale soit rendue. - - elsif dossiers_list_facade.liste == 'en_instruction' + - when 'en_instruction' Les dossiers présents dans cette liste sont %b en cours de réception @@ -39,12 +40,12 @@ %b en cours d'examen par les services instructeurs. Une notification vous sera envoyée une fois qu'une décision aura été rendue. - - elsif dossiers_list_facade.liste == 'termine' + - when 'termine' Les dossiers présents dans cette liste sont ceux qui ont été instruits et pour lesquels %b une décision finale a été rendue. Ils peuvent posséder trois états différents : Accepté, Refusé ou Sans Suite. - - elsif dossiers_list_facade.liste == 'invite' + - when 'invite' Les dossiers présents dans cette liste sont ceux %b auxquels vous avez été invités diff --git a/config/deploy.rb b/config/deploy.rb index 13367378b..eae817ea8 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -24,7 +24,8 @@ set :port, 2200 set :deploy_to, '/var/www/tps_dev' -if ENV["to"] == "staging" +case ENV["to"] +when "staging" if ENV['branch'].nil? set :branch, 'staging' else @@ -33,7 +34,7 @@ if ENV["to"] == "staging" set :deploy_to, '/var/www/tps_dev' set :user, 'tps_dev' # Username in the server to SSH to. appname = 'tps_dev' -elsif ENV["to"] == "production" +when "production" if ENV['branch'].nil? set :branch, 'master' else From 2b969ef575240578b0154b58a57fa679a78716f8 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 30 Mar 2017 16:12:01 +0200 Subject: [PATCH 25/26] MandatoryAttachment: group missing errors logic together and show errors only if not draft --- .../private_formulaires_controller.rb | 3 +- .../users/description_controller.rb | 14 +- app/services/champs_service.rb | 12 +- app/services/pieces_justificatives_service.rb | 2 - spec/services/champs_service_spec.rb | 45 +++--- .../pieces_justificatives_service_spec.rb | 129 ++++++++++-------- 6 files changed, 103 insertions(+), 102 deletions(-) diff --git a/app/controllers/backoffice/private_formulaires_controller.rb b/app/controllers/backoffice/private_formulaires_controller.rb index 3c62ad362..0353b02f3 100644 --- a/app/controllers/backoffice/private_formulaires_controller.rb +++ b/app/controllers/backoffice/private_formulaires_controller.rb @@ -5,7 +5,8 @@ class Backoffice::PrivateFormulairesController < ApplicationController dossier = current_gestionnaire.dossiers.find(params[:dossier_id]) unless params[:champs].nil? - champs_service_errors = ChampsService.save_champs dossier.champs_private, params + ChampsService.save_champs dossier.champs_private, params + champs_service_errors = ChampsService.build_error_messages(dossier.champs_private) if champs_service_errors.empty? flash[:notice] = "Formulaire enregistré" diff --git a/app/controllers/users/description_controller.rb b/app/controllers/users/description_controller.rb index 69e17b4a8..bdd38cce9 100644 --- a/app/controllers/users/description_controller.rb +++ b/app/controllers/users/description_controller.rb @@ -28,13 +28,8 @@ class Users::DescriptionController < UsersController procedure = dossier.procedure return head :forbidden unless dossier.can_be_initiated? - check_mandatory_fields = !draft_submission? - if params[:champs] - champs_service_errors = - ChampsService.save_champs(dossier.champs, params, check_mandatory_fields) - return redirect_to_description_with_errors(dossier, champs_service_errors) if champs_service_errors.any? - end + ChampsService.save_champs(dossier.champs, params) if params[:champs] if procedure.cerfa_flag? && params[:cerfa_pdf] cerfa = Cerfa.new(content: params[:cerfa_pdf], dossier: dossier, user: current_user) @@ -44,6 +39,13 @@ class Users::DescriptionController < UsersController errors_upload = PiecesJustificativesService.upload!(dossier, current_user, params) return redirect_to_description_with_errors(dossier, errors_upload) if errors_upload.any? + if params[:champs] && !draft_submission? + errors = + ChampsService.build_error_messages(dossier.champs) + + PiecesJustificativesService.missing_pj_error_messages(dossier) + return redirect_to_description_with_errors(dossier, errors) if errors.any? + end + if draft_submission? flash.notice = 'Votre brouillon a bien été sauvegardé.' redirect_to url_for(controller: :dossiers, action: :index, liste: :brouillon) diff --git a/app/services/champs_service.rb b/app/services/champs_service.rb index b35ec4d7b..40c46a993 100644 --- a/app/services/champs_service.rb +++ b/app/services/champs_service.rb @@ -1,11 +1,14 @@ class ChampsService class << self - def save_champs(champs, params, check_mandatory = true) + def save_champs(champs, params) fill_champs(champs, params) champs.select(&:changed?).each(&:save) + end - check_mandatory ? build_error_messages(champs) : [] + def build_error_messages(champs) + champs.select(&:mandatory_and_blank?) + .map { |c| "Le champ #{c.libelle} doit être rempli." } end private @@ -28,10 +31,5 @@ class ChampsService def extract_minute(champ_id, h) h[:time_minute]["'#{champ_id}'"] end - - def build_error_messages(champs) - champs.select(&:mandatory_and_blank?) - .map { |c| "Le champ #{c.libelle} doit être rempli." } - end end end diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index 1298897e5..8003e3c92 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -13,8 +13,6 @@ class PiecesJustificativesService errors += without_virus .map { |tpj, content| save_pj(content, dossier, tpj, user) } .compact() - - errors += missing_pj_error_messages(dossier) end def self.upload_one! dossier, user, params diff --git a/spec/services/champs_service_spec.rb b/spec/services/champs_service_spec.rb index ee0047ea2..67f4c04d1 100644 --- a/spec/services/champs_service_spec.rb +++ b/spec/services/champs_service_spec.rb @@ -1,15 +1,15 @@ require 'spec_helper' describe ChampsService do - describe 'save_champs' do - let!(:champ) { Champ.create(value: 'toto', type_de_champ: TypeDeChamp.new) } - let!(:champ_mandatory_empty) { Champ.create(type_de_champ: TypeDeChamp.new(libelle: 'mandatory', mandatory: true)) } - let!(:champ_datetime) do - champ_datetime = TypeDeChamp.new(type_champ: 'datetime') - Champ.create(type_de_champ: champ_datetime) - end - let!(:champs) { [champ, champ_mandatory_empty, champ_datetime] } + let!(:champ) { Champ.create(value: 'toto', type_de_champ: TypeDeChamp.new) } + let!(:champ_mandatory_empty) { Champ.create(type_de_champ: TypeDeChamp.new(libelle: 'mandatory', mandatory: true)) } + let!(:champ_datetime) do + champ_datetime = TypeDeChamp.new(type_champ: 'datetime') + Champ.create(type_de_champ: champ_datetime) + end + let!(:champs) { [champ, champ_mandatory_empty, champ_datetime] } + describe 'save_champs' do before :each do params_hash = { champs: { @@ -19,31 +19,22 @@ describe ChampsService do time_hour: { "'#{champ_datetime.id}'" => '12' }, time_minute: { "'#{champ_datetime.id}'" => '24' } } - @errors = ChampsService.save_champs(champs, params_hash, check_mandatory) + ChampsService.save_champs(champs, params_hash) champs.each(&:reload) end - context 'check_mandatory is true' do - let(:check_mandatory) { true } - it 'saves the changed champ' do - expect(champ.value).to eq('yop') - end - - it 'parses and save the date' do - expect(champ_datetime.value).to eq('d 12:24') - end - - it 'adds error for the missing mandatory champ' do - expect(@errors).to match(['Le champ mandatory doit être rempli.']) - end + it 'saves the changed champ' do + expect(champ.value).to eq('yop') end - context 'check_mandatory is false' do - let(:check_mandatory) { false } + it 'parses and save the date' do + expect(champ_datetime.value).to eq('d 12:24') + end + end - it 'does not add errors' do - expect(@errors).to match([]) - end + describe 'build_error_message' do + it 'adds error for the missing mandatory champ' do + expect(ChampsService.build_error_messages(champs)).to match(['Le champ mandatory doit être rempli.']) end end end diff --git a/spec/services/pieces_justificatives_service_spec.rb b/spec/services/pieces_justificatives_service_spec.rb index d6ac03c87..0e6704515 100644 --- a/spec/services/pieces_justificatives_service_spec.rb +++ b/spec/services/pieces_justificatives_service_spec.rb @@ -8,74 +8,85 @@ describe PiecesJustificativesService do allow(ClamavService).to receive(:safe_file?).and_return(safe_file) end + let(:hash) { {} } + let!(:tpj_not_mandatory) do + TypeDePieceJustificative.create(libelle: 'not mandatory', mandatory: false) + end + let!(:tpj_mandatory) do + TypeDePieceJustificative.create(libelle: 'justificatif', mandatory: true) + end + let(:procedure) { Procedure.create(types_de_piece_justificative: tpjs) } + let(:dossier) { Dossier.create(procedure: procedure) } + let(:errors) { PiecesJustificativesService.upload!(dossier, user, hash) } + let(:tpjs) { [tpj_not_mandatory] } + describe 'self.upload!' do - let(:hash) { {} } - let!(:tpj_not_mandatory) do - TypeDePieceJustificative.create(libelle: 'not mandatory', mandatory: false) - end - let!(:tpj_mandatory) do - TypeDePieceJustificative.create(libelle: 'justificatif', mandatory: true) - end - let(:procedure) { Procedure.create(types_de_piece_justificative: tpjs) } - let(:dossier) { Dossier.create(procedure: procedure) } - let(:errors) { PiecesJustificativesService.upload!(dossier, user, hash) } - - context 'when no piece justificative is required' do - let(:tpjs) { [tpj_not_mandatory] } - - context 'when no params are given' do - it { expect(errors).to eq([]) } - end - - context 'when sometihing wrong with file save' do - let(:hash) do - { - "piece_justificative_#{tpj_not_mandatory.id}" => - double(path: '', original_filename: 'filename') - } - end - - it { expect(errors).to match(["le fichier filename (not mandatory) n'a pas pu être sauvegardé"]) } - end - - context 'when a virus is provided' do - let(:safe_file) { false } - let(:hash) do - { - "piece_justificative_#{tpj_not_mandatory.id}" => - double(path: '', original_filename: 'bad_file') - } - end - - it { expect(errors).to match(['bad_file : virus détecté']) } - end + context 'when no params are given' do + it { expect(errors).to eq([]) } end - context 'when a piece justificative is required' do - let(:tpjs) { [tpj_mandatory] } - - context 'when no params are given' do - it { expect(errors).to match(['La pièce jointe justificatif doit être fournie.']) } + context 'when there is something wrong with file save' do + let(:hash) do + { + "piece_justificative_#{tpj_not_mandatory.id}" => + double(path: '', original_filename: 'filename') + } end - context 'when the piece justificative is provided' do - before :each do - # we are messing around piece_justificative - # because directly doubling carrierwave params seems complicated + it { expect(errors).to match(["le fichier filename (not mandatory) n'a pas pu être sauvegardé"]) } + end - allow(PiecesJustificativesService).to receive(:save_pj).and_return(nil) - piece_justificative_double = double(type_de_piece_justificative: tpj_mandatory) - expect(dossier).to receive(:pieces_justificatives).and_return([piece_justificative_double]) - end + context 'when a virus is provided' do + let(:safe_file) { false } + let(:hash) do + { + "piece_justificative_#{tpj_not_mandatory.id}" => + double(path: '', original_filename: 'bad_file') + } + end - let(:hash) do - { - "piece_justificative_#{tpj_mandatory.id}" => double(path: '') - } - end + it { expect(errors).to match(['bad_file : virus détecté']) } + end - it { expect(errors).to match([]) } + context 'when a regular file is provided' do + let(:content) { double(path: '', original_filename: 'filename') } + let(:hash) do + { + "piece_justificative_#{tpj_not_mandatory.id}" => + content + } + end + + before :each do + expect(PiecesJustificativesService).to receive(:save_pj) + .with(content, dossier, tpj_not_mandatory, user) + .and_return(nil) + end + + it 'is saved' do + expect(errors).to match([]) end end end + + describe 'missing_pj_error_messages' do + let(:errors) { PiecesJustificativesService.missing_pj_error_messages(dossier) } + let(:tpjs) { [tpj_mandatory] } + + context 'when no params are given' do + it { expect(errors).to match(['La pièce jointe justificatif doit être fournie.']) } + end + + context 'when the piece justificative is provided' do + before :each do + # we are messing around piece_justificative + # because directly doubling carrierwave params seems complicated + + piece_justificative_double = double(type_de_piece_justificative: tpj_mandatory) + expect(dossier).to receive(:pieces_justificatives).and_return([piece_justificative_double]) + end + + it { expect(errors).to match([]) } + end + end end From ce4a23ec7ff97495db7fed8edcd90935e459841b Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 30 Mar 2017 16:12:26 +0200 Subject: [PATCH 26/26] MandatoryAttachment: show * near mandatory attachment --- .../_pieces_justificatives.html.haml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/users/description/_pieces_justificatives.html.haml b/app/views/users/description/_pieces_justificatives.html.haml index e3a109ba9..bb6604478 100644 --- a/app/views/users/description/_pieces_justificatives.html.haml +++ b/app/views/users/description/_pieces_justificatives.html.haml @@ -18,24 +18,24 @@ - else %input{ type: 'file', name: 'cerfa_pdf', id: 'cerfa_pdf', accept: PieceJustificative.accept_format, :max_file_size => 6.megabytes } - - dossier.types_de_piece_justificative.order('order_place ASC').each do |type_de_piece_justificative| + - dossier.types_de_piece_justificative.order('order_place ASC').each do |tpj| %tr %th.piece-libelle - = type_de_piece_justificative.libelle + = tpj.mandatory ? tpj.libelle + ' *' : tpj.libelle %td - - unless type_de_piece_justificative.lien_demarche.blank? + - unless tpj.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 + = link_to "Télécharger", tpj.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. + - if tpj.api_entreprise + %span.text-success{ id: "piece_justificative_#{tpj.id}" } Nous l'avons récupéré pour vous. - else - - if dossier.retrieve_last_piece_justificative_by_type(type_de_piece_justificative.id).nil? - = file_field_tag "piece_justificative_#{type_de_piece_justificative.id}", accept: PieceJustificative.accept_format, :max_file_size => 6.megabytes + - if dossier.retrieve_last_piece_justificative_by_type(tpj.id).nil? + = file_field_tag "piece_justificative_#{tpj.id}", accept: PieceJustificative.accept_format, :max_file_size => 6.megabytes - else %span.btn.btn-sm.btn-file.btn-success Modifier - = file_field_tag "piece_justificative_#{type_de_piece_justificative.id}", accept: PieceJustificative.accept_format, :max_file_size => 6.megabytes + = file_field_tag "piece_justificative_#{tpj.id}", accept: PieceJustificative.accept_format, :max_file_size => 6.megabytes