Merge branch 'dev'
This commit is contained in:
commit
8e080a2695
15 changed files with 125 additions and 92 deletions
2
Gemfile
2
Gemfile
|
@ -17,8 +17,6 @@ gem 'therubyracer', platforms: :ruby
|
|||
gem 'jquery-rails'
|
||||
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
|
||||
gem 'turbolinks'
|
||||
# bundle exec rake doc:rails generates the API under doc/api.
|
||||
gem 'sdoc', '~> 0.4.0', group: :doc
|
||||
|
||||
# Enable deep clone of active record models
|
||||
gem 'deep_cloneable'
|
||||
|
|
48
Gemfile.lock
48
Gemfile.lock
|
@ -82,7 +82,7 @@ GEM
|
|||
tzinfo (~> 1.1)
|
||||
addressable (2.5.2)
|
||||
public_suffix (>= 2.0.2, < 4.0)
|
||||
administrate (0.8.1)
|
||||
administrate (0.9.0)
|
||||
actionpack (>= 4.2, < 5.2)
|
||||
actionview (>= 4.2, < 5.2)
|
||||
activerecord (>= 4.2, < 5.2)
|
||||
|
@ -98,14 +98,14 @@ GEM
|
|||
arel (9.0.0)
|
||||
ast (2.4.0)
|
||||
attr_required (1.0.1)
|
||||
autoprefixer-rails (7.2.5)
|
||||
autoprefixer-rails (8.0.0)
|
||||
execjs
|
||||
axlsx (2.0.1)
|
||||
htmlentities (~> 4.3.1)
|
||||
nokogiri (>= 1.4.1)
|
||||
rubyzip (~> 1.0.0)
|
||||
bcrypt (3.1.11)
|
||||
bindata (2.4.1)
|
||||
bindata (2.4.2)
|
||||
bindex (0.5.0)
|
||||
bootstrap-sass (3.3.7)
|
||||
autoprefixer-rails (>= 5.2.1)
|
||||
|
@ -195,7 +195,7 @@ GEM
|
|||
http_parser.rb (~> 0.6.0)
|
||||
erubi (1.7.0)
|
||||
erubis (2.7.0)
|
||||
eventmachine (1.2.1)
|
||||
eventmachine (1.2.5)
|
||||
excon (0.60.0)
|
||||
execjs (2.7.0)
|
||||
factory_bot (4.8.2)
|
||||
|
@ -205,7 +205,7 @@ GEM
|
|||
ffi (1.9.18)
|
||||
fission (0.5.0)
|
||||
CFPropertyList (~> 2.2)
|
||||
fog (1.41.0)
|
||||
fog (1.42.0)
|
||||
fog-aliyun (>= 0.1.0)
|
||||
fog-atmos
|
||||
fog-aws (>= 0.6.0)
|
||||
|
@ -222,6 +222,7 @@ GEM
|
|||
fog-json
|
||||
fog-local
|
||||
fog-openstack
|
||||
fog-ovirt
|
||||
fog-powerdns (>= 0.1.1)
|
||||
fog-profitbricks
|
||||
fog-rackspace
|
||||
|
@ -238,7 +239,7 @@ GEM
|
|||
fog-xenserver
|
||||
fog-xml (~> 0.1.1)
|
||||
ipaddress (~> 0.5)
|
||||
json (>= 1.8, < 2.0)
|
||||
json (~> 2.0)
|
||||
fog-aliyun (0.2.0)
|
||||
fog-core (~> 1.27)
|
||||
fog-json (~> 1.0)
|
||||
|
@ -300,6 +301,11 @@ GEM
|
|||
fog-core (~> 1.40)
|
||||
fog-json (>= 1.0)
|
||||
ipaddress (>= 0.8)
|
||||
fog-ovirt (0.1.3)
|
||||
fog-core (~> 1.45)
|
||||
fog-json
|
||||
fog-xml (~> 0.1.1)
|
||||
rbovirt (~> 0.1.5)
|
||||
fog-powerdns (0.1.1)
|
||||
fog-core (~> 1.27)
|
||||
fog-json (~> 1.0)
|
||||
|
@ -411,7 +417,7 @@ GEM
|
|||
rails-dom-testing (>= 1, < 3)
|
||||
railties (>= 4.2.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
json (1.8.6)
|
||||
json (2.1.0)
|
||||
json-jwt (1.8.3)
|
||||
activesupport
|
||||
bindata
|
||||
|
@ -431,7 +437,7 @@ GEM
|
|||
activerecord
|
||||
kaminari-core (= 1.1.1)
|
||||
kaminari-core (1.1.1)
|
||||
kgio (2.11.1)
|
||||
kgio (2.11.2)
|
||||
launchy (2.4.3)
|
||||
addressable (~> 2.3)
|
||||
leaflet-draw-rails (0.1.0)
|
||||
|
@ -499,7 +505,7 @@ GEM
|
|||
oauth2 (~> 1.1)
|
||||
omniauth (~> 1.2)
|
||||
open4 (1.3.4)
|
||||
openid_connect (1.1.3)
|
||||
openid_connect (1.1.4)
|
||||
activemodel
|
||||
attr_required (>= 1.0.0)
|
||||
json (>= 1.4.3)
|
||||
|
@ -537,12 +543,12 @@ GEM
|
|||
rack
|
||||
rack-mini-profiler (0.10.7)
|
||||
rack (>= 1.2.0)
|
||||
rack-oauth2 (1.7.0)
|
||||
activesupport (>= 2.3)
|
||||
attr_required (>= 0.0.5)
|
||||
httpclient (>= 2.4)
|
||||
multi_json (>= 1.3.6)
|
||||
rack (>= 1.1)
|
||||
rack-oauth2 (1.8.2)
|
||||
activesupport
|
||||
attr_required
|
||||
httpclient
|
||||
json-jwt
|
||||
rack
|
||||
rack-protection (2.0.1)
|
||||
rack
|
||||
rack-test (0.8.2)
|
||||
|
@ -581,12 +587,14 @@ GEM
|
|||
rb-fsevent (0.10.2)
|
||||
rb-inotify (0.9.10)
|
||||
ffi (>= 0.5.0, < 2)
|
||||
rbovirt (0.1.5)
|
||||
nokogiri
|
||||
rest-client (> 1.7.0)
|
||||
rbvmomi (1.11.6)
|
||||
builder (~> 3.0)
|
||||
json (>= 1.8)
|
||||
nokogiri (~> 1.5)
|
||||
trollop (~> 2.1)
|
||||
rdoc (4.3.0)
|
||||
ref (2.0.0)
|
||||
request_store (1.4.0)
|
||||
rack (>= 1.4)
|
||||
|
@ -660,9 +668,6 @@ GEM
|
|||
scss_lint (0.56.0)
|
||||
rake (>= 0.9, < 13)
|
||||
sass (~> 3.5.3)
|
||||
sdoc (0.4.2)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
rdoc (~> 4.0)
|
||||
securecompare (1.0.0)
|
||||
select2-rails (4.0.3)
|
||||
thor (~> 0.14)
|
||||
|
@ -672,7 +677,7 @@ GEM
|
|||
rubyzip (~> 1.0)
|
||||
sentry-raven (2.7.2)
|
||||
faraday (>= 0.7.6, < 1.0)
|
||||
sexp_processor (4.10.0)
|
||||
sexp_processor (4.10.1)
|
||||
shellany (0.0.1)
|
||||
shoulda-matchers (3.1.2)
|
||||
activesupport (>= 4.0.0)
|
||||
|
@ -724,7 +729,7 @@ GEM
|
|||
execjs (>= 0.3.0, < 3)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.7.4)
|
||||
unf_ext (0.0.7.5)
|
||||
unicode-display_width (1.3.0)
|
||||
unicode_utils (1.4.0)
|
||||
unicorn (5.4.0)
|
||||
|
@ -830,7 +835,6 @@ DEPENDENCIES
|
|||
sass-rails
|
||||
scenic
|
||||
scss_lint
|
||||
sdoc (~> 0.4.0)
|
||||
select2-rails
|
||||
sentry-raven
|
||||
shoulda-matchers
|
||||
|
|
|
@ -4,6 +4,9 @@ class Admin::AccompagnateursController < AdminController
|
|||
|
||||
before_action :retrieve_procedure
|
||||
|
||||
ASSIGN = 'assign'
|
||||
NOT_ASSIGN = 'not_assign'
|
||||
|
||||
def show
|
||||
assign_scope = @procedure.gestionnaires
|
||||
|
||||
|
@ -46,11 +49,21 @@ class Admin::AccompagnateursController < AdminController
|
|||
procedure = Procedure.find(params[:procedure_id])
|
||||
to = params[:to]
|
||||
|
||||
accompagnateur_service = AccompagnateurService.new gestionnaire, procedure, to
|
||||
case to
|
||||
when ASSIGN
|
||||
if gestionnaire.assign_to_procedure(procedure)
|
||||
flash.notice = "L'accompagnateur a bien été affecté"
|
||||
else
|
||||
flash.alert = "L'accompagnateur a déjà été affecté"
|
||||
end
|
||||
when NOT_ASSIGN
|
||||
if gestionnaire.remove_from_procedure(procedure)
|
||||
flash.notice = "L'accompagnateur a bien été désaffecté"
|
||||
else
|
||||
flash.alert = "L'accompagnateur a déjà été désaffecté"
|
||||
end
|
||||
end
|
||||
|
||||
accompagnateur_service.change_assignement!
|
||||
|
||||
flash.notice = "Assignement effectué"
|
||||
redirect_to admin_procedure_accompagnateurs_path, procedure_id: params[:procedure_id]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ module NewGestionnaire
|
|||
ITEMS_PER_PAGE = 25
|
||||
|
||||
def index
|
||||
@procedures = current_gestionnaire.procedures.order(archived_at: :desc, published_at: :desc)
|
||||
@procedures = current_gestionnaire.visible_procedures.order(archived_at: :desc, published_at: :desc)
|
||||
|
||||
dossiers = current_gestionnaire.dossiers
|
||||
@dossiers_count_per_procedure = dossiers.all_state.group(:procedure_id).reorder(nil).count
|
||||
|
@ -202,7 +202,7 @@ module NewGestionnaire
|
|||
end
|
||||
|
||||
def redirect_to_avis_if_needed
|
||||
if current_gestionnaire.procedures.count == 0 && current_gestionnaire.avis.count > 0
|
||||
if current_gestionnaire.visible_procedures.count == 0 && current_gestionnaire.avis.count > 0
|
||||
redirect_to gestionnaire_avis_index_path
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ class Gestionnaire < ActiveRecord::Base
|
|||
has_and_belongs_to_many :administrateurs
|
||||
|
||||
has_many :assign_to, dependent: :destroy
|
||||
has_many :procedures, -> { publiees_ou_archivees }, through: :assign_to
|
||||
has_many :procedures, through: :assign_to
|
||||
has_many :dossiers, -> { state_not_brouillon }, through: :procedures
|
||||
has_many :follows
|
||||
has_many :followed_dossiers, through: :follows, source: :dossier
|
||||
|
@ -14,6 +14,10 @@ class Gestionnaire < ActiveRecord::Base
|
|||
|
||||
include CredentialsSyncableConcern
|
||||
|
||||
def visible_procedures
|
||||
procedures.publiees_ou_archivees
|
||||
end
|
||||
|
||||
def procedure_filter
|
||||
procedure_id = self[:procedure_filter]
|
||||
if procedures.find_by(id: procedure_id).present?
|
||||
|
@ -47,6 +51,19 @@ class Gestionnaire < ActiveRecord::Base
|
|||
procedures.find_by(id: procedure_id).present?
|
||||
end
|
||||
|
||||
def assign_to_procedure(procedure)
|
||||
begin
|
||||
procedures << procedure
|
||||
true
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def remove_from_procedure(procedure)
|
||||
!!(procedure.in?(procedures) && procedures.destroy(procedure))
|
||||
end
|
||||
|
||||
def last_week_overview
|
||||
start_date = DateTime.now.beginning_of_week
|
||||
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
class AccompagnateurService
|
||||
ASSIGN = 'assign'
|
||||
NOT_ASSIGN = 'not_assign'
|
||||
|
||||
def initialize accompagnateur, procedure, to
|
||||
@accompagnateur = accompagnateur
|
||||
@procedure = procedure
|
||||
@to = to
|
||||
end
|
||||
|
||||
def change_assignement!
|
||||
case @to
|
||||
when ASSIGN
|
||||
AssignTo.create(gestionnaire: @accompagnateur, procedure: @procedure)
|
||||
when NOT_ASSIGN
|
||||
AssignTo.where(gestionnaire: @accompagnateur, procedure: @procedure).delete_all
|
||||
end
|
||||
end
|
||||
end
|
|
@ -9,7 +9,7 @@
|
|||
- @accompagnateurs_assign.each do |accompagnateur|
|
||||
%tr
|
||||
%td.col-md-1.col-lg-1.col-sm-1.col-xs-1.col-sm-1.col-xs-1.center
|
||||
%a.btn.btn-primary{ href: "#{admin_procedure_accompagnateurs_path(procedure_id: @procedure.id, accompagnateur_id: accompagnateur.id, to: AccompagnateurService::NOT_ASSIGN)}", 'data-method' => 'put' }
|
||||
= link_to "#{admin_procedure_accompagnateurs_path(procedure_id: @procedure.id, accompagnateur_id: accompagnateur.id, to: Admin::AccompagnateursController::NOT_ASSIGN)}", class: "btn btn-primary", 'data-method' => 'put' do
|
||||
.fa.fa-arrow-left
|
||||
%td{ style: 'padding-top: 11px; font-size: 15px; text-align: right;' }= accompagnateur.email
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
%tr
|
||||
%td.col-xs-11{ style: 'padding-top: 11px; font-size: 15px;' }= accompagnateur.email
|
||||
%td.center
|
||||
%a.btn.btn-success.gestionnaire-affectation{ href: "#{admin_procedure_accompagnateurs_path(procedure_id: @procedure.id, accompagnateur_id: accompagnateur.id, to: AccompagnateurService::ASSIGN)}", 'data-method' => 'put' }
|
||||
= link_to "#{admin_procedure_accompagnateurs_path(procedure_id: @procedure.id, accompagnateur_id: accompagnateur.id, to: Admin::AccompagnateursController::ASSIGN)}", class: "btn btn-success gestionnaire-affectation", 'data-method' => 'put' do
|
||||
.fa.fa-arrow-right
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
- if nav_bar_profile == :gestionnaire && gestionnaire_signed_in?
|
||||
- current_url = request.path_info
|
||||
%ul.header-tabs
|
||||
- if current_gestionnaire.procedures.count > 0
|
||||
- if current_gestionnaire.visible_procedures.count > 0
|
||||
%li
|
||||
= link_to "Procédures", gestionnaire_procedures_path, class: (controller_name != 'avis') ? "tab-link active" : 'tab-link'
|
||||
- if current_gestionnaire.avis.count > 0
|
||||
|
|
|
@ -16,7 +16,7 @@ as well as a link to its edit page.
|
|||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Show
|
||||
%>
|
||||
|
||||
<% content_for(:title) { "#{t("administrate.actions.show")} #{page.page_title}" } %>
|
||||
<% content_for(:title) { t("administrate.actions.show_resource", name: page.page_title) } %>
|
||||
<% procedure = page.resource %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
|
@ -26,7 +26,7 @@ as well as a link to its edit page.
|
|||
|
||||
<div>
|
||||
<%= link_to(
|
||||
"#{t("administrate.actions.edit")} #{page.page_title}",
|
||||
t("administrate.actions.edit_resource", name: page.page_title),
|
||||
[:edit, namespace, page.resource],
|
||||
class: "button",
|
||||
) if valid_action? :edit %>
|
||||
|
|
|
@ -16,7 +16,7 @@ as well as a link to its edit page.
|
|||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Show
|
||||
%>
|
||||
|
||||
<% content_for(:title) { "#{t("administrate.actions.show")} #{page.page_title}" } %>
|
||||
<% content_for(:title) { t("administrate.actions.show_resource", name: page.page_title) } %>
|
||||
<% procedure = page.resource %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
|
@ -26,7 +26,7 @@ as well as a link to its edit page.
|
|||
|
||||
<div>
|
||||
<%= link_to(
|
||||
"#{t("administrate.actions.edit")} #{page.page_title}",
|
||||
t("administrate.actions.edit_resource", name: page.page_title),
|
||||
[:edit, namespace, page.resource],
|
||||
class: "button",
|
||||
) if valid_action? :edit %>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddUniqueIndexOnAssignTosGestionnaireIdProcedureId < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_index :assign_tos, [:gestionnaire_id, :procedure_id], unique: true
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2018_02_09_133452) do
|
||||
ActiveRecord::Schema.define(version: 2018_02_19_170553) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -84,6 +84,7 @@ ActiveRecord::Schema.define(version: 2018_02_09_133452) do
|
|||
create_table "assign_tos", id: :serial, force: :cascade do |t|
|
||||
t.integer "gestionnaire_id"
|
||||
t.integer "procedure_id"
|
||||
t.index ["gestionnaire_id", "procedure_id"], name: "index_assign_tos_on_gestionnaire_id_and_procedure_id", unique: true
|
||||
t.index ["gestionnaire_id"], name: "index_assign_tos_on_gestionnaire_id"
|
||||
t.index ["procedure_id"], name: "index_assign_tos_on_procedure_id"
|
||||
end
|
||||
|
|
|
@ -64,6 +64,54 @@ describe Gestionnaire, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#assign_to_procedure" do
|
||||
subject { gestionnaire.assign_to_procedure(procedure_to_assign) }
|
||||
|
||||
context "with a procedure not already assigned" do
|
||||
let(:procedure_to_assign) { procedure_3 }
|
||||
|
||||
it { is_expected.to be_truthy }
|
||||
it { expect{ subject }.to change(gestionnaire.procedures, :count) }
|
||||
end
|
||||
|
||||
context "with an already assigned procedure" do
|
||||
let(:procedure_to_assign) { procedure }
|
||||
|
||||
it { is_expected.to be_falsey }
|
||||
it { expect{ subject }.not_to change(gestionnaire.procedures, :count) }
|
||||
end
|
||||
end
|
||||
|
||||
describe "#remove_from_procedure" do
|
||||
subject { gestionnaire.remove_from_procedure(procedure_to_remove) }
|
||||
|
||||
context "with an assigned procedure" do
|
||||
let(:procedure_to_remove) { procedure }
|
||||
let!(:procedure_presentation) { procedure_assign.procedure_presentation }
|
||||
|
||||
it { is_expected.to be_truthy }
|
||||
|
||||
describe "consequences" do
|
||||
before do
|
||||
procedure_assign.build_procedure_presentation
|
||||
procedure_assign.save
|
||||
subject
|
||||
end
|
||||
|
||||
it "removes the assign_to and procedure_presentation" do
|
||||
expect(AssignTo.where(id: procedure_assign).count).to eq(0)
|
||||
expect(ProcedurePresentation.where(assign_to_id: procedure_assign.id).count).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with an already unassigned procedure" do
|
||||
let(:procedure_to_remove) { procedure_3 }
|
||||
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
end
|
||||
|
||||
context 'unified login' do
|
||||
it 'syncs credentials to associated user' do
|
||||
gestionnaire = create(:gestionnaire)
|
||||
|
@ -188,7 +236,6 @@ describe Gestionnaire, type: :model do
|
|||
end
|
||||
|
||||
describe "procedure_presentation_for_procedure_id" do
|
||||
let!(:procedure_assign_2) { create :assign_to, gestionnaire: gestionnaire, procedure: procedure_2 }
|
||||
let!(:pp) { ProcedurePresentation.create(assign_to: procedure_assign) }
|
||||
|
||||
it { expect(gestionnaire.procedure_presentation_for_procedure_id(procedure.id)).to eq(pp) }
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe AccompagnateurService do
|
||||
let(:procedure) { create :procedure, :published }
|
||||
let(:accompagnateur) { create :gestionnaire }
|
||||
|
||||
let(:accompagnateur_service) { AccompagnateurService.new accompagnateur, procedure, to }
|
||||
|
||||
describe '#change_assignement!' do
|
||||
subject { accompagnateur_service.change_assignement! }
|
||||
|
||||
context 'when accompagnateur is not assign at the procedure' do
|
||||
let(:to) { AccompagnateurService::ASSIGN }
|
||||
|
||||
before do
|
||||
subject
|
||||
end
|
||||
|
||||
it { expect(accompagnateur.procedures).to include procedure }
|
||||
end
|
||||
|
||||
context 'when accompagnateur is assign at the procedure' do
|
||||
let(:to) { AccompagnateurService::NOT_ASSIGN }
|
||||
|
||||
before do
|
||||
create :assign_to, gestionnaire: accompagnateur, procedure: procedure
|
||||
subject
|
||||
end
|
||||
|
||||
it { expect(accompagnateur.procedures).not_to include procedure }
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue