diff --git a/Gemfile b/Gemfile index 68f3b6576..27c1d035a 100644 --- a/Gemfile +++ b/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' diff --git a/Gemfile.lock b/Gemfile.lock index f3ad4d067..7771536d5 100644 --- a/Gemfile.lock +++ b/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 diff --git a/app/controllers/admin/accompagnateurs_controller.rb b/app/controllers/admin/accompagnateurs_controller.rb index 1f7ca7c7f..f695dca07 100644 --- a/app/controllers/admin/accompagnateurs_controller.rb +++ b/app/controllers/admin/accompagnateurs_controller.rb @@ -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 diff --git a/app/controllers/new_gestionnaire/procedures_controller.rb b/app/controllers/new_gestionnaire/procedures_controller.rb index 0131bcb61..7b4d958a6 100644 --- a/app/controllers/new_gestionnaire/procedures_controller.rb +++ b/app/controllers/new_gestionnaire/procedures_controller.rb @@ -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 diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb index 9a9a01b0b..4b4a98aa2 100644 --- a/app/models/gestionnaire.rb +++ b/app/models/gestionnaire.rb @@ -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 diff --git a/app/services/accompagnateur_service.rb b/app/services/accompagnateur_service.rb deleted file mode 100644 index 2546506a9..000000000 --- a/app/services/accompagnateur_service.rb +++ /dev/null @@ -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 diff --git a/app/views/admin/accompagnateurs/_list_assign.html.haml b/app/views/admin/accompagnateurs/_list_assign.html.haml index cd7d1621a..8afe8e25f 100644 --- a/app/views/admin/accompagnateurs/_list_assign.html.haml +++ b/app/views/admin/accompagnateurs/_list_assign.html.haml @@ -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 diff --git a/app/views/admin/accompagnateurs/_list_not_assign.html.haml b/app/views/admin/accompagnateurs/_list_not_assign.html.haml index 51e8c5326..e9e156a07 100644 --- a/app/views/admin/accompagnateurs/_list_not_assign.html.haml +++ b/app/views/admin/accompagnateurs/_list_not_assign.html.haml @@ -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 diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml index 3f73c7cba..f4e088c14 100644 --- a/app/views/layouts/_new_header.haml +++ b/app/views/layouts/_new_header.haml @@ -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 diff --git a/app/views/manager/administrateurs/show.html.erb b/app/views/manager/administrateurs/show.html.erb index df139d013..f7665c111 100644 --- a/app/views/manager/administrateurs/show.html.erb +++ b/app/views/manager/administrateurs/show.html.erb @@ -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 %>