Merge pull request #1964 from betagouv/fix_1701_do_not_use_pipedrive_form
[fix #1701] Use DS form to enroll admin
This commit is contained in:
commit
311fb0d9e8
9 changed files with 137 additions and 1 deletions
26
app/controllers/demandes_controller.rb
Normal file
26
app/controllers/demandes_controller.rb
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
class DemandesController < ApplicationController
|
||||||
|
layout "new_application"
|
||||||
|
|
||||||
|
def new
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
PipedriveService.add_demande(
|
||||||
|
demande_params[:email],
|
||||||
|
demande_params[:phone],
|
||||||
|
demande_params[:name],
|
||||||
|
demande_params[:poste],
|
||||||
|
demande_params[:source],
|
||||||
|
demande_params[:organization_name],
|
||||||
|
demande_params[:address]
|
||||||
|
)
|
||||||
|
flash.notice = 'Votre demande a bien été enregistrée, nous vous contacterons rapidement.'
|
||||||
|
redirect_to root_path
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def demande_params
|
||||||
|
params.permit(:organization_name, :poste, :name, :email, :phone, :source, :address)
|
||||||
|
end
|
||||||
|
end
|
|
@ -2,6 +2,7 @@ class Pipedrive::API
|
||||||
PIPEDRIVE_ALL_NOT_DELETED_DEALS = 'all_not_deleted'
|
PIPEDRIVE_ALL_NOT_DELETED_DEALS = 'all_not_deleted'
|
||||||
PIPEDRIVE_DEALS_URL = [PIPEDRIVE_API_URL, 'deals'].join("/")
|
PIPEDRIVE_DEALS_URL = [PIPEDRIVE_API_URL, 'deals'].join("/")
|
||||||
PIPEDRIVE_PEOPLE_URL = [PIPEDRIVE_API_URL, 'persons'].join("/")
|
PIPEDRIVE_PEOPLE_URL = [PIPEDRIVE_API_URL, 'persons'].join("/")
|
||||||
|
PIPEDRIVE_ORGANIZATIONS_URL = [PIPEDRIVE_API_URL, 'organizations'].join("/")
|
||||||
|
|
||||||
def self.get_persons_owned_by_user(user_id)
|
def self.get_persons_owned_by_user(user_id)
|
||||||
url = PIPEDRIVE_PEOPLE_URL
|
url = PIPEDRIVE_PEOPLE_URL
|
||||||
|
@ -23,12 +24,24 @@ class Pipedrive::API
|
||||||
self.put(url, params)
|
self.put(url, params)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.post_deal(params)
|
||||||
|
self.post(PIPEDRIVE_DEALS_URL, params)
|
||||||
|
end
|
||||||
|
|
||||||
def self.put_person(person_id, params)
|
def self.put_person(person_id, params)
|
||||||
url = [PIPEDRIVE_PEOPLE_URL, person_id].join("/")
|
url = [PIPEDRIVE_PEOPLE_URL, person_id].join("/")
|
||||||
|
|
||||||
self.put(url, params)
|
self.put(url, params)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.post_person(params)
|
||||||
|
self.post(PIPEDRIVE_PEOPLE_URL, params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.post_organization(params)
|
||||||
|
self.post(PIPEDRIVE_ORGANIZATIONS_URL, params)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def self.get(url, params)
|
def self.get(url, params)
|
||||||
|
@ -47,4 +60,10 @@ class Pipedrive::API
|
||||||
|
|
||||||
RestClient.put(url, params.to_json, { content_type: :json })
|
RestClient.put(url, params.to_json, { content_type: :json })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.post(url, params)
|
||||||
|
url = "#{url}?api_token=#{PIPEDRIVE_TOKEN}"
|
||||||
|
|
||||||
|
RestClient.post(url, params.to_json, { content_type: :json })
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,4 +33,15 @@ class Pipedrive::DealAdapter
|
||||||
|
|
||||||
Pipedrive::API.put_deal(deal_id, params)
|
Pipedrive::API.put_deal(deal_id, params)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.add_deal(organisation_id, person_id, title)
|
||||||
|
params = {
|
||||||
|
org_id: organisation_id,
|
||||||
|
person_id: person_id,
|
||||||
|
title: title,
|
||||||
|
user_id: Pipedrive::PersonAdapter::PIPEDRIVE_ROBOT_ID
|
||||||
|
}
|
||||||
|
|
||||||
|
Pipedrive::API.post_deal(params)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
13
app/lib/pipedrive/organization_adapter.rb
Normal file
13
app/lib/pipedrive/organization_adapter.rb
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
class Pipedrive::OrganizationAdapter
|
||||||
|
def self.add_organization(name, address)
|
||||||
|
params = {
|
||||||
|
name: name,
|
||||||
|
owner_id: Pipedrive::PersonAdapter::PIPEDRIVE_ROBOT_ID,
|
||||||
|
address: address
|
||||||
|
}
|
||||||
|
|
||||||
|
response = Pipedrive::API.post_organization(params)
|
||||||
|
|
||||||
|
JSON.parse(response.body)['data']['id']
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,5 +1,6 @@
|
||||||
class Pipedrive::PersonAdapter
|
class Pipedrive::PersonAdapter
|
||||||
PIPEDRIVE_POSTE_ATTRIBUTE_ID = '33a790746f1713d712fe97bcce9ac1ca6374a4d6'
|
PIPEDRIVE_POSTE_ATTRIBUTE_ID = '33a790746f1713d712fe97bcce9ac1ca6374a4d6'
|
||||||
|
PIPEDRIVE_SOURCE_ATTRIBUTE_ID = '2fa7864f467ffa97721cbcd08df5a3d591b15f50'
|
||||||
PIPEDRIVE_ROBOT_ID = '2748449'
|
PIPEDRIVE_ROBOT_ID = '2748449'
|
||||||
|
|
||||||
def self.get_demandes_from_persons_owned_by_robot
|
def self.get_demandes_from_persons_owned_by_robot
|
||||||
|
@ -19,4 +20,20 @@ class Pipedrive::PersonAdapter
|
||||||
|
|
||||||
Pipedrive::API.put_person(person_id, params)
|
Pipedrive::API.put_person(person_id, params)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.add_person(email, phone, name, organization_id, poste, source)
|
||||||
|
params = {
|
||||||
|
email: email,
|
||||||
|
phone: phone,
|
||||||
|
name: name,
|
||||||
|
org_id: organization_id,
|
||||||
|
owner_id: PIPEDRIVE_ROBOT_ID,
|
||||||
|
"#{PIPEDRIVE_POSTE_ATTRIBUTE_ID}": poste,
|
||||||
|
"#{PIPEDRIVE_SOURCE_ATTRIBUTE_ID}": source
|
||||||
|
}
|
||||||
|
|
||||||
|
response = Pipedrive::API.post_person(params)
|
||||||
|
|
||||||
|
JSON.parse(response.body)['data']['id']
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,4 +14,10 @@ class PipedriveService
|
||||||
def self.get_demandes
|
def self.get_demandes
|
||||||
Pipedrive::PersonAdapter.get_demandes_from_persons_owned_by_robot
|
Pipedrive::PersonAdapter.get_demandes_from_persons_owned_by_robot
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.add_demande(email, phone, name, poste, source, organization_name, address)
|
||||||
|
organization_id = Pipedrive::OrganizationAdapter.add_organization(organization_name, address)
|
||||||
|
person_id = Pipedrive::PersonAdapter.add_person(email, phone, name, organization_id, poste, source)
|
||||||
|
Pipedrive::DealAdapter.add_deal(organization_id, person_id, organization_name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
43
app/views/demandes/new.html.haml
Normal file
43
app/views/demandes/new.html.haml
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
.container
|
||||||
|
%h1 Demande de compte administrateur
|
||||||
|
%p Pour obtenir un compte administrateur sur demarches-simplifiees.fr, veuillez remplir le formulaire ci-dessous et un membre de notre équipe vous contactera très prochainement.
|
||||||
|
%p Tous les champs sont obligatoires.
|
||||||
|
|
||||||
|
= form_tag({ controller: 'demandes', action: 'create' }, class: 'form') do
|
||||||
|
|
||||||
|
= label_tag :organization_name do
|
||||||
|
Quel est le nom de votre organisme ?
|
||||||
|
%span.mandatory *
|
||||||
|
= text_field_tag :organization_name, nil, placeholder: 'service jeunesse et prévention, direction des affaires maritimes', required: true
|
||||||
|
|
||||||
|
= label_tag :poste do
|
||||||
|
Quel est votre poste ?
|
||||||
|
%span.mandatory *
|
||||||
|
= text_field_tag :poste, nil, required: true
|
||||||
|
|
||||||
|
= label_tag :name do
|
||||||
|
Quel est votre prénom et votre nom ?
|
||||||
|
%span.mandatory *
|
||||||
|
= text_field_tag :name, nil, required: true
|
||||||
|
|
||||||
|
= label_tag :email do
|
||||||
|
Quelle est l'adresse email pour laquelle vous souhaitez un compte ?
|
||||||
|
%span.mandatory *
|
||||||
|
= email_field_tag :email, nil, required: true
|
||||||
|
|
||||||
|
= label_tag :phone do
|
||||||
|
Quel est votre numéro de téléphone ?
|
||||||
|
%span.mandatory *
|
||||||
|
= text_field_tag :phone, nil, required: true
|
||||||
|
|
||||||
|
= label_tag :source do
|
||||||
|
Comment avez-vous entendu parlé de demarches-simplifiees.fr ?
|
||||||
|
%span.mandatory *
|
||||||
|
= text_field_tag :source, nil, required: true
|
||||||
|
|
||||||
|
= label_tag :address do
|
||||||
|
Quel est le code postal de votre institution ?
|
||||||
|
%span.mandatory *
|
||||||
|
= text_field_tag :address, nil, required: true
|
||||||
|
|
||||||
|
= submit_tag 'Envoyer', class: 'button', data: { disable_with: "Envoi..." }
|
|
@ -67,7 +67,7 @@
|
||||||
%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
|
%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",
|
= link_to "Demander un compte",
|
||||||
"https://pipedrivewebforms.com/form/c4a5de08b0a1dcc92374e853aa11905a1871869",
|
new_demande_path,
|
||||||
class: "role-panel-button-primary",
|
class: "role-panel-button-primary",
|
||||||
target: "_blank",
|
target: "_blank",
|
||||||
rel: "noopener noreferrer",
|
rel: "noopener noreferrer",
|
||||||
|
|
|
@ -69,6 +69,7 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
resources :stats, only: [:index]
|
resources :stats, only: [:index]
|
||||||
resources :accessibilite, only: [:index]
|
resources :accessibilite, only: [:index]
|
||||||
|
resources :demandes, only: [:new, :create]
|
||||||
|
|
||||||
namespace :france_connect do
|
namespace :france_connect do
|
||||||
get 'particulier' => 'particulier#login'
|
get 'particulier' => 'particulier#login'
|
||||||
|
|
Loading…
Reference in a new issue