mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-27 04:51:14 +00:00
f6b30be278
Improve brackets Update gitignore and docs.
41 lines
985 B
Ruby
41 lines
985 B
Ruby
class BracketsController < ApplicationController
|
|
before_action :get_bracket, only: [:show, :edit, :update, :destroy]
|
|
|
|
def edit
|
|
raise AccessError unless @bracket.can_update? cuser
|
|
render layout: 'full'
|
|
end
|
|
|
|
def create
|
|
@bracket = Bracket.new Bracket.params(params, cuser)
|
|
raise AccessError unless @bracket.can_create? cuser
|
|
|
|
if @bracket.save
|
|
flash[:notice] = t(:brackets_create)
|
|
end
|
|
|
|
redirect_to edit_contest_path(@bracket.contest)
|
|
end
|
|
|
|
def update
|
|
raise AccessError unless @bracket.can_update? cuser
|
|
|
|
if @bracket.update_attributes(Bracket.params(params, cuser)) and @bracket.update_cells(params.permit(:cell))
|
|
flash[:notice] = t(:brackets_update)
|
|
end
|
|
|
|
render :edit, layout: 'full'
|
|
end
|
|
|
|
def destroy
|
|
raise AccessError unless @bracket.can_destroy? cuser
|
|
@bracket.destroy
|
|
redirect_to edit_contest_path(@bracket.contest)
|
|
end
|
|
|
|
private
|
|
|
|
def get_bracket
|
|
@bracket = Bracket.find(params[:id])
|
|
end
|
|
end
|