diff --git a/CHANGELOG.md b/CHANGELOG.md index 641d47789..e2b2f9038 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Next release - Improvement: default order for the spaces/trainings list is set to descending by created_at +- Improvement: members cannot see training deactivated in the list ## v6.3.35 2024 November 13 diff --git a/app/controllers/api/trainings_controller.rb b/app/controllers/api/trainings_controller.rb index 286ef7bf8..e912fc807 100644 --- a/app/controllers/api/trainings_controller.rb +++ b/app/controllers/api/trainings_controller.rb @@ -14,6 +14,7 @@ class API::TrainingsController < API::APIController def show @training = Training.friendly.find(params[:id]) + authorize @training end def create diff --git a/app/policies/training_policy.rb b/app/policies/training_policy.rb index 6fb3d1215..18b66f89c 100644 --- a/app/policies/training_policy.rb +++ b/app/policies/training_policy.rb @@ -8,6 +8,10 @@ class TrainingPolicy < ApplicationPolicy end end + def show? + !record.disabled? || user.admin? || user.manager? + end + def create? user.admin? end