1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

[bug] managers cannot see passed events

This commit is contained in:
Sylvain 2020-09-29 08:40:07 +02:00
parent fd1589207a
commit 30b3a794d3
3 changed files with 4 additions and 2 deletions

View File

@ -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

View File

@ -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')

View File

@ -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')