2014-09-17 12:43:17 +03:00
|
|
|
module Management
|
|
|
|
class ManagementController < ::ApplicationController
|
2014-09-17 14:30:50 +03:00
|
|
|
before_action :authenticate_user!, :authorize_user!
|
|
|
|
|
2014-09-17 12:43:17 +03:00
|
|
|
layout 'management'
|
2014-09-17 14:30:50 +03:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2015-06-09 21:50:23 +03:00
|
|
|
def default_url_options(options = {})
|
2015-07-12 10:28:24 +03:00
|
|
|
{ current_conference: current_conference.try(:slug) }.merge(options)
|
2015-06-09 21:50:23 +03:00
|
|
|
end
|
|
|
|
|
2015-05-30 17:07:57 +03:00
|
|
|
def current_conference?
|
2015-05-30 17:24:49 +03:00
|
|
|
current_conference.present?
|
2015-05-30 17:07:57 +03:00
|
|
|
end
|
|
|
|
helper_method :current_conference?
|
|
|
|
|
2015-06-09 21:50:23 +03:00
|
|
|
# TODO (2015-06-09) Fetch conferences by slug only
|
2015-05-30 17:07:57 +03:00
|
|
|
def current_conference
|
2015-06-09 21:50:23 +03:00
|
|
|
@current_conference ||=
|
|
|
|
begin
|
|
|
|
# if params[:current_conference]
|
|
|
|
# Conference.find_by_slug(params[:current_conference])
|
|
|
|
# end
|
|
|
|
|
|
|
|
if session[:current_conference_id]
|
|
|
|
Conference.find_by(id: session[:current_conference_id])
|
|
|
|
end
|
|
|
|
end
|
2015-05-30 17:07:57 +03:00
|
|
|
end
|
|
|
|
helper_method :current_conference
|
|
|
|
|
|
|
|
def set_current_conference(conference)
|
2015-05-30 17:24:49 +03:00
|
|
|
if conference.present?
|
|
|
|
session[:current_conference_id] = conference.id
|
|
|
|
else
|
|
|
|
session.delete(:current_conference_id)
|
|
|
|
end
|
2015-05-30 17:07:57 +03:00
|
|
|
end
|
|
|
|
|
2014-09-17 14:30:50 +03:00
|
|
|
def authorize_user!
|
|
|
|
head :forbidden unless current_user.admin?
|
|
|
|
end
|
2014-09-17 12:43:17 +03:00
|
|
|
end
|
|
|
|
end
|