Class: Backend::Cells::EventsCellsController

Inherits:
BaseController show all
Defined in:
app/controllers/backend/cells/events_cells_controller.rb

Instance Attribute Summary

Attributes inherited from ApplicationController

#current_theme

Instance Method Summary collapse

Methods inherited from BaseController

accounts_range_crit, crit_params, journal_entries_states_crit, journal_period_crit, journals_crit, search_conditions

Methods inherited from ApplicationController

#after_sign_in_path_for, #authorized?, human_action_name, #human_action_name

Instance Method Details

#showObject


4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/backend/cells/events_cells_controller.rb', line 4

def show
  mode = (params[:mode] || :all).to_s.tr('_', '-')
  @events = (mode =~ /\bmy\b/ ? Event.with_participant(current_user.person) : Event.without_restrictions_for(current_user.person))
  now = Time.zone.now
  if mode =~ /\bfuture\b/
    @events = @events.after(now).reorder(started_at: :asc)
  elsif mode =~ /\blast\b/
    @events = @events.before(now).reorder(started_at: :desc)
  end
  count = params[:count].to_i
  count = 5 unless 0 < count && count <= 50
  @events = @events.limit(count)
end