Add params filtering in Management::EventsController#index

This commit is contained in:
Petko Bordjukov 2019-04-29 00:31:36 +03:00
parent 48c979549f
commit b774cb9b11
1 changed files with 12 additions and 1 deletions

View File

@ -2,7 +2,7 @@ module Management
class EventsController < ManagementController class EventsController < ManagementController
def index def index
@conference = find_conference @conference = find_conference
@filters = params[:filters] || {} @filters = filter_params || {}
@events = EventSearch.new(scope: Event.where(conference: @conference).eager_load(:participants_with_personal_profiles, :proposition, :proposer, :track, :event_type).preload(:conference), filters: params[:filters]).results @events = EventSearch.new(scope: Event.where(conference: @conference).eager_load(:participants_with_personal_profiles, :proposition, :proposer, :track, :event_type).preload(:conference), filters: params[:filters]).results
# @events = @conference.events.order(:title).includes(:proposition, :proposer, :track, :event_type) # @events = @conference.events.order(:title).includes(:proposition, :proposer, :track, :event_type)
end end
@ -49,6 +49,17 @@ module Management
Conference.find(params[:conference_id]) Conference.find(params[:conference_id])
end end
def filter_params
params.fetch(:filters, {}).permit(
:event_type_id,
:track_id,
:language,
:status,
:confirmed,
:not_confirmed,
)
end
def event_params def event_params
params.require(:event).permit( params.require(:event).permit(
:title, :title,