mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-27 04:51:14 +00:00
58 lines
1,016 B
Ruby
58 lines
1,016 B
Ruby
|
class BansController < ApplicationController
|
||
|
before_filter :get_ban, :only => [:show, :edit, :update, :destroy]
|
||
|
|
||
|
def index
|
||
|
@bans = Ban.ordered
|
||
|
end
|
||
|
|
||
|
def show
|
||
|
end
|
||
|
|
||
|
def refresh
|
||
|
Ban.refresh
|
||
|
end
|
||
|
|
||
|
def new
|
||
|
@ban = Ban.new
|
||
|
raise AccessError unless @ban.can_create? cuser
|
||
|
end
|
||
|
|
||
|
def edit
|
||
|
raise AccessError unless @ban.can_update? cuser
|
||
|
end
|
||
|
|
||
|
def create
|
||
|
@ban = Ban.new(params[:ban])
|
||
|
raise AccessError unless @ban.can_create? cuser
|
||
|
|
||
|
if @ban.save
|
||
|
flash[:notice] = t(:bans_create)
|
||
|
redirect_to(@ban)
|
||
|
else
|
||
|
render :action => "new"
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def update
|
||
|
raise AccessError unless @ban.can_update? cuser
|
||
|
if @ban.update_attributes(params[:ban])
|
||
|
flash[:notice] = t(:bans_update)
|
||
|
redirect_to(@ban)
|
||
|
else
|
||
|
render :action => "edit"
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def destroy
|
||
|
raise AccessError unless @ban.can_destroy? cuser
|
||
|
@ban.destroy
|
||
|
redirect_to(bans_url)
|
||
|
end
|
||
|
|
||
|
private
|
||
|
|
||
|
def get_ban
|
||
|
@ban = Ban.find(params[:id])
|
||
|
end
|
||
|
end
|