Sha256: 1ccb1c0c0a1738d93d56a1fd0444df6a78f6c151d5c4b37a07f114563d327620

Contents?: true

Size: 889 Bytes

Versions: 1

Compression:

Stored size: 889 Bytes

Contents

module Calagator
  class AdminController < Calagator::ApplicationController
    require_admin

    def index; end

    def events
      if params[:query].blank?
        @events = Event.future
      else
        @search = Event::Search.new(params)
        @admin_query = params[:query]

        @events = @search.events

        flash[:failure] = @search.failure_message
        return redirect_to admin_events_path if @search.hard_failure?
      end

      render 'calagator/admin/events'
    end

    def lock_event
      @event = Event.find(params[:event_id])

      if @event.locked?
        @event.unlock_editing!
        flash[:success] = "Unlocked event #{@event.title} (#{@event.id})"
      else
        @event.lock_editing!
        flash[:success] = "Locked event #{@event.title} (#{@event.id})"
      end
      redirect_to action: :events, query: params[:query]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
calagator-1.1.0 app/controllers/calagator/admin_controller.rb