diff --git a/app/controllers/admin/administration/dashboard_controller.rb b/app/controllers/admin/administration/dashboard_controller.rb index b4d6fb38a59655df734f1afda747da3900023b58..58b679812d27e4ada3898998eba0725ffbb31af8 100644 --- a/app/controllers/admin/administration/dashboard_controller.rb +++ b/app/controllers/admin/administration/dashboard_controller.rb @@ -1,6 +1,7 @@ class Admin::Administration::DashboardController < Admin::Administration::ApplicationController def index + raise_403_unless feature_administration? @namespace = Administration breadcrumb render 'admin/dashboard/namespace' diff --git a/app/controllers/admin/communication/dashboard_controller.rb b/app/controllers/admin/communication/dashboard_controller.rb index 89729cd1742fd794533e9ed3161e3644272b1928..c8acc704aac008fa28f00542cff3f9a1b05e0ce6 100644 --- a/app/controllers/admin/communication/dashboard_controller.rb +++ b/app/controllers/admin/communication/dashboard_controller.rb @@ -1,6 +1,7 @@ class Admin::Communication::DashboardController < Admin::Communication::ApplicationController def index + raise_403_unless feature_communication? @namespace = Communication breadcrumb render 'admin/dashboard/namespace' diff --git a/app/controllers/admin/education/dashboard_controller.rb b/app/controllers/admin/education/dashboard_controller.rb index 9e66bb7488220fae88acbce1e87d134d49d137ed..03824a39fa543ab48036ce7a65e4dcb373a3fb36 100644 --- a/app/controllers/admin/education/dashboard_controller.rb +++ b/app/controllers/admin/education/dashboard_controller.rb @@ -1,6 +1,7 @@ class Admin::Education::DashboardController < Admin::Education::ApplicationController def index + raise_403_unless feature_education? @namespace = Education breadcrumb render 'admin/dashboard/namespace' diff --git a/app/controllers/admin/education/teachers_controller.rb b/app/controllers/admin/education/teachers_controller.rb index 455019b4d887f55d39f1e430f915e710d50316e4..ee081706cef8775be107a284c345ebea3d4ae0f1 100644 --- a/app/controllers/admin/education/teachers_controller.rb +++ b/app/controllers/admin/education/teachers_controller.rb @@ -1,5 +1,7 @@ class Admin::Education::TeachersController < Admin::Education::ApplicationController - before_action :load_teacher, only: [:show, :edit, :update] + load_and_authorize_resource class: University::Person::Teacher, + through: :current_university, + through_association: :people has_scope :for_search_term has_scope :for_program @@ -47,14 +49,6 @@ class Admin::Education::TeachersController < Admin::Education::ApplicationContro add_breadcrumb @teacher, admin_education_teacher_path(@teacher) if @teacher end - def load_teacher - @teacher = current_university.people - .for_language_id(current_university.default_language_id) - .teachers - .accessible_by(current_ability) - .find(params[:id]) - end - def teacher_params params.require(:university_person).permit( involvements_attributes: [:id, :target_id, :target_type, :description, :_destroy] diff --git a/app/controllers/admin/research/dashboard_controller.rb b/app/controllers/admin/research/dashboard_controller.rb index ab32c0ed1fa51224fd3e83f254966ce6491cbf47..25bc14de7b4da3ff1901b98c18edd7933827edc0 100644 --- a/app/controllers/admin/research/dashboard_controller.rb +++ b/app/controllers/admin/research/dashboard_controller.rb @@ -1,6 +1,7 @@ class Admin::Research::DashboardController < Admin::Research::ApplicationController def index + raise_403_unless feature_research? @namespace = Research breadcrumb render 'admin/dashboard/namespace' diff --git a/app/controllers/admin/university/dashboard_controller.rb b/app/controllers/admin/university/dashboard_controller.rb index cabcce423f099b175c878231d3ff9dd674d53109..f89936771407967a54b944f1169b00c0bc4ee907 100644 --- a/app/controllers/admin/university/dashboard_controller.rb +++ b/app/controllers/admin/university/dashboard_controller.rb @@ -1,6 +1,7 @@ class Admin::University::DashboardController < Admin::University::ApplicationController def index + raise_403_unless can?(:read, University::Person) || can?(:read, University::Organization) || can?(:read, User) @namespace = University breadcrumb render 'admin/dashboard/namespace' diff --git a/app/controllers/application_controller/with_features.rb b/app/controllers/application_controller/with_features.rb index 76993e34ad0e6549bfd1b77eb2673d3ebfee4ac6..d77ac48c5f31703d6963d5a987c84d4a81dfe1e4 100644 --- a/app/controllers/application_controller/with_features.rb +++ b/app/controllers/application_controller/with_features.rb @@ -3,24 +3,12 @@ module ApplicationController::WithFeatures included do - def feature_administration? - current_university.feature_administration && - can?(:read, Administration::Qualiopi::Criterion) - end - helper_method :feature_administration? - - def feature_communication? - current_university.feature_communication && - can?(:read, Communication::Website) - end - helper_method :feature_communication? - def feature_education? current_university.feature_education && - can?(:read, Education::Program) + can?(:read, Education::Program) end helper_method :feature_education? - + def feature_research? current_university.feature_research && ( can?(:read, Research::Journal) || @@ -29,6 +17,19 @@ module ApplicationController::WithFeatures ) end helper_method :feature_research? + + def feature_communication? + current_university.feature_communication && + can?(:read, Communication::Website) + end + helper_method :feature_communication? + + def feature_administration? + current_university.feature_administration && + can?(:read, Administration::Qualiopi::Criterion) + end + helper_method :feature_administration? end + end diff --git a/app/views/admin/dashboard/namespace.html.erb b/app/views/admin/dashboard/namespace.html.erb index d3667f4a08fa35aaf2b8b29dba39679e8623cc02..ea7421bab974a50d75b3a9005a8ec48727a54297 100644 --- a/app/views/admin/dashboard/namespace.html.erb +++ b/app/views/admin/dashboard/namespace.html.erb @@ -9,6 +9,7 @@ <div class="row pt-5 mt-5"> <% @namespace.parts.each do |part| %> <% + next unless can? :read, part.first class_name = part.first path = send part.last title = class_name.model_name.human(count: 2)