From 58d5e401305e3128eb96b564f92d6030212e9065 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 15 Feb 2017 15:26:24 +0100 Subject: [PATCH 1/4] Remove duplicate email received --- ...5102943_remove_duplicate_email_received.rb | 11 ++++++++ db/schema.rb | 2 +- .../remove_duplicate_email_received_spec.rb | 25 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170215102943_remove_duplicate_email_received.rb create mode 100644 spec/migrations/remove_duplicate_email_received_spec.rb diff --git a/db/migrate/20170215102943_remove_duplicate_email_received.rb b/db/migrate/20170215102943_remove_duplicate_email_received.rb new file mode 100644 index 000000000..ec37aaf93 --- /dev/null +++ b/db/migrate/20170215102943_remove_duplicate_email_received.rb @@ -0,0 +1,11 @@ +class RemoveDuplicateEmailReceived < ActiveRecord::Migration[5.0] + def change + all_mails = MailReceived.all + groupped = all_mails.group_by { |m| m.procedure_id } + filtered = groupped.reject { |k, v| v.length < 2 } + filtered.each do |k, duplicate_mails| + duplicate_mails.pop + duplicate_mails.each(&:destroy) + end + end +end diff --git a/db/schema.rb b/db/schema.rb index f6a873372..7eee27d55 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: 20170125152856) do +ActiveRecord::Schema.define(version: 20170215102943) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" diff --git a/spec/migrations/remove_duplicate_email_received_spec.rb b/spec/migrations/remove_duplicate_email_received_spec.rb new file mode 100644 index 000000000..9fd83c40a --- /dev/null +++ b/spec/migrations/remove_duplicate_email_received_spec.rb @@ -0,0 +1,25 @@ +load 'spec/spec_helper.rb' +load 'db/migrate/20170215102943_remove_duplicate_email_received.rb' + +describe RemoveDuplicateEmailReceived do + context 'with one procedure and one associated mail_received' do + let!(:procedure) { create(:procedure) } + + it 'keeps the procedure mails' do + RemoveDuplicateEmailReceived.new.change + expect(MailReceived.count).to eq(1) + end + + context 'and another mail_received' do + before :each do + MailReceived.create!(procedure: procedure) + end + + it 'destroys the unecessary maiL_received' do + RemoveDuplicateEmailReceived.new.change + expect(MailReceived.count).to eq(1) + expect(procedure.mail_received).not_to be_nil + end + end + end +end From 8995c6754265c5b6c3f9cdadc50ab0fec0efb6e9 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 15 Feb 2017 15:31:06 +0100 Subject: [PATCH 2/4] Add timestamp to mailtemplate --- ...20170215142944_add_timestamps_to_mail_template.rb | 6 ++++++ db/schema.rb | 12 +++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20170215142944_add_timestamps_to_mail_template.rb diff --git a/db/migrate/20170215142944_add_timestamps_to_mail_template.rb b/db/migrate/20170215142944_add_timestamps_to_mail_template.rb new file mode 100644 index 000000000..bbdb2fd2b --- /dev/null +++ b/db/migrate/20170215142944_add_timestamps_to_mail_template.rb @@ -0,0 +1,6 @@ +class AddTimestampsToMailTemplate < ActiveRecord::Migration[5.0] + def change + add_column :mail_templates, :created_at, :datetime + add_column :mail_templates, :updated_at, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index 7eee27d55..3af9d7709 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: 20170215102943) do +ActiveRecord::Schema.define(version: 20170215142944) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -234,10 +234,12 @@ ActiveRecord::Schema.define(version: 20170215102943) do end create_table "mail_templates", force: :cascade do |t| - t.string "object" - t.text "body" - t.string "type" - t.integer "procedure_id" + t.string "object" + t.text "body" + t.string "type" + t.integer "procedure_id" + t.datetime "created_at" + t.datetime "updated_at" end create_table "module_api_cartos", force: :cascade do |t| From a1240692102177c587a83e305d8e774aa3c5e488 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 15 Feb 2017 15:43:56 +0100 Subject: [PATCH 3/4] Procedure: use after_create to build_default_mails --- app/models/procedure.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 6f43a774e..a70b7bcdd 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -30,7 +30,7 @@ class Procedure < ActiveRecord::Base validates :libelle, presence: true, allow_blank: false, allow_nil: false validates :description, presence: true, allow_blank: false, allow_nil: false - after_save :build_default_mails, if: Proc.new { id_changed? } + after_create :build_default_mails def build_default_mails MailReceived.create(procedure: self) unless mail_received From 9fcc0920e6c752806832164ef735bb7adbb9a91c Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 16 Feb 2017 13:59:32 +0100 Subject: [PATCH 4/4] Css update --- app/assets/stylesheets/carte.scss | 4 -- .../admin/procedures_controller.rb | 2 +- app/views/admin/mail_templates/edit.html.haml | 9 +-- .../admin/procedures/_informations.html.haml | 69 ++++++++++--------- app/views/admin/procedures/edit.html.haml | 6 +- app/views/admin/procedures/show.html.haml | 12 ++-- 6 files changed, 50 insertions(+), 52 deletions(-) diff --git a/app/assets/stylesheets/carte.scss b/app/assets/stylesheets/carte.scss index f1d7d4dbb..486e98b64 100644 --- a/app/assets/stylesheets/carte.scss +++ b/app/assets/stylesheets/carte.scss @@ -3,10 +3,6 @@ // You can use Sass (SCSS) here: http://sass-lang.com/ @import "bootstrap"; -table { - font-size: 13px; -} - #carte_page { #map { @extend .col-md-12; diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb index 2f7f11d1b..e047f9cc1 100644 --- a/app/controllers/admin/procedures_controller.rb +++ b/app/controllers/admin/procedures_controller.rb @@ -81,7 +81,7 @@ class Admin::ProceduresController < AdminController return render 'edit' end - flash.notice = 'Préocédure modifiée' + flash.notice = 'Procédure modifiée' redirect_to edit_admin_procedure_path(id: @procedure.id) end diff --git a/app/views/admin/mail_templates/edit.html.haml b/app/views/admin/mail_templates/edit.html.haml index a5471782a..1017a2012 100644 --- a/app/views/admin/mail_templates/edit.html.haml +++ b/app/views/admin/mail_templates/edit.html.haml @@ -12,7 +12,7 @@ = f.button :submit, 'Mettre à jour', class: "btn-success" .row - .col-md-6 + .col-md-8 %table.table %tr %th @@ -23,8 +23,9 @@ %tr %td.center %b.text-success - \-- - = balise.first - \-- + = raw "--#{balise.first}--" + -# \-- + -# = balise.first + -# \-- %td =balise.second[:description] diff --git a/app/views/admin/procedures/_informations.html.haml b/app/views/admin/procedures/_informations.html.haml index d34f1c07f..0b5e9a2ce 100644 --- a/app/views/admin/procedures/_informations.html.haml +++ b/app/views/admin/procedures/_informations.html.haml @@ -1,6 +1,3 @@ - -%br - -{libelle: 'Libellé*', description: 'Description*', organisation: 'Organisation', direction: 'Direction', lien_site_web: 'Lien site internet', lien_notice: 'Lien notice'}.each do |key, value| .form-group %h4 @@ -23,54 +20,58 @@ Fichier accepté : JPG / JPEG / PNG .col-xs-6 %h4 Drapeau européen - %label - =f.check_box :euro_flag - Afficher le drapeau européen - -%br + .checkbox + %label + =f.check_box :euro_flag + Afficher le drapeau européen .row .col-xs-6 %h4 Cartographie = f.fields_for :module_api_carto, @procedure.module_api_carto do |ff| - %label - =ff.check_box :use_api_carto, {id: :procedure_module_api_carto_use_api_carto} - Utilisation de la cartographie + .checkbox + %label + =ff.check_box :use_api_carto, {id: :procedure_module_api_carto_use_api_carto} + Utilisation de la cartographie %ul#modules_api_carto %li - %label - = ff.check_box :quartiers_prioritaires - Quartiers Prioritaires + .checkbox + %label + = ff.check_box :quartiers_prioritaires + Quartiers Prioritaires %li - %label - = ff.check_box :cadastre - Cadastre + .checkbox + %label + = ff.check_box :cadastre + Cadastre .col-xs-6 - if @procedure.cerfa_flag %h4 Formulaire de demande ou CERFA - %label - =f.check_box :cerfa_flag - Activer l'envoi de formulaire de demande ou CERFA - %br + .checkbox + %label + =f.check_box :cerfa_flag + Activer l'envoi de formulaire de demande ou CERFA =f.text_field :lien_demarche, class: 'form-control', placeholder: 'URL vers le formulaire vierge (facultatif)' -%br .row .col-xs-6 %h4 Particuliers - %div - %label - =f.check_box :for_individual - Cette procédure s'adresse à un public qui - %b - ne possède pas (ou pas encore) de numéro SIRET, - qui doivent donc s'identifier en tant que personne physique. - - %ul#individual_with_siret{style:'margin-top: 8px'} - %li + %ul.list-unstyled + %li + .checkbox %label - =f.check_box :individual_with_siret - Donner la possibilité de renseigner un SIRET au cours de la construction du dossier. + =f.check_box :for_individual + Cette procédure s'adresse à un public qui + %b + ne possède pas (ou pas encore) de numéro SIRET, + qui doit donc s'identifier en tant que personne physique. + + %ul.list-unstyled#individual_with_siret{style:'margin-left: 15px'} + %li + .checkbox + %label + =f.check_box :individual_with_siret + Donner la possibilité de renseigner un SIRET au cours de la construction du dossier. diff --git a/app/views/admin/procedures/edit.html.haml b/app/views/admin/procedures/edit.html.haml index c1a2c7dbe..e8097c911 100644 --- a/app/views/admin/procedures/edit.html.haml +++ b/app/views/admin/procedures/edit.html.haml @@ -2,6 +2,6 @@ #procedure_new.section.section-label = form_for @procedure, url: url_for({controller: 'admin/procedures', action: :update, id: @procedure.id}), multipart: true do |f| = render partial: 'informations', locals: {f: f} - = f.submit 'Editer', class: 'btn btn-success', style: 'float:right' - %br - %br + + .text-right + = f.submit 'Editer', class: 'btn btn-success' diff --git a/app/views/admin/procedures/show.html.haml b/app/views/admin/procedures/show.html.haml index 13bbd5516..1bcceffa9 100644 --- a/app/views/admin/procedures/show.html.haml +++ b/app/views/admin/procedures/show.html.haml @@ -70,18 +70,18 @@ Champs .badge.progress-bar-info = @facade.procedure.types_de_champ.size - - @facade.procedure.types_de_champ.order(:order_place).each do |champ| - = champ.libelle - %br + %ul + - @facade.procedure.types_de_champ.order(:order_place).each do |champ| + %li= champ.libelle .champs_private.col-xs-6.col-md-3 %h4.text-info Champs privés .badge.progress-bar-info = @facade.procedure.types_de_champ_private.size - - @facade.procedure.types_de_champ_private.order(:order_place).each do |champ| - = champ.libelle - %br + %ul + - @facade.procedure.types_de_champ_private.order(:order_place).each do |champ| + %li= champ.libelle .pieces_justificatives.col-xs-6.col-md-3 %h4.text-info