basic function

This commit is contained in:
Matthew K. Fu JuYuan authored and Christophe Vilayphiou committed 2012-09-17 13:32:52 +08:00
1 parent 9eed9ec7b6
commit 19db9d0037
26 files changed
+420 -185

No files matched your search

@@ -5,20 +5,63 @@ class Admin::UsersNewInterfaceController < ApplicationController
before_filter :set_attribute, :only => [:index, :show, :new, :edit]
def index
@users = User.all.entries
get_tags
get_sub_roles
page_num = params[:page] || 1
@users = []
render case params[:at]
when 'summary'
@users=User.page(page_num).per(12).includes('avatar')
"index_summary"
when 'thumbnail'
@users=User.page(page_num).per(36).includes('avatar')
"index_thumbnail"
else
@users=User.page(page_num).per(10).includes('avatar')
"index"
end
end
def show
@user = User.find(params[:id])
@profile_data = []
@teacher_data = []
@student_data = []
@staff_data = []
@user.attribute_values.each{|att_val|
@profile_data.push({:name => att_val.attribute_field.title,:value =>att_val[I18n.locale]}) if att_val.attribute_field.attribute.key=="profile" rescue false
}
@user.attribute_values.each{|att_val|
@teacher_data.push({:name => att_val.attribute_field.title,:value => eval("att_val.#{att_val.key}")}) if att_val.attribute_field.role.key=="teacher"rescue false
}
@user.attribute_values.each{|att_val|
@student_data.push({:name => att_val.attribute_field.title,:value =>eval("att_val.#{att_val.key}")}) if att_val.attribute_field.role.key=="student"rescue false
}
@user.attribute_values.each{|att_val|
@staff_data.push({:name => att_val.attribute_field.title,:value =>eval("att_val.#{att_val.key}")}) if att_val.attribute_field.role.key=="staff_data"rescue false
}
# binding.pry
# @user.attribute_values.each{|att_val|
# @teacher_data.push({:name => att_val.attribute_field.title,:value =>att_val[I18n.locale]})
# }
# @user.attribute_values.each{|att_val|
# @student_data.push({:name => att_val.attribute_field.title,:value =>att_val[I18n.locale]})
# }
# @user.attribute_values.each{|att_val|
# @staff_data.push({:name => att_val.attribute_field.title,:value =>att_val[I18n.locale]})
# }
# [ {:name=> "1",:value =>"Matt"},{:name=> "2",:value =>"Mark"},{:name=> "3",:value =>"Luke"},{:name=> "4",:value =>"John"} ]
get_info_and_roles
end
@@ -74,7 +117,14 @@ class Admin::UsersNewInterfaceController < ApplicationController
end
protected
def get_tags
@sub_role_tags = SubRoleTag.all
end
def get_sub_roles
@sub_roles = SubRole.all
end
def get_info_and_roles
@infos = Info.excludes('disabled' => true)
@roles = Role.excludes('disabled' => true)