mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-14 04:04:03 +00:00
Implement role authorization
This commit is contained in:
parent
6755328c4c
commit
e2fb434dc7
122 changed files with 1386 additions and 751 deletions
|
|
@ -1,9 +1,10 @@
|
|||
module Admin
|
||||
class DifficultyLevelsController < ApplicationController
|
||||
before_filter :verify_organizer
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
authorize_resource through: :conference
|
||||
|
||||
def index
|
||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||
authorize! :index, DifficultyLevel.new(conference_id: @conference.id)
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
@ -13,18 +14,18 @@ module Admin
|
|||
@conference.use_difficulty_levels = false
|
||||
@conference.save!
|
||||
flash[:error] = "You cannot enable the usage of difficulty levels without having set any levels."
|
||||
redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title))
|
||||
redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title))
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
flash[:error] = "Something went wrong. Difficulty Levels update failed."
|
||||
redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title))
|
||||
redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title))
|
||||
end
|
||||
else
|
||||
flash[:notice] = "Difficulty Levels were successfully updated."
|
||||
redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title))
|
||||
redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title))
|
||||
end
|
||||
else
|
||||
flash[:error] = "Difficulty Levels update failed."
|
||||
redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title))
|
||||
redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue