user new interface 70%

This commit is contained in:
Matthew K. Fu JuYuan committed 2012-10-08 16:58:33 +08:00
1 parent 5de433d219
commit e16a27601d
20 files changed
+589 -52

No files matched your search

@@ -32,19 +32,19 @@ class Admin::UsersNewInterfaceController < ApplicationController
@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
@profile_data.push({:name => att_val.attribute_field.title,:value =>att_val.get_value_by_locale(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
@teacher_data.push({:name => att_val.attribute_field.title,:value => att_val.get_value_by_locale(I18n.locale) }) 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
@student_data.push({:name => att_val.attribute_field.title,:value => att_val.get_value_by_locale(I18n.locale) }) 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
@staff_data.push({:name => att_val.attribute_field.title,:value => att_val.get_value_by_locale(I18n.locale) }) if att_val.attribute_field.role.key=="staff_data"rescue false
}
# binding.pry
@@ -81,28 +81,37 @@ class Admin::UsersNewInterfaceController < ApplicationController
end
end
def temp_edit
@user = User.find(params[:id])
@form_index = 0
get_info_and_roles
end
def edit
@user = User.find(params[:id])
@form_index = 0
get_info_and_roles
end
def update
@user = User.find(params[:id])
@user.update_attributes(params[:user])
@user.save
redirect_to :action => :show
# # Update changes to the avatar
# @user.remove_avatar! if params[:file]
# @user.avatar = params[:file] if params[:file]
# Update changes to the avatar
@user.remove_avatar! if params[:file]
@user.avatar = params[:file] if params[:file]
if @user.id.to_s.eql?(session['warden.user.user.key'][1].to_s) && @user.admin != params[:user][:admin].to_i.to_b
flash.now[:error] = t('admin.cant_revoke_self_admin')
end
if !flash[:error] && @user.update_attributes(params[:user])
flash[:notice] = t('admin.update_success_user')
redirect_to :action => :index
else
get_info_and_roles
render :action => :edit
end
# if @user.id.to_s.eql?(session['warden.user.user.key'][1].to_s) && @user.admin != params[:user][:admin].to_i.to_b
# flash.now[:error] = t('admin.cant_revoke_self_admin')
# end
# if !flash[:error] && @user.update_attributes(params[:user])
# flash[:notice] = t('admin.update_success_user')
# redirect_to :action => :index
# else
# get_info_and_roles
# render :action => :edit
# end
end
def destroy