commit
183a680826
8 changed files with 92 additions and 4 deletions
|
@ -1,4 +1,12 @@
|
||||||
module Manager
|
module Manager
|
||||||
class DossiersController < Manager::ApplicationController
|
class DossiersController < Manager::ApplicationController
|
||||||
|
def change_state_to_instruction
|
||||||
|
dossier = Dossier.find(params[:id])
|
||||||
|
dossier.update(state: 'en_instruction', processed_at: nil, motivation: nil)
|
||||||
|
dossier.attestation&.destroy
|
||||||
|
logger.info("Le dossier #{dossier.id} est repassé en instruction par #{current_administration.email}")
|
||||||
|
flash[:notice] = "Le dossier #{dossier.id} est repassé en instruction"
|
||||||
|
redirect_to manager_dossier_path(dossier)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,8 +22,8 @@ class Pipedrive::DealAdapter
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_deals_ids_for_person(person_id)
|
def self.get_deals_ids_for_person(person_id)
|
||||||
Pipedrive::API.get_deals_for_person(person_id)
|
deals = Pipedrive::API.get_deals_for_person(person_id) || []
|
||||||
.map { |datum| datum['id'] }
|
deals.map { |datum| datum['id'] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.update_deal_owner_and_stage(deal_id, owner_id, stage_id)
|
def self.update_deal_owner_and_stage(deal_id, owner_id, stage_id)
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
= render partial: 'dossiers/commentaires/form', locals: { dossier_facade: @facade }
|
= render partial: 'dossiers/commentaires/form', locals: { dossier_facade: @facade }
|
||||||
|
|
||||||
.last-commentaire.clearfix.hidden-print
|
.last-commentaire.clearfix.hidden-print
|
||||||
- if last_comment = dossier_facade.commentaires.first
|
- if last_comment = dossier_facade.commentaires.last
|
||||||
%div
|
%div
|
||||||
DERNIER MESSAGE
|
DERNIER MESSAGE
|
||||||
= render partial: 'dossiers/commentaires/commentaire', object: last_comment
|
= render partial: 'dossiers/commentaires/commentaire', object: last_comment
|
||||||
|
|
|
@ -12,7 +12,7 @@ as defined by the routes in the `admin/` namespace
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
<% Administrate::Namespace.new(namespace).resources.reject { |resource| resource.resource == 'dossiers'}.each do |resource| %>
|
<% Administrate::Namespace.new(namespace).resources.each do |resource| %>
|
||||||
|
|
||||||
<%= link_to(
|
<%= link_to(
|
||||||
display_resource_name(resource),
|
display_resource_name(resource),
|
||||||
|
|
48
app/views/manager/dossiers/show.html.erb
Normal file
48
app/views/manager/dossiers/show.html.erb
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<%#
|
||||||
|
# Show
|
||||||
|
|
||||||
|
This view is the template for the show page.
|
||||||
|
It renders the attributes of a resource,
|
||||||
|
as well as a link to its edit page.
|
||||||
|
|
||||||
|
## Local variables:
|
||||||
|
|
||||||
|
- `page`:
|
||||||
|
An instance of [Administrate::Page::Show][1].
|
||||||
|
Contains methods for accessing the resource to be displayed on the page,
|
||||||
|
as well as helpers for describing how each attribute of the resource
|
||||||
|
should be displayed.
|
||||||
|
|
||||||
|
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Show
|
||||||
|
%>
|
||||||
|
|
||||||
|
<% content_for(:title) { t("administrate.actions.show_resource", name: page.page_title) } %>
|
||||||
|
<% dossier = page.resource %>
|
||||||
|
|
||||||
|
<header class="main-content__header" role="banner">
|
||||||
|
<h1 class="main-content__page-title">
|
||||||
|
<%= content_for(:title) %>
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<% if dossier.termine? %>
|
||||||
|
<%= link_to 'repasser en instruction', change_state_to_instruction_manager_dossier_path(dossier), method: :post, class: 'button' %>
|
||||||
|
<% end %>
|
||||||
|
<div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<section class="main-content__body">
|
||||||
|
<dl>
|
||||||
|
<% page.attributes.each do |attribute| %>
|
||||||
|
<dt class="attribute-label" id="<%= attribute.name %>">
|
||||||
|
<%= t(
|
||||||
|
"helpers.label.#{resource_name}.#{attribute.name}",
|
||||||
|
default: attribute.name.titleize,
|
||||||
|
) %>
|
||||||
|
</dt>
|
||||||
|
|
||||||
|
<dd class="attribute-data attribute-data--<%=attribute.html_class%>"
|
||||||
|
><%= render_field attribute %></dd>
|
||||||
|
<% end %>
|
||||||
|
</dl>
|
||||||
|
</section>
|
|
@ -6,6 +6,10 @@ Rails.application.routes.draw do
|
||||||
post 'whitelist', on: :member
|
post 'whitelist', on: :member
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resources :dossiers, only: [:index, :show] do
|
||||||
|
post 'change_state_to_instruction', on: :member
|
||||||
|
end
|
||||||
|
|
||||||
resources :administrateurs, only: [:index, :show, :new, :create] do
|
resources :administrateurs, only: [:index, :show, :new, :create] do
|
||||||
post 'reinvite', on: :member
|
post 'reinvite', on: :member
|
||||||
put 'enable_feature', on: :member
|
put 'enable_feature', on: :member
|
||||||
|
|
27
spec/lib/pipedrive/deal_adapter_spec.rb
Normal file
27
spec/lib/pipedrive/deal_adapter_spec.rb
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Pipedrive::DealAdapter do
|
||||||
|
let(:url) { PIPEDRIVE_API_URL }
|
||||||
|
let(:status) { 200 }
|
||||||
|
let(:body) { '{}' }
|
||||||
|
|
||||||
|
before do
|
||||||
|
stub_request(:get, url)
|
||||||
|
.to_return(status: status, body: body)
|
||||||
|
end
|
||||||
|
|
||||||
|
describe ".get_deals_ids_for_person" do
|
||||||
|
let(:url) { %r{/persons/1/deals\?*} }
|
||||||
|
subject { Pipedrive::DealAdapter.get_deals_ids_for_person('1') }
|
||||||
|
|
||||||
|
context "with valid data" do
|
||||||
|
let(:body) { '{ "success": true, "data": [ { "id": 34 }, { "id": 35 } ] }' }
|
||||||
|
it { is_expected.to eq [34, 35] }
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when no data are returned" do
|
||||||
|
let(:body) { '{ "success": true, "data": null }' }
|
||||||
|
it { is_expected.to eq [] }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -72,6 +72,7 @@ DatabaseCleaner.strategy = :transaction
|
||||||
TPS::Application.load_tasks
|
TPS::Application.load_tasks
|
||||||
|
|
||||||
SIADETOKEN = :valid_token if !defined? SIADETOKEN
|
SIADETOKEN = :valid_token if !defined? SIADETOKEN
|
||||||
|
PIPEDRIVE_TOKEN = :pipedrive_test_token if !defined? PIPEDRIVE_TOKEN
|
||||||
|
|
||||||
include Warden::Test::Helpers
|
include Warden::Test::Helpers
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue