@@ -102,20 +102,22 @@ def validate_new
102102 end
103103
104104 def set_index_variables # needs to not be private
105- @month_year_options = WorkshopLog . group ( "DATE_FORMAT(COALESCE(date, created_at, NOW()), '%Y-%m')" )
105+ scoped_logs = authorized_scope ( WorkshopLog . all )
106+ @month_year_options = scoped_logs . group ( "DATE_FORMAT(COALESCE(date, created_at, NOW()), '%Y-%m')" )
106107 . select ( "DATE_FORMAT(COALESCE(date, created_at, NOW()), '%Y-%m') AS ym,
107108 MAX(COALESCE(date, created_at)) AS max_dt" )
108109 . order ( "max_dt DESC" )
109110 . map { |record | [ Date . strptime ( record . ym , "%Y-%m" ) . strftime ( "%B %Y" ) , record . ym ] }
110-
111- @year_options = WorkshopLog . pluck (
111+ @year_options = scoped_logs . pluck (
112112 Arel . sql ( "DISTINCT EXTRACT(YEAR FROM COALESCE(date, created_at, NOW()))" )
113113 ) . sort . reverse
114- @facilitators = User . active . or ( User . where ( id : @workshop_logs_unpaginated . pluck ( :user_id ) ) )
115- . includes ( :workshop_logs , :facilitator )
116- . joins ( :workshop_logs )
117- . distinct
118- . order ( "facilitators.first_name, facilitators.last_name" )
114+
115+ scoped_users = current_user &.super_user? ? User . active : User . where ( id : current_user . id )
116+ @facilitators = scoped_users . or ( User . where ( id : @workshop_logs_unpaginated . pluck ( :user_id ) ) )
117+ . includes ( :workshop_logs , :facilitator )
118+ . joins ( :workshop_logs )
119+ . distinct
120+ . order ( "facilitators.first_name, facilitators.last_name" )
119121 @organizations =
120122 if current_user &.super_user?
121123 # Organization.where(id: @workshop_logs_unpaginated.pluck(:organization_id)).order(:name)
0 commit comments