diff --git a/app/assets/stylesheets/new_design/landing.scss b/app/assets/stylesheets/new_design/landing.scss index bf02238f0..7cfaa8839 100644 --- a/app/assets/stylesheets/new_design/landing.scss +++ b/app/assets/stylesheets/new_design/landing.scss @@ -159,10 +159,15 @@ $landing-breakpoint: 1040px; } .usagers-panel, -.numbers-panel { +.numbers-panel, +.cta-panel-2 { background-color: $light-grey; } +.more-info { + background-color: #FFFFFF; +} + .numbers { @extend %horizontal-list; justify-content: space-around; @@ -316,6 +321,15 @@ $users-breakpoint: 950px; } } +.role-more-info-image { + text-align: left; + + @media (max-width: $users-breakpoint) { + text-align: center; + margin-bottom: 45px; + } +} + .role-usagers-image { @media (max-width: $users-breakpoint) { text-align: center; @@ -437,3 +451,12 @@ $cta-panel-button-border-size: 2px; text-decoration: underline; } } + +.half { + width: 45%; + float: left; +} + +.first-half { + margin-right: 10%; +} diff --git a/app/controllers/support_controller.rb b/app/controllers/support_controller.rb index 310a62c2e..45f4c074d 100644 --- a/app/controllers/support_controller.rb +++ b/app/controllers/support_controller.rb @@ -5,6 +5,10 @@ class SupportController < ApplicationController setup_context end + def admin + setup_context_admin + end + def create if direct_message? && create_commentaire flash.notice = "Votre message a été envoyé sur la messagerie de votre dossier." @@ -13,12 +17,21 @@ class SupportController < ApplicationController elsif create_conversation flash.notice = "Votre message a été envoyé." - redirect_to root_path(formulaire_contact_general_submitted: true) + if params[:admin] + redirect_to root_path(formulaire_contact_admin_submitted: true) + else + redirect_to root_path(formulaire_contact_general_submitted: true) + end else - setup_context - flash.now.alert = "Une erreur est survenue. Vous pouvez nous contactez à #{helpers.mail_to(CONTACT_EMAIL)}." + flash.now.alert = "Une erreur est survenue. Vous pouvez nous contacter à #{helpers.mail_to(CONTACT_EMAIL)}." - render :index + if params[:admin] + setup_context_admin + render :admin + else + setup_context + render :index + end end end @@ -30,10 +43,16 @@ class SupportController < ApplicationController @options = Helpscout::FormAdapter::OPTIONS end + def setup_context_admin + @tags = tags + @options = Helpscout::FormAdapter::ADMIN_OPTIONS + end + def create_conversation Helpscout::FormAdapter.new( subject: params[:subject], email: email, + phone: params[:phone], text: params[:text], file: params[:file], dossier_id: dossier&.id, diff --git a/app/lib/helpscout/api.rb b/app/lib/helpscout/api.rb index e8930d07d..fa172b8d4 100644 --- a/app/lib/helpscout/api.rb +++ b/app/lib/helpscout/api.rb @@ -3,6 +3,8 @@ class Helpscout::API CONVERSATIONS = 'conversations' TAGS = 'tags' FIELDS = 'fields' + CUSTOMERS = 'customers' + PHONES = 'phones' OAUTH2_TOKEN = 'oauth2/token' def add_tags(conversation_id, tags) @@ -42,6 +44,21 @@ class Helpscout::API call_api(:post, CONVERSATIONS, body) end + def add_phone_number(email, phone) + query = URI.encode("(email:#{email})") + response = call_api(:get, "#{CUSTOMERS}?mailbox=#{mailbox_id}&query=#{query}") + if response.success? + body = parse_response_body(response) + if body[:page][:totalElements] > 0 + customer_id = body[:_embedded][:customers].first[:id] + call_api(:post, "#{CUSTOMERS}/#{customer_id}/#{PHONES}", { + type: "work", + value: phone + }) + end + end + end + private def attachments(file) diff --git a/app/lib/helpscout/form_adapter.rb b/app/lib/helpscout/form_adapter.rb index eb607933d..de777c026 100644 --- a/app/lib/helpscout/form_adapter.rb +++ b/app/lib/helpscout/form_adapter.rb @@ -20,6 +20,18 @@ class Helpscout::FormAdapter [I18n.t(TYPE_AUTRE, scope: [:support]), TYPE_AUTRE] ] + ADMIN_TYPE_RDV = 'admin demande rdv' + ADMIN_TYPE_QUESTION = 'admin question' + ADMIN_TYPE_SOUCIS = 'admin soucis' + ADMIN_TYPE_AUTRE = 'admin autre' + + ADMIN_OPTIONS = [ + [I18n.t(ADMIN_TYPE_QUESTION, scope: [:supportadmin]), ADMIN_TYPE_QUESTION], + [I18n.t(ADMIN_TYPE_RDV, scope: [:supportadmin]), ADMIN_TYPE_RDV], + [I18n.t(ADMIN_TYPE_SOUCIS, scope: [:supportadmin]), ADMIN_TYPE_SOUCIS], + [I18n.t(ADMIN_TYPE_AUTRE, scope: [:supportadmin]), ADMIN_TYPE_AUTRE] + ] + def send_form conversation_id = create_conversation @@ -51,6 +63,11 @@ class Helpscout::FormAdapter params[:file] ) - response.success? ? response.headers['Resource-ID'] : nil + if response.success? + if params[:phone].present? + @api.add_phone_number(params[:email], params[:phone]) + end + response.headers['Resource-ID'] + end end end diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 386849c83..58ff1328d 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -15,7 +15,7 @@ class Dossier < ApplicationRecord has_one :etablissement, dependent: :destroy has_one :individual, dependent: :destroy - has_one :attestation + has_one :attestation, dependent: :destroy has_many :pieces_justificatives, dependent: :destroy has_many :champs, -> { public_only.ordered }, dependent: :destroy @@ -26,7 +26,7 @@ class Dossier < ApplicationRecord has_many :followers_gestionnaires, through: :follows, source: :gestionnaire has_many :avis, dependent: :destroy - has_many :dossier_operation_logs + has_many :dossier_operation_logs, dependent: :destroy belongs_to :procedure belongs_to :user diff --git a/app/uploaders/base_uploader.rb b/app/uploaders/base_uploader.rb index e5067cf57..f3d8d9386 100644 --- a/app/uploaders/base_uploader.rb +++ b/app/uploaders/base_uploader.rb @@ -7,7 +7,7 @@ class BaseUploader < CarrierWave::Uploader::Base def remove! begin super - rescue Fog::Storage::OpenStack::NotFound + rescue Fog::OpenStack::Storage::NotFound end end end diff --git a/app/views/root/administration.html.haml b/app/views/root/administration.html.haml index 238015f70..175ca7301 100644 --- a/app/views/root/administration.html.haml +++ b/app/views/root/administration.html.haml @@ -13,8 +13,8 @@ .hero-wrapper .hero-text %p.hero-tagline - %em.hero-tagline-em Dématérialiser et simplifier - les démarches administratives + %em.hero-tagline-em Dématérialisez et simplifiez + vos démarches administratives .hero-illustration %img{ :src => image_url("landing/hero/dematerialiser.svg"), alt: "" } @@ -26,7 +26,7 @@ %img.role-image{ :src => image_url("landing/roles/administrations.svg"), alt: "" } .role-panel-70 - %h1.role-panel-title Vous êtes une administration et vous souhaitez dématérialiser une démarche papier et réduire vos temps d'instruction ? + %h1.role-panel-title Vous êtes une administration et êtes prête pour dématérialiser ? %p.role-panel-explanation Créez des formulaires en ligne en quelques minutes et instruisez les demandes des usagers sur une plateforme dédiée = link_to "Demander un compte administrateur", @@ -34,12 +34,26 @@ class: "role-panel-button-primary", rel: "noopener noreferrer" - = link_to "Voir la documentation", + .landing-panel.more-info + .container + .role-panel-wrapper.role-administrations-panel + .role-panel-70 + %h1.role-panel-title Vous voulez en savoir plus ? + %p.role-panel-explanation Découvrez notre outil + + = link_to "Contactez-nous", + contact_admin_path, + rel: "noopener noreferrer", + class: "role-panel-button-primary" + + = link_to "Consultez notre documentation", DOC_URL, - target: "_blank", rel: "noopener noreferrer", class: "role-panel-button-secondary" + .role-panel-30.role-more-info-image + %img.role-image{ :src => image_url("landing/roles/usagers.svg"), alt: "" } + .landing-panel.features-panel .container %ul.features @@ -181,6 +195,24 @@ = link_to "http://www.lillemetropole.fr/", target: :blank, rel: "noopener noreferrer" do %img.user-image{ :src => image_url("landing/users/mel.jpg"), alt: "Métropole Européenne de Lille" } + .landing-panel.cta-panel-2 + .container + .half.first-half + %h1.cta-panel-title Vous êtes prêt pour dématérialiser ? + %p.cta-panel-explanation Réduisez vos temps d'instruction de 50 % + = link_to "Demander un compte", + new_demande_path, + class: "cta-panel-button-blue" + + .half + %h1.cta-panel-title Vous voulez en savoir plus ? + %p.cta-panel-explanation Nous vous faisons découvrir l'outil + = link_to "Contactez-nous", + contact_admin_path, + class: "cta-panel-button-blue" + + .clearfix + .landing-panel.cta-panel .container .cta-panel-wrapper @@ -188,19 +220,5 @@ %h1.cta-panel-title Une question, un problème ? %p.cta-panel-explanation Notre équipe est disponible pour vous renseigner et vous aider %div - = contact_link "Contactez-nous", - tags: 'administration', - class: "cta-panel-button-white", - target: "_blank", - rel: "noopener noreferrer" - - .landing-panel - .container - .cta-panel-wrapper - %div - %h1.cta-panel-title Vous êtes prêt pour dématérialiser ? - %p.cta-panel-explanation Réduisez vos temps d'instruction de 50 % - %div - = link_to "Demander un compte administrateur", - new_demande_path, - class: "cta-panel-button-blue" + %a.cta-panel-button-white{ rel: 'noopener noreferrer', href:'/contact-admin' } + Contactez-nous diff --git a/app/views/support/admin.html.haml b/app/views/support/admin.html.haml new file mode 100644 index 000000000..b1fb05145 --- /dev/null +++ b/app/views/support/admin.html.haml @@ -0,0 +1,51 @@ +- content_for(:title, 'Contact') + +#contact-form + .container + %h1.new-h1 Contactez notre équipe + + .description + En tant qu'administration, vous pouvez nous contactez via ce formulaire. Nous vous répondrons dans les plus brefs délais, par email ou par téléphone. + %br + %br + %strong + Attention, ce formulaire est réservée uniquement aux organismes publics. + Il ne concerne ni les particuliers, ni les entreprises, ni les associations (sauf celles reconnues d'utilité publique). Si c'est votre cas, rendez-vous sur notre + = link_to contact_path do + formulaire de contact public + \. + + = form_tag contact_path, method: :post, class: 'form' do |f| + - if !logged_in? + .contact-champ + = label_tag :email do + Adresse email professionnelle + %span.mandatory * + = text_field_tag :email, params[:email], required: true + + .contact-champ + = label_tag :type do + Catégorie + %span.mandatory * + = select_tag :type, options_for_select(@options, params[:type]) + + .contact-champ + = label_tag :phone, 'Numéro de téléphone professionnel (ligne directe)' + = text_field_tag :phone + + .contact-champ + = label_tag :subject do + Sujet + = text_field_tag :subject, params[:subject], required: false + + .contact-champ + = label_tag :text do + Message + %span.mandatory * + = text_area_tag :text, params[:text], rows: 6, required: true + + = hidden_field_tag :tags, @tags&.join(',') + = hidden_field_tag :admin, true + + .send-wrapper + = button_tag 'Envoyer le message', type: :submit, class: 'button send primary' diff --git a/config/environments/development.rb b/config/environments/development.rb index 4dfddc69c..9a178ab8c 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -61,4 +61,9 @@ Rails.application.configure do # Raises error for missing translations # config.action_view.raise_on_missing_translations = true + + # This is useful to run rails in development with :async queue adapter + if ENV['RAILS_QUEUE_ADAPTER'] + config.active_job.queue_adapter = ENV['RAILS_QUEUE_ADAPTER'].to_sym + end end diff --git a/config/locales/fr.yml b/config/locales/fr.yml index d7dd009c0..3a3fccfa7 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -61,6 +61,11 @@ fr: produit: J'ai une idée d'amélioration pour votre site usager perdu: Je ne trouve pas la démarche que je veux faire autre: Autre sujet + supportadmin: + admin demande rdv: Demande de RDV pour une présentation à distance de demarches-simplifiees.fr + admin question: J'ai une question sur demarches-simplifiees.fr + admin soucis: J'ai un problème technique avec demarches-simplifiees.fr + admin autre: Autre sujet number: currency: diff --git a/config/routes.rb b/config/routes.rb index 244e6cd8f..48532b4c2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -137,6 +137,8 @@ Rails.application.routes.draw do get "contact", to: "support#index" post "contact", to: "support#create" + get "contact-admin", to: "support#admin" + post "webhooks/helpscout", to: "webhook#helpscout" match "webhooks/helpscout", to: lambda { |_| [204, {}, nil] }, via: :head diff --git a/lib/tasks/deployment/20181128155650_destroy_orphaned_dossier_operation_logs.rake b/lib/tasks/deployment/20181128155650_destroy_orphaned_dossier_operation_logs.rake new file mode 100644 index 000000000..82aa61b46 --- /dev/null +++ b/lib/tasks/deployment/20181128155650_destroy_orphaned_dossier_operation_logs.rake @@ -0,0 +1,17 @@ +namespace :after_party do + desc 'Deployment task: destroy_orphaned_dossier_operation_logs' + task destroy_orphaned_dossier_operation_logs: :environment do + bar = RakeProgressbar.new(DossierOperationLog.count) + + DossierOperationLog.find_each do |log| + if log.dossier.blank? + log.destroy + end + bar.inc + end + + bar.finished + + AfterParty::TaskRecord.create version: '20181128155650' + end +end diff --git a/spec/lib/helpscout/form_adapter_spec.rb b/spec/lib/helpscout/form_adapter_spec.rb index c6054789b..0b6c56209 100644 --- a/spec/lib/helpscout/form_adapter_spec.rb +++ b/spec/lib/helpscout/form_adapter_spec.rb @@ -66,5 +66,45 @@ describe Helpscout::FormAdapter do .with(conversation_id, nil, nil) end end + + context 'add_phone' do + before do + allow(api).to receive(:create_conversation) + .and_return( + double( + success?: true, + headers: { + 'Resource-ID' => conversation_id + } + ) + ) + + described_class.new(params, api).send_form + end + + let(:params) { + { + email: email, + subject: subject, + text: text, + phone: '0666666666' + } + } + let(:phone) { '0666666666' } + let(:email) { 'paul.chavard@beta.gouv.fr' } + let(:subject) { 'Bonjour' } + let(:text) { "J'ai un problem" } + let(:tags) { ['info demarche'] } + let(:conversation_id) { '123' } + + it 'should call method' do + expect(api).to have_received(:create_conversation) + .with(email, subject, text, nil) + expect(api).to have_received(:add_phone_number) + .with(email, phone) + expect(api).to have_received(:add_custom_fields) + .with(conversation_id, nil, nil) + end + end end end