2011-12-10 10:12:39 +00:00
|
|
|
class Admin::RolesController < ApplicationController
|
|
|
|
|
|
|
|
layout "admin"
|
|
|
|
before_filter :authenticate_user!
|
|
|
|
before_filter :is_admin?
|
|
|
|
before_filter :set_attribute, :only => [:index, :show, :new, :edit]
|
|
|
|
|
|
|
|
def index
|
|
|
|
@attributes = Role.all.entries
|
|
|
|
render :template => 'admin/attributes/index'
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
2011-12-18 02:07:42 +00:00
|
|
|
|
2011-12-10 10:12:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@attribute = Role.new
|
2011-12-18 02:07:42 +00:00
|
|
|
render :template => 'admin/attributes/new'
|
2011-12-10 10:12:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@attribute = Role.find(params[:id])
|
|
|
|
@i18n_variable = @attribute.i18n_variable
|
2011-12-18 02:07:42 +00:00
|
|
|
render :template => 'admin/attributes/edit'
|
2011-12-10 10:12:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2011-12-19 13:22:26 +00:00
|
|
|
puts params.to_yaml
|
2011-12-10 10:12:39 +00:00
|
|
|
@attribute = Role.new(params[:role])
|
|
|
|
@attribute.save
|
|
|
|
redirect_to :action => :index
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2011-12-19 13:22:26 +00:00
|
|
|
puts params.to_yaml
|
2011-12-10 10:12:39 +00:00
|
|
|
@attribute = Role.find(params[:id])
|
|
|
|
@attribute.update_attributes(params[:role])
|
|
|
|
respond_to do |format|
|
|
|
|
format.html { redirect_to :action => :index }
|
|
|
|
format.js { render 'admin/attributes/toggle_enable' }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@attribute = Role.find(params[:id])
|
|
|
|
@attribute.destroy
|
|
|
|
redirect_to :action => :index
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def set_attribute
|
|
|
|
@attribute_type = 'role'
|
2011-12-18 02:07:42 +00:00
|
|
|
@class = 'roles'
|
2011-12-10 10:12:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|