From a029aa62b18657ff10eeaa33ea7b4f1341508d82 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 2 Oct 2018 16:04:14 +0200 Subject: [PATCH] [Fix #2674] Add Services to manager --- .../manager/services_controller.rb | 4 ++ app/dashboards/procedure_dashboard.rb | 4 +- app/dashboards/service_dashboard.rb | 63 +++++++++++++++++++ config/routes.rb | 3 + 4 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 app/controllers/manager/services_controller.rb create mode 100644 app/dashboards/service_dashboard.rb diff --git a/app/controllers/manager/services_controller.rb b/app/controllers/manager/services_controller.rb new file mode 100644 index 000000000..ff9fd2c5f --- /dev/null +++ b/app/controllers/manager/services_controller.rb @@ -0,0 +1,4 @@ +module Manager + class ServicesController < Manager::ApplicationController + end +end diff --git a/app/dashboards/procedure_dashboard.rb b/app/dashboards/procedure_dashboard.rb index 1867d4404..ed558de60 100644 --- a/app/dashboards/procedure_dashboard.rb +++ b/app/dashboards/procedure_dashboard.rb @@ -28,6 +28,7 @@ class ProcedureDashboard < Administrate::BaseDashboard hidden_at: Field::DateTime, archived_at: Field::DateTime, whitelisted_at: Field::DateTime, + service: Field::BelongsTo, }.freeze # COLLECTION_ATTRIBUTES @@ -54,6 +55,7 @@ class ProcedureDashboard < Administrate::BaseDashboard :description, :organisation, :direction, + :service, :created_at, :updated_at, :published_at, @@ -65,7 +67,7 @@ class ProcedureDashboard < Administrate::BaseDashboard :for_individual, :individual_with_siret, :auto_archive_on, - :gestionnaires + :gestionnaires, ].freeze # FORM_ATTRIBUTES diff --git a/app/dashboards/service_dashboard.rb b/app/dashboards/service_dashboard.rb new file mode 100644 index 000000000..4066b9e49 --- /dev/null +++ b/app/dashboards/service_dashboard.rb @@ -0,0 +1,63 @@ +require "administrate/base_dashboard" + +class ServiceDashboard < Administrate::BaseDashboard + # ATTRIBUTE_TYPES + # a hash that describes the type of each of the model's fields. + # + # Each different type represents an Administrate::Field object, + # which determines how the attribute is displayed + # on pages throughout the dashboard. + ATTRIBUTE_TYPES = { + id: Field::Number, + type_organisme: Field::String, + nom: Field::String, + created_at: Field::DateTime, + updated_at: Field::DateTime, + administrateur: Field::BelongsTo, + organisme: Field::String, + email: Field::String, + telephone: Field::String, + horaires: Field::String, + adresse: Field::String, + siret: Field::String, + }.freeze + + # COLLECTION_ATTRIBUTES + # an array of attributes that will be displayed on the model's index page. + # + # By default, it's limited to four items to reduce clutter on index pages. + # Feel free to add, remove, or rearrange items. + COLLECTION_ATTRIBUTES = [ + :nom, + :type_organisme, + ].freeze + + # SHOW_PAGE_ATTRIBUTES + # an array of attributes that will be displayed on the model's show page. + SHOW_PAGE_ATTRIBUTES = [ + :id, + :type_organisme, + :nom, + :created_at, + :updated_at, + :administrateur, + :organisme, + :email, + :telephone, + :horaires, + :adresse, + :siret, + ].freeze + + # FORM_ATTRIBUTES + # an array of attributes that will be displayed + # on the model's form (`new` and `edit`) pages. + FORM_ATTRIBUTES = [].freeze + + # Overwrite this method to customize how users are displayed + # across all pages of the admin dashboard. + # + def display_resource(service) + service.nom + end +end diff --git a/config/routes.rb b/config/routes.rb index 4560f9058..4f35ffe32 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -31,6 +31,9 @@ Rails.application.routes.draw do resources :dossiers, only: [:show] resources :demandes, only: [:index] + + resources :services, only: [:index, :show] + post 'demandes/create_administrateur' post 'demandes/refuse_administrateur'