Merge pull request #1732 from betagouv/refuse_pipedrive_deal
Refuse pipedrive deal
This commit is contained in:
commit
7df3e0d05f
8 changed files with 80 additions and 0 deletions
|
@ -23,12 +23,30 @@ module Manager
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def refuse_administrateur
|
||||||
|
PipedriveRefusesDealsJob.perform_later(
|
||||||
|
refuse_administrateur_params[:person_id],
|
||||||
|
PipedriveService::PIPEDRIVE_CAMILLE_ID
|
||||||
|
)
|
||||||
|
|
||||||
|
AdministrationMailer
|
||||||
|
.refuse_admin(refuse_administrateur_params[:email])
|
||||||
|
.deliver_later
|
||||||
|
|
||||||
|
flash.notice = "La demande de #{refuse_administrateur_params[:email]} va être refusée"
|
||||||
|
redirect_to manager_demandes_path
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def create_administrateur_params
|
def create_administrateur_params
|
||||||
params.permit(:email, :person_id, :stage_id)
|
params.permit(:email, :person_id, :stage_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def refuse_administrateur_params
|
||||||
|
params.permit(:email, :person_id)
|
||||||
|
end
|
||||||
|
|
||||||
def pending_demandes
|
def pending_demandes
|
||||||
already_approved_emails = Administrateur
|
already_approved_emails = Administrateur
|
||||||
.where(email: demandes.map { |d| d[:email] })
|
.where(email: demandes.map { |d| d[:email] })
|
||||||
|
|
5
app/jobs/pipedrive_refuses_deals_job.rb
Normal file
5
app/jobs/pipedrive_refuses_deals_job.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class PipedriveRefusesDealsJob < ApplicationJob
|
||||||
|
def perform(person_id, owner_id)
|
||||||
|
PipedriveService.refuse_deals_from_person(person_id, owner_id)
|
||||||
|
end
|
||||||
|
end
|
|
@ -16,6 +16,12 @@ class AdministrationMailer < ApplicationMailer
|
||||||
reply_to: "contact@demarches-simplifiees.fr")
|
reply_to: "contact@demarches-simplifiees.fr")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def refuse_admin(admin_email)
|
||||||
|
mail(to: admin_email,
|
||||||
|
subject: "demarches-simplifiees.fr - Votre demande de compte a été refusée",
|
||||||
|
reply_to: "contact@demarches-simplifiees.fr")
|
||||||
|
end
|
||||||
|
|
||||||
def dubious_procedures(procedures_and_type_de_champs)
|
def dubious_procedures(procedures_and_type_de_champs)
|
||||||
@procedures_and_type_de_champs = procedures_and_type_de_champs
|
@procedures_and_type_de_champs = procedures_and_type_de_champs
|
||||||
mail(to: 'equipe@demarches-simplifiees.fr',
|
mail(to: 'equipe@demarches-simplifiees.fr',
|
||||||
|
|
|
@ -6,12 +6,16 @@ class PipedriveService
|
||||||
|
|
||||||
PIPEDRIVE_ALL_NOT_DELETED_DEALS = 'all_not_deleted'
|
PIPEDRIVE_ALL_NOT_DELETED_DEALS = 'all_not_deleted'
|
||||||
|
|
||||||
|
PIPEDRIVE_LOST_STATUS = "lost"
|
||||||
|
PIPEDRIVE_LOST_REASON = "refusé depuis DS"
|
||||||
|
|
||||||
PIPEDRIVE_ADMIN_CENTRAL_STOCK_STAGE_ID = 35
|
PIPEDRIVE_ADMIN_CENTRAL_STOCK_STAGE_ID = 35
|
||||||
PIPEDRIVE_REGIONS_STOCK_STAGE_ID = 24
|
PIPEDRIVE_REGIONS_STOCK_STAGE_ID = 24
|
||||||
PIPEDRIVE_PREFECTURES_STOCK_STAGE_ID = 20
|
PIPEDRIVE_PREFECTURES_STOCK_STAGE_ID = 20
|
||||||
PIPEDRIVE_DEPARTEMENTS_STOCK_STAGE_ID = 30
|
PIPEDRIVE_DEPARTEMENTS_STOCK_STAGE_ID = 30
|
||||||
PIPEDRIVE_COMMUNES_STOCK_STAGE_ID = 40
|
PIPEDRIVE_COMMUNES_STOCK_STAGE_ID = 40
|
||||||
PIPEDRIVE_ORGANISMES_STOCK_STAGE_ID = 1
|
PIPEDRIVE_ORGANISMES_STOCK_STAGE_ID = 1
|
||||||
|
PIPEDRIVE_ORGANISMES_REFUSES_STOCK_STAGE_ID = 45
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def accept_deals_from_person(person_id, owner_id, stage_id)
|
def accept_deals_from_person(person_id, owner_id, stage_id)
|
||||||
|
@ -20,6 +24,12 @@ class PipedriveService
|
||||||
update_person_owner(person_id, owner_id)
|
update_person_owner(person_id, owner_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def refuse_deals_from_person(person_id, owner_id)
|
||||||
|
waiting_deal_ids = fetch_waiting_deal_ids(person_id)
|
||||||
|
waiting_deal_ids.each { |deal_id| refuse_deal(deal_id, owner_id) }
|
||||||
|
update_person_owner(person_id, owner_id)
|
||||||
|
end
|
||||||
|
|
||||||
def fetch_people_demandes
|
def fetch_people_demandes
|
||||||
params = {
|
params = {
|
||||||
start: 0,
|
start: 0,
|
||||||
|
@ -44,6 +54,19 @@ class PipedriveService
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def refuse_deal(deal_id, owner_id)
|
||||||
|
url = PIPEDRIVE_DEALS_URL + "/#{deal_id}?api_token=#{PIPEDRIVE_TOKEN}"
|
||||||
|
|
||||||
|
params = {
|
||||||
|
user_id: owner_id,
|
||||||
|
stage_id: PIPEDRIVE_ORGANISMES_REFUSES_STOCK_STAGE_ID,
|
||||||
|
status: PIPEDRIVE_LOST_STATUS,
|
||||||
|
lost_reason: PIPEDRIVE_LOST_REASON
|
||||||
|
}
|
||||||
|
|
||||||
|
RestClient.put(url, params.to_json, { content_type: :json })
|
||||||
|
end
|
||||||
|
|
||||||
def fetch_waiting_deal_ids(person_id)
|
def fetch_waiting_deal_ids(person_id)
|
||||||
url = [PIPEDRIVE_PEOPLE_URL, person_id, "deals"].join('/')
|
url = [PIPEDRIVE_PEOPLE_URL, person_id, "deals"].join('/')
|
||||||
|
|
||||||
|
|
17
app/views/administration_mailer/refuse_admin.html.haml
Normal file
17
app/views/administration_mailer/refuse_admin.html.haml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
- content_for(:title, 'Demande de création de compte refusée')
|
||||||
|
|
||||||
|
Bonjour,
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
Les comptes administrateurs sont destinés aux administrations publiques souhaitant mettre en place des démarches dématérialisées avec demarches-simplifiees.fr. Il ne semble pas que ce soit votre cas.
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
Pour les usagers qui souhaitent remplir une démarche, l’entrée dans demarches-simplifiees.fr se fait via un lien fourni par l’administration responsable, sur son propre site web. Ce lien vous permettra de créer un compte et de remplir le formulaire dans la foulée.
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
Si par contre vous rencontrez des problèmes lors de l'utilisation de demarches-simplifiees.fr en tant qu'usager, merci d'expliciter le problème rencontré.
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
Cordialement,
|
||||||
|
%br
|
||||||
|
L'équipe demarches-simplifiees.fr
|
|
@ -48,6 +48,12 @@
|
||||||
<%= submit_tag 'Créer' %>
|
<%= submit_tag 'Créer' %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</td>
|
</td>
|
||||||
|
<td class="cell-data cell-data--string" style="text-align: center;">
|
||||||
|
<%= button_to('Refuser',
|
||||||
|
manager_demandes_refuse_administrateur_path,
|
||||||
|
params: { person_id: demande[:person_id], email: demande[:email] },
|
||||||
|
style: 'background-color: #FFFFFF; color: #293f54; border: 1px solid #dfe0e1') %>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -12,6 +12,7 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
resources :demandes, only: [:index]
|
resources :demandes, only: [:index]
|
||||||
post 'demandes/create_administrateur'
|
post 'demandes/create_administrateur'
|
||||||
|
post 'demandes/refuse_administrateur'
|
||||||
|
|
||||||
authenticate :administration do
|
authenticate :administration do
|
||||||
match "/delayed_job" => DelayedJobWeb, :anchor => false, :via => [:get, :post]
|
match "/delayed_job" => DelayedJobWeb, :anchor => false, :via => [:get, :post]
|
||||||
|
|
|
@ -10,4 +10,8 @@ class AdministrationMailerPreview < ActionMailer::Preview
|
||||||
def invite_admin
|
def invite_admin
|
||||||
AdministrationMailer.invite_admin(Administrateur.last, "12345678")
|
AdministrationMailer.invite_admin(Administrateur.last, "12345678")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def refuse_admin
|
||||||
|
AdministrationMailer.refuse_admin('bad_admin@pipo.com')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue