Merge pull request #33 from differentreality/final_difficulty_levels

Add difficulty levels
This commit is contained in:
Henne Vogelsang 2014-03-03 10:40:21 +01:00
commit 4ed72d4967
15 changed files with 119 additions and 3 deletions

View file

@ -0,0 +1,30 @@
class Admin::DifficultyLevelsController < ApplicationController
before_filter :verify_organizer
def index
@conference = Conference.find_all_by_short_title(params[:conference_id]).first
end
def update
if @conference.update_attributes(params[:conference])
if !(@conference.difficulty_levels.count > 0) && @conference.use_difficulty_levels == true
begin
@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))
rescue ActiveRecord::RecordInvalid
flash[:error] = "Something went wrong. Difficulty Levels update failed."
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))
end
else
flash[:error] = "Difficulty Levels update failed."
redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title))
end
end
end

View file

@ -71,6 +71,7 @@ class Admin::EventsController < ApplicationController
@comments = @event.root_comments
@comment_count = @event.comment_threads.count
@ratings = @event.votes.includes(:person)
@difficulty_levels = @conference.difficulty_levels
end
def edit
@ -102,6 +103,9 @@ class Admin::EventsController < ApplicationController
if params.has_key? :event_type_id
@event.update_attribute(:event_type_id, params[:event_type_id])
end
if params.has_key? :difficulty_level_id
@event.update_attribute(:difficulty_level_id, params[:difficulty_level_id])
end
if @event.update_attributes(params[:event]) && @event.submitter.update_attributes(params[:person])
flash[:notice] = "Successfully updated #{@event.title}."
else