diff --git a/CHANGELOG.md b/CHANGELOG.md index e1874b9d8..9468f9e46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog Fab-manager +- Fix a bug: managers cannot see passed events + ## v4.5.8 2020 Septembre 28 - Fix a bug: unable to run the elastic-upgrade script diff --git a/app/controllers/api/events_controller.rb b/app/controllers/api/events_controller.rb index 2e550018e..e86703835 100644 --- a/app/controllers/api/events_controller.rb +++ b/app/controllers/api/events_controller.rb @@ -14,7 +14,7 @@ class API::EventsController < API::ApiController @events = @events.joins(:event_themes).where('event_themes.id = :theme', theme: params[:theme_id]) if params[:theme_id] @events = @events.where('age_range_id = :age_range', age_range: params[:age_range_id]) if params[:age_range_id] - if current_user&.admin? + if current_user&.admin? || current_user&.manager? @events = case params[:scope] when 'future' @events.where('availabilities.start_at >= ?', DateTime.current).order('availabilities.start_at DESC') diff --git a/app/policies/event_policy.rb b/app/policies/event_policy.rb index 4db834236..1a5a51df5 100644 --- a/app/policies/event_policy.rb +++ b/app/policies/event_policy.rb @@ -5,7 +5,7 @@ class EventPolicy < ApplicationPolicy # Defines the scope of the events index, depending on the role of the current user class Scope < Scope def resolve - if user.nil? || (user && !user.admin?) + if user.nil? || (user && !user.admin? && !user.manager?) scope.includes(:event_image, :event_files, :availability, :category) .where('availabilities.start_at >= ?', DateTime.current) .order('availabilities.start_at ASC')