mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-27 04:51:14 +00:00
e59e8ac8e7
- Add .params to models and update controllers - Add afk time to gather - Reannotate models - Fix rspec problem by using latest rspec plugins from github
48 lines
981 B
Ruby
48 lines
981 B
Ruby
class WeeksController < ApplicationController
|
|
before_action :get_week, except: [:new, :create]
|
|
|
|
def new
|
|
@week = Week.new
|
|
@week.contest = Contest.find(params[:id])
|
|
raise AccessError unless @week.can_create? cuser
|
|
end
|
|
|
|
def edit
|
|
raise AccessError unless @week.can_update? cuser
|
|
end
|
|
|
|
def create
|
|
@week = Week.new(Weeks.params(params, cuser))
|
|
raise AccessError unless @week.can_create? cuser
|
|
|
|
if @week.save
|
|
flash[:notice] = t(:weeks_create)
|
|
redirect_to @week.contest
|
|
else
|
|
render :new
|
|
end
|
|
end
|
|
|
|
def update
|
|
raise AccessError unless @week.can_update? cuser
|
|
|
|
if @week.update_attributes(Week.params(params, cuser))
|
|
flash[:notice] = t(:weeks_update)
|
|
redirect_to @week.contest
|
|
else
|
|
render :edit
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
raise AccessError unless @week.can_destroy? cuser
|
|
@week.destroy
|
|
redirect_to_back
|
|
end
|
|
|
|
private
|
|
|
|
def get_week
|
|
@week = Week.find(params[:id])
|
|
end
|
|
end
|