|
|
|
@ -50,95 +50,34 @@ class MyController < ApplicationController
|
|
|
|
|
def account
|
|
|
|
|
@user = User.current
|
|
|
|
|
@pref = @user.pref
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# if @user.user_extensions.nil?
|
|
|
|
|
# se = UserExtebsions.new
|
|
|
|
|
# se.user_id = @user.id
|
|
|
|
|
# se.occupation = params[:occupation]
|
|
|
|
|
# se.save
|
|
|
|
|
# else
|
|
|
|
|
# # = @user.user_extensions
|
|
|
|
|
# end
|
|
|
|
|
# @occupation = UserExtensions.occupation
|
|
|
|
|
# @occupation.save
|
|
|
|
|
|
|
|
|
|
if request.post?
|
|
|
|
|
@user.safe_attributes = params[:user]
|
|
|
|
|
@user.pref.attributes = params[:pref]
|
|
|
|
|
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
|
|
|
|
|
unless @user.user_extensions.nil?
|
|
|
|
|
if @user.user_extensions.identity == 2
|
|
|
|
|
@user.firstname = params[:enterprise_name]
|
|
|
|
|
@user.firstname = params[:enterprise_name]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# # UserExtensions.create(:user_id => @user.id, :occupation => params[:occupation])
|
|
|
|
|
# else
|
|
|
|
|
# ue = @user.user_extensions
|
|
|
|
|
# ue.occupation = params[:occupation]
|
|
|
|
|
# ue.save
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
# added by bai
|
|
|
|
|
if @user.user_extensions.nil?
|
|
|
|
|
se = UserExtensions.new
|
|
|
|
|
se.user_id = @user.id
|
|
|
|
|
if params[:occupation]
|
|
|
|
|
se.school_id = params[:occupation]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
se.gender = params[:gender]
|
|
|
|
|
|
|
|
|
|
if params[:province] && params[:city]
|
|
|
|
|
se.location = params[:province]
|
|
|
|
|
se.location_city = params[:city]
|
|
|
|
|
end
|
|
|
|
|
if params[:identity]
|
|
|
|
|
se.identity = params[:identity].to_i
|
|
|
|
|
end
|
|
|
|
|
if params[:technical_title]
|
|
|
|
|
se.technical_title = params[:technical_title]
|
|
|
|
|
end
|
|
|
|
|
if params[:no]
|
|
|
|
|
se.student_id = params[:no]
|
|
|
|
|
end
|
|
|
|
|
se.save
|
|
|
|
|
else
|
|
|
|
|
se = @user.user_extensions
|
|
|
|
|
if params[:occupation]
|
|
|
|
|
se.school_id = params[:occupation]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
se.gender = params[:gender]
|
|
|
|
|
|
|
|
|
|
if params[:province] && params[:city]
|
|
|
|
|
se.location = params[:province]
|
|
|
|
|
se.location_city = params[:city]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if params[:identity]
|
|
|
|
|
se.identity= params[:identity].to_i
|
|
|
|
|
end
|
|
|
|
|
if params[:technical_title]
|
|
|
|
|
se.technical_title = params[:technical_title]
|
|
|
|
|
end
|
|
|
|
|
if params[:no]
|
|
|
|
|
se.student_id = params[:no]
|
|
|
|
|
end
|
|
|
|
|
se.save
|
|
|
|
|
end
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
if @user.save
|
|
|
|
|
|
|
|
|
|
@se = @user.user_extensions ||= UserExtensions.new
|
|
|
|
|
@se.school_id = params[:occupation] if params[:occupation]
|
|
|
|
|
@se.gender = params[:gender]
|
|
|
|
|
@se.location = params[:province] if params[:province]
|
|
|
|
|
@se.location_city = params[:city] if params[:city]
|
|
|
|
|
@se.identity = params[:identity].to_i if params[:identity]
|
|
|
|
|
@se.technical_title = params[:technical_title] if params[:technical_title]
|
|
|
|
|
@se.student_id = params[:no] if params[:no]
|
|
|
|
|
|
|
|
|
|
if @user.save && @se.save
|
|
|
|
|
@user.pref.save
|
|
|
|
|
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
|
|
|
|
|
set_language_if_valid @user.language
|
|
|
|
|
flash[:notice] = l(:notice_account_updated)
|
|
|
|
|
redirect_to user_path(@user)
|
|
|
|
|
return
|
|
|
|
|
else
|
|
|
|
|
@user
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|