2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2014-06-05 14:52:44 +05:30
|
|
|
module Admin
|
2014-08-13 14:37:05 +03:00
|
|
|
class SponsorshipLevelsController < Admin::BaseController
|
2014-08-12 11:51:59 +03:00
|
|
|
load_and_authorize_resource :conference, find_by: :short_title
|
2014-11-14 11:58:36 +01:00
|
|
|
load_and_authorize_resource through: :conference
|
2014-08-12 11:51:59 +03:00
|
|
|
|
|
|
|
|
def index
|
|
|
|
|
authorize! :index, SponsorshipLevel.new(conference_id: @conference.id)
|
|
|
|
|
end
|
2014-06-05 14:52:44 +05:30
|
|
|
|
2014-11-14 11:58:36 +01:00
|
|
|
def edit; end
|
|
|
|
|
|
|
|
|
|
def new
|
|
|
|
|
@sponsorship_level = @conference.sponsorship_levels.new
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def create
|
|
|
|
|
@sponsorship_level = @conference.sponsorship_levels.new(sponsorship_level_params)
|
|
|
|
|
if @sponsorship_level.save
|
2016-03-11 02:08:00 +05:30
|
|
|
redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title),
|
|
|
|
|
notice: 'Sponsorship level successfully created.'
|
2014-11-14 11:58:36 +01:00
|
|
|
else
|
2017-04-03 18:34:37 +03:00
|
|
|
flash.now[:error] = "Creating Sponsorship Level failed: #{@sponsorship_level.errors.full_messages.join('. ')}."
|
2014-11-14 11:58:36 +01:00
|
|
|
render :new
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2014-06-05 14:52:44 +05:30
|
|
|
def update
|
2022-02-14 17:53:58 +01:00
|
|
|
if @sponsorship_level.update(sponsorship_level_params)
|
2016-03-11 02:08:00 +05:30
|
|
|
redirect_to admin_conference_sponsorship_levels_path(
|
2014-06-05 14:52:44 +05:30
|
|
|
conference_id: @conference.short_title),
|
2016-03-11 02:08:00 +05:30
|
|
|
notice: 'Sponsorship level successfully updated.'
|
2014-06-05 14:52:44 +05:30
|
|
|
else
|
2017-04-03 18:34:37 +03:00
|
|
|
flash.now[:error] = "Update Sponsorship level failed: #{@sponsorship_level.errors.full_messages.join('. ')}."
|
2014-11-14 11:58:36 +01:00
|
|
|
render :edit
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
|
if @sponsorship_level.destroy
|
2016-03-11 02:08:00 +05:30
|
|
|
redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title),
|
|
|
|
|
notice: 'Sponsorship level successfully deleted.'
|
2014-11-14 11:58:36 +01:00
|
|
|
else
|
2016-03-11 02:08:00 +05:30
|
|
|
redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title),
|
2014-11-14 11:58:36 +01:00
|
|
|
error: 'Deleting sponsorship level failed! ' \
|
2016-03-11 02:08:00 +05:30
|
|
|
"#{@sponsorship_level.errors.full_messages.join('. ')}."
|
2014-06-05 14:52:44 +05:30
|
|
|
end
|
|
|
|
|
end
|
2014-11-14 11:58:36 +01:00
|
|
|
|
|
|
|
|
def up
|
|
|
|
|
@sponsorship_level.move_higher
|
2016-03-11 02:08:00 +05:30
|
|
|
redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title)
|
2014-11-14 11:58:36 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def down
|
|
|
|
|
@sponsorship_level.move_lower
|
2016-03-11 02:08:00 +05:30
|
|
|
redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title)
|
2014-11-14 11:58:36 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def sponsorship_level_params
|
2026-03-17 15:59:42 +01:00
|
|
|
params.require(:sponsorship_level).permit(:title)
|
2014-11-14 11:58:36 +01:00
|
|
|
end
|
2014-06-05 14:52:44 +05:30
|
|
|
end
|
|
|
|
|
end
|