commit
c31da8bc63
13 changed files with 138 additions and 14 deletions
|
@ -96,6 +96,7 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
if administrateur_signed_in?
|
if administrateur_signed_in?
|
||||||
gon.sendinblue = sendinblue_config
|
gon.sendinblue = sendinblue_config
|
||||||
|
gon.crisp = crisp_config
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -239,6 +240,21 @@ class ApplicationController < ActionController::Base
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def crisp_config
|
||||||
|
crisp = Rails.application.secrets.crisp
|
||||||
|
|
||||||
|
{
|
||||||
|
key: crisp[:client_key],
|
||||||
|
enabled: crisp[:enabled],
|
||||||
|
administrateur: {
|
||||||
|
email: current_administrateur&.email,
|
||||||
|
DS_SIGN_IN_COUNT: current_administrateur&.sign_in_count,
|
||||||
|
DS_CREATED_AT: current_administrateur&.created_at,
|
||||||
|
DS_ID: current_administrateur&.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def current_email
|
def current_email
|
||||||
current_user&.email ||
|
current_user&.email ||
|
||||||
current_gestionnaire&.email ||
|
current_gestionnaire&.email ||
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
import '../shared/track/sendinblue';
|
import '../shared/track/sendinblue';
|
||||||
|
import '../shared/track/crisp';
|
32
app/javascript/shared/track/crisp.js
Normal file
32
app/javascript/shared/track/crisp.js
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
const { key, enabled, administrateur } = gon.crisp || {};
|
||||||
|
|
||||||
|
if (enabled) {
|
||||||
|
window.$crisp = [];
|
||||||
|
window.CRISP_WEBSITE_ID = key;
|
||||||
|
|
||||||
|
const script = document.createElement('script');
|
||||||
|
const firstScript = document.getElementsByTagName('script')[0];
|
||||||
|
script.type = 'text/javascript';
|
||||||
|
script.id = 'crisp-js';
|
||||||
|
script.async = true;
|
||||||
|
script.src = 'https://client.crisp.chat/l.js';
|
||||||
|
firstScript.parentNode.insertBefore(script, firstScript);
|
||||||
|
|
||||||
|
window.$crisp.push(['set', 'user:email', [administrateur.email]]);
|
||||||
|
window.$crisp.push(['set', 'session:segments', [['administrateur']]]);
|
||||||
|
window.$crisp.push([
|
||||||
|
'set',
|
||||||
|
'session:data',
|
||||||
|
[
|
||||||
|
[
|
||||||
|
['DS_ID', administrateur.email],
|
||||||
|
['DS_SIGN_IN_COUNT', administrateur.DS_SIGN_IN_COUNT],
|
||||||
|
[
|
||||||
|
'URL_MANAGER',
|
||||||
|
'https://www.demarches-simplifiees.fr/manager/administrateurs/' +
|
||||||
|
administrateur.DS_ID
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
class Pipedrive::PersonAdapter
|
class Pipedrive::PersonAdapter
|
||||||
PIPEDRIVE_POSTE_ATTRIBUTE_ID = '33a790746f1713d712fe97bcce9ac1ca6374a4d6'
|
PIPEDRIVE_POSTE_ATTRIBUTE_ID = '33a790746f1713d712fe97bcce9ac1ca6374a4d6'
|
||||||
PIPEDRIVE_SOURCE_ATTRIBUTE_ID = '2fa7864f467ffa97721cbcd08df5a3d591b15f50'
|
PIPEDRIVE_SOURCE_ATTRIBUTE_ID = '2fa7864f467ffa97721cbcd08df5a3d591b15f50'
|
||||||
|
PIPEDRIVE_NB_DOSSIERS_ATTRIBUTE_ID = '2734a3ff19f4b88bd0d7b4cf02c47c7545617207'
|
||||||
|
PIPEDRIVE_DEADLINE_ATTRIBUTE_ID = 'ef766dd14de7da246fb5fc1704f45d1f1830f6c9'
|
||||||
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
|
||||||
|
@ -11,7 +13,9 @@ class Pipedrive::PersonAdapter
|
||||||
poste: datum[PIPEDRIVE_POSTE_ATTRIBUTE_ID],
|
poste: datum[PIPEDRIVE_POSTE_ATTRIBUTE_ID],
|
||||||
email: datum.dig('email', 0, 'value'),
|
email: datum.dig('email', 0, 'value'),
|
||||||
tel: datum.dig('phone', 0, 'value'),
|
tel: datum.dig('phone', 0, 'value'),
|
||||||
organisation: datum['org_name']
|
organisation: datum['org_name'],
|
||||||
|
nb_dossiers: datum[PIPEDRIVE_NB_DOSSIERS_ATTRIBUTE_ID],
|
||||||
|
deadline: datum[PIPEDRIVE_DEADLINE_ATTRIBUTE_ID]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -22,7 +26,7 @@ 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)
|
def self.add_person(email, phone, name, organization_id, poste, source, nb_of_dossiers, deadline)
|
||||||
params = {
|
params = {
|
||||||
email: email,
|
email: email,
|
||||||
phone: phone,
|
phone: phone,
|
||||||
|
@ -30,7 +34,9 @@ class Pipedrive::PersonAdapter
|
||||||
org_id: organization_id,
|
org_id: organization_id,
|
||||||
owner_id: PIPEDRIVE_ROBOT_ID,
|
owner_id: PIPEDRIVE_ROBOT_ID,
|
||||||
"#{PIPEDRIVE_POSTE_ATTRIBUTE_ID}": poste,
|
"#{PIPEDRIVE_POSTE_ATTRIBUTE_ID}": poste,
|
||||||
"#{PIPEDRIVE_SOURCE_ATTRIBUTE_ID}": source
|
"#{PIPEDRIVE_SOURCE_ATTRIBUTE_ID}": source,
|
||||||
|
"#{PIPEDRIVE_NB_DOSSIERS_ATTRIBUTE_ID}": nb_of_dossiers,
|
||||||
|
"#{PIPEDRIVE_DEADLINE_ATTRIBUTE_ID}": deadline
|
||||||
}
|
}
|
||||||
|
|
||||||
response = Pipedrive::API.post_person(params)
|
response = Pipedrive::API.post_person(params)
|
||||||
|
|
|
@ -19,7 +19,7 @@ class PipedriveService
|
||||||
|
|
||||||
def self.add_demande(email, phone, name, poste, source, organization_name, address, nb_of_procedures, nb_of_dossiers, deadline)
|
def self.add_demande(email, phone, name, poste, source, organization_name, address, nb_of_procedures, nb_of_dossiers, deadline)
|
||||||
organization_id = Pipedrive::OrganizationAdapter.add_organization(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)
|
person_id = Pipedrive::PersonAdapter.add_person(email, phone, name, organization_id, poste, source, nb_of_dossiers, deadline)
|
||||||
Pipedrive::DealAdapter.add_deal(organization_id, person_id, organization_name, nb_of_procedures, nb_of_dossiers, deadline)
|
Pipedrive::DealAdapter.add_deal(organization_id, person_id, organization_name, nb_of_procedures, nb_of_dossiers, deadline)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
= favicon_link_tag(image_url("favicons/32x32.png"), type: "image/png", sizes: "32x32")
|
= 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")
|
= favicon_link_tag(image_url("favicons/96x96.png"), type: "image/png", sizes: "96x96")
|
||||||
|
|
||||||
- packs = ['application', 'track', administrateur_signed_in? ? 'sendinblue' : nil].compact
|
- packs = ['application', 'track', administrateur_signed_in? ? 'track-admin' : nil].compact
|
||||||
= javascript_packs_with_chunks_tag *packs, defer: true, 'data-turbolinks-track': 'reload'
|
= javascript_packs_with_chunks_tag *packs, defer: true, 'data-turbolinks-track': 'reload'
|
||||||
= stylesheet_link_tag 'new_design/new_application', media: 'all', 'data-turbolinks-track': 'reload'
|
= stylesheet_link_tag 'new_design/new_application', media: 'all', 'data-turbolinks-track': 'reload'
|
||||||
= stylesheet_link_tag 'new_design/print', media: 'print', 'data-turbolinks-track': 'reload'
|
= stylesheet_link_tag 'new_design/print', media: 'print', 'data-turbolinks-track': 'reload'
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': "reload"
|
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': "reload"
|
||||||
= stylesheet_link_tag 'print', media: 'print', 'data-turbolinks-track': "reload"
|
= stylesheet_link_tag 'print', media: 'print', 'data-turbolinks-track': "reload"
|
||||||
- packs = ['application-old', 'track', administrateur_signed_in? ? 'sendinblue' : nil].compact
|
- packs = ['application-old', 'track', administrateur_signed_in? ? 'track-admin' : nil].compact
|
||||||
= javascript_packs_with_chunks_tag *packs, defer: true, 'data-turbolinks-track': 'reload'
|
= javascript_packs_with_chunks_tag *packs, defer: true, 'data-turbolinks-track': 'reload'
|
||||||
= javascript_include_tag 'application', defer: true, 'data-turbolinks-track': 'reload'
|
= javascript_include_tag 'application', defer: true, 'data-turbolinks-track': 'reload'
|
||||||
= csrf_meta_tags
|
= csrf_meta_tags
|
||||||
|
|
|
@ -34,13 +34,7 @@
|
||||||
<%= form_tag(manager_demandes_create_administrateur_path) do -%>
|
<%= form_tag(manager_demandes_create_administrateur_path) do -%>
|
||||||
<%= select_tag "stage_id",
|
<%= select_tag "stage_id",
|
||||||
options_for_select({
|
options_for_select({
|
||||||
"suspect" => Pipedrive::DealAdapter::PIPEDRIVE_SUSPECTS_COMPTE_CREE_STAGE_ID,
|
"suspect" => Pipedrive::DealAdapter::PIPEDRIVE_SUSPECTS_COMPTE_CREE_STAGE_ID
|
||||||
"administration centrale" => Pipedrive::DealAdapter::PIPEDRIVE_ADMIN_CENTRAL_STOCK_STAGE_ID,
|
|
||||||
"service déco. régional" => Pipedrive::DealAdapter::PIPEDRIVE_SERVICE_DECO_REGIONAL_STOCK_STAGE_ID,
|
|
||||||
"service déco. départemental" => Pipedrive::DealAdapter::PIPEDRIVE_SERVICE_DECO_DEPARTEMENTAL_STOCK_STAGE_ID,
|
|
||||||
"collectivité dép. ou rég." =>Pipedrive::DealAdapter::PIPEDRIVE_COLLECTIVITE_DEP_OU_REG_STOCK_STAGE_ID,
|
|
||||||
"collectivité locale" => Pipedrive::DealAdapter::PIPEDRIVE_COLLECTIVITE_LOCALE_STOCK_STAGE_ID,
|
|
||||||
"organisme" => Pipedrive::DealAdapter::PIPEDRIVE_ORGANISMES_STOCK_STAGE_ID
|
|
||||||
|
|
||||||
}),
|
}),
|
||||||
style: 'margin-bottom: 20px; width: inherit;' %>
|
style: 'margin-bottom: 20px; width: inherit;' %>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
= form.hidden_field :_destroy, disabled: true
|
= form.hidden_field :_destroy, disabled: true
|
||||||
.flex.row-reverse
|
.flex.row-reverse
|
||||||
- if champ.persisted?
|
- if champ.persisted?
|
||||||
%button.button.danger.remove-row
|
%button.button.danger.remove-row{ type: :button }
|
||||||
Supprimer
|
Supprimer
|
||||||
- else
|
- else
|
||||||
%button.button.danger{ type: :button }
|
%button.button.danger{ type: :button }
|
||||||
|
|
|
@ -46,6 +46,9 @@ MATOMO_ENABLED="disabled"
|
||||||
MATOMO_ID="73"
|
MATOMO_ID="73"
|
||||||
|
|
||||||
SENDINBLUE_ENABLED="disabled"
|
SENDINBLUE_ENABLED="disabled"
|
||||||
|
SENDINBLUE_CLIENT_KEY=""
|
||||||
|
CRISP_ENABLED="disabled"
|
||||||
|
CRISP_CLIENT_KEY=""
|
||||||
|
|
||||||
MAILTRAP_ENABLED="disabled"
|
MAILTRAP_ENABLED="disabled"
|
||||||
MAILTRAP_USERNAME=""
|
MAILTRAP_USERNAME=""
|
||||||
|
|
|
@ -61,6 +61,11 @@ defaults: &defaults
|
||||||
enabled: <%= ENV['SENTRY_ENABLED'] == 'enabled' %>
|
enabled: <%= ENV['SENTRY_ENABLED'] == 'enabled' %>
|
||||||
client_key: <%= ENV['SENTRY_DSN_JS'] %>
|
client_key: <%= ENV['SENTRY_DSN_JS'] %>
|
||||||
environment: <%= ENV['SENTRY_CURRENT_ENV'] %>
|
environment: <%= ENV['SENTRY_CURRENT_ENV'] %>
|
||||||
|
crisp:
|
||||||
|
enabled: <%= ENV['CRISP_ENABLED'] == 'enabled' %>
|
||||||
|
client_key: <%= ENV['CRISP_CLIENT_KEY'] %>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
development:
|
development:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
require Rails.root.join("lib", "tasks", "task_helper")
|
||||||
|
|
||||||
|
namespace :fix_timestamps_of_migrated_dossiers do
|
||||||
|
desc 'Fix the timestamps of dossiers affected by the faulty PJ migration'
|
||||||
|
task run: :environment do
|
||||||
|
affected_time_range = Time.utc(2019, 6, 4, 8, 0)..Time.utc(2019, 6, 4, 18, 0)
|
||||||
|
dossiers = Dossier.unscoped.where(procedure_id: 0..1000).where(updated_at: affected_time_range)
|
||||||
|
|
||||||
|
progress = ProgressReport.new(dossiers.count)
|
||||||
|
|
||||||
|
dossiers.find_each do |dossier|
|
||||||
|
fixed_updated_at = dossier.processed_at || dossier.en_instruction_at || dossier.en_construction_at || dossier.champs.last.updated_at || nil
|
||||||
|
dossier.update_column(:updated_at, fixed_updated_at)
|
||||||
|
|
||||||
|
progress.inc
|
||||||
|
end
|
||||||
|
progress.finish
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,48 @@
|
||||||
|
describe '2019_06_06_fix_timestamps_of_migrated_dossiers' do
|
||||||
|
let(:affected_procedure) { create(:simple_procedure, id: 500) }
|
||||||
|
let(:procedure_outside_range) { create(:simple_procedure, id: 5000) }
|
||||||
|
|
||||||
|
let(:affected_dossier) { create(:dossier, procedure: affected_procedure) }
|
||||||
|
let(:dossier_outside_time_range) { create(:dossier, procedure: affected_procedure) }
|
||||||
|
let(:dossier_outside_procedure_range) { create(:dossier, procedure: procedure_outside_range) }
|
||||||
|
|
||||||
|
let(:creation_time) { Time.utc(2017, 1, 1, 12, 0) }
|
||||||
|
let(:en_construction_time) { Time.utc(2018, 1, 1, 12, 0) }
|
||||||
|
let(:pj_migration_time) { Time.utc(2019, 6, 4, 12, 0) }
|
||||||
|
|
||||||
|
let(:rake_task) { Rake::Task['fix_timestamps_of_migrated_dossiers:run'] }
|
||||||
|
|
||||||
|
before do
|
||||||
|
Timecop.freeze(creation_time) do
|
||||||
|
affected_dossier
|
||||||
|
dossier_outside_time_range
|
||||||
|
dossier_outside_procedure_range
|
||||||
|
end
|
||||||
|
Timecop.freeze(en_construction_time) do
|
||||||
|
affected_dossier.update_column(:en_construction_at, Time.zone.now)
|
||||||
|
end
|
||||||
|
Timecop.freeze(pj_migration_time.prev_week) do
|
||||||
|
dossier_outside_time_range.tap(&:touch).reload
|
||||||
|
end
|
||||||
|
Timecop.freeze(pj_migration_time) do
|
||||||
|
dossier_outside_procedure_range.tap(&:touch).reload
|
||||||
|
affected_dossier.tap(&:touch).reload
|
||||||
|
end
|
||||||
|
|
||||||
|
rake_task.invoke
|
||||||
|
end
|
||||||
|
|
||||||
|
after { rake_task.reenable }
|
||||||
|
|
||||||
|
it 'fix the updated_at of affected dossiers' do
|
||||||
|
expect(affected_dossier.reload.updated_at).to eq(en_construction_time)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'ignores dossiers with a procedure_id outside of the procedure range' do
|
||||||
|
expect(dossier_outside_procedure_range.reload.updated_at).to eq(pj_migration_time)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'ignores dossiers with an updated_at outside of the time range' do
|
||||||
|
expect(dossier_outside_time_range.reload.updated_at).to eq(pj_migration_time.prev_week)
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue