2014-09-30 13:34:09 +03:00
|
|
|
module Management
|
|
|
|
class EventsController < ManagementController
|
2014-10-10 19:10:34 +03:00
|
|
|
before_action :assign_suggestion, only: [:show, :state]
|
2014-09-30 13:34:09 +03:00
|
|
|
|
|
|
|
def index
|
|
|
|
@suggestion_groups = SuggestionGroup.for_conference Conference.current
|
|
|
|
end
|
|
|
|
|
2014-10-10 19:10:34 +03:00
|
|
|
def approved
|
|
|
|
@suggestion_groups = SuggestionGroup.for_conference Conference.current, state: Event.states[:approved]
|
|
|
|
render :index
|
|
|
|
end
|
|
|
|
|
|
|
|
def undecided
|
|
|
|
@suggestion_groups = SuggestionGroup.for_conference Conference.current, state: Event.states[:undecided]
|
|
|
|
render :index
|
|
|
|
end
|
|
|
|
|
|
|
|
def rejected
|
|
|
|
@suggestion_groups = SuggestionGroup.for_conference Conference.current, state: Event.states[:rejected]
|
|
|
|
render :index
|
|
|
|
end
|
|
|
|
|
2014-10-10 20:25:41 +03:00
|
|
|
def backup
|
|
|
|
@suggestion_groups = SuggestionGroup.for_conference Conference.current, state: Event.states[:backup]
|
|
|
|
render :index
|
|
|
|
end
|
|
|
|
|
2014-09-30 13:34:09 +03:00
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
2014-10-10 19:10:34 +03:00
|
|
|
def state
|
|
|
|
@suggestion.state = state_params
|
|
|
|
@suggestion.save
|
|
|
|
end
|
|
|
|
|
2014-10-12 15:32:23 +03:00
|
|
|
def send_acceptance_notifications
|
|
|
|
@suggestions = Conference.current.events.approved.where acceptance_notification_sent_at: nil
|
|
|
|
if @suggestions.all?(&:send_acceptance_notification!)
|
|
|
|
head :no_content
|
|
|
|
else
|
|
|
|
head :unprocessable_entity
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-09-30 13:34:09 +03:00
|
|
|
private
|
|
|
|
|
2014-10-10 19:10:34 +03:00
|
|
|
def state_params
|
|
|
|
params.require :state
|
|
|
|
end
|
|
|
|
|
2014-09-30 13:34:09 +03:00
|
|
|
def assign_suggestion
|
|
|
|
@suggestion = Event.find params[:id]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|