Change role structure

Still needs to: change the views and create sub_roles in the dev.rake
This commit is contained in:
chris2tof committed 2011-12-10 18:12:39 +08:00
1 parent e0cdedfa2e
commit b7ac5478b4
45 files changed
+608 -492

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
class Admin::InfosController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :is_admin?
before_filter :set_attribute, :only => [:index, :show, :new, :edit]
def index
@attributes = Info.all.entries
render :template => 'admin/attributes/index'
end
def show
#@attribute = Info.find(params[:id])
end
def new
@attribute = Info.new
end
def edit
@attribute = Info.find(params[:id])
@i18n_variable = @attribute.i18n_variable
end
def create
@attribute = Info.new(params[:info])
@attribute.save
redirect_to :action => :index
end
def update
@attribute = Info.find(params[:id])
@attribute.update_attributes(params[:info])
end
def destroy
@attribute = Info.find(params[:id])
@attribute.destroy
redirect_to :action => :index
end
protected
def set_attribute
@attribute_type = 'info'
end
end
+54
View File
@@ -0,0 +1,54 @@
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
#@attribute = Role.find(params[:id])
end
def new
@attribute = Role.new
end
def edit
@attribute = Role.find(params[:id])
@i18n_variable = @attribute.i18n_variable
end
def create
@attribute = Role.new(params[:role])
@attribute.save
redirect_to :action => :index
end
def update
@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'
end
end
@@ -1,58 +0,0 @@
class Admin::UserInfoModelsController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :is_admin?
before_filter :set_attribute, :only => [:index, :show, :new, :edit]
def index
@user_attribute_models = UserInfoModel.all.entries
render :template => 'admin/user_attribute_models/index'
end
def show
#@user_attribute_model = UserInfoModel.find(params[:id])
end
def new
@user_attribute_model = UserInfoModel.new
render :template => 'admin/user_attribute_models/new'
end
def edit
@user_attribute_model = UserInfoModel.find(params[:id])
@i18n_variable = @user_attribute_model.i18n_variable
render :template => 'admin/user_attribute_models/edit'
end
def create
@user_attribute_model = UserInfoModel.new(params[:user_info_model])
@user_attribute_model.save
redirect_to :action => :index
end
def update
@user_attribute_model = UserInfoModel.find(params[:id])
@user_attribute_model.update_attributes(params[:user_info_model])
respond_to do |format|
format.html { redirect_to :action => :index }
format.js { render 'admin/user_attribute_models/toggle_enable' }
end
end
def destroy
@user_attribute_model = UserInfoModel.find(params[:id])
@user_attribute_model.destroy
@user_attribute_model.destroy_i18n_variables
redirect_to :action => :index
end
protected
def set_attribute
@attribute = 'info'
end
end
@@ -1,59 +0,0 @@
class Admin::UserRoleModelsController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :is_admin?
before_filter :set_attribute, :only => [:index, :show, :new, :edit]
def index
@user_attribute_models = UserRoleModel.all.entries
render :template => 'admin/user_attribute_models/index'
end
def show
#@user_attribute_model = UserRoleModel.find(params[:id])
end
def new
@user_attribute_model = UserRoleModel.new
render :template => 'admin/user_attribute_models/new'
end
def edit
@user_attribute_model = UserRoleModel.find(params[:id])
@i18n_variable = @user_attribute_model.i18n_variable
render :template => 'admin/user_attribute_models/edit'
end
def create
@user_attribute_model = UserRoleModel.new(params[:user_role_model])
@user_attribute_model.save
redirect_to :action => :index
end
def update
@user_attribute_model = UserRoleModel.find(params[:id])
@user_attribute_model.update_attributes(params[:user_role_model])
respond_to do |format|
format.html { redirect_to :action => :index }
format.js { render 'admin/user_attribute_models/toggle_enable' }
end
end
def destroy
@user_attribute_model = UserRoleModel.find(params[:id])
@user_attribute_model.destroy
@user_attribute_model.destroy_i18n_variables
redirect_to :action => :index
end
protected
def set_attribute
@attribute = 'role'
end
end
+8 -8
View File
@@ -20,13 +20,13 @@ class Admin::UsersController < ApplicationController
def create
@user = User.new(params[:user])
if @user.save
@user.user_infos.each do |user_info|
user_info.save
user_info.attribute_values.each(&:save)
@user.user_infos.each do |info|
info.save
info.attribute_values.each(&:save)
end
@user.user_roles.each do |user_role|
user_role.save
user_role.attribute_values.each(&:save)
@user.roles.each do |role|
role.save
role.attribute_values.each(&:save)
end
flash[:notice] = t('admin.create_success_user')
redirect_to :action => :index
@@ -77,8 +77,8 @@ class Admin::UsersController < ApplicationController
protected
def get_info_role_models
@user_info_models = UserInfoModel.excludes('disabled' => true)
@user_role_models = UserRoleModel.excludes('disabled' => true)
@roles = Info.excludes('disabled' => true)
@infos = Role.excludes('disabled' => true)
end
end