|
|
|
@ -76,6 +76,8 @@ class MyController < ApplicationController
|
|
|
|
|
def account
|
|
|
|
|
@user = User.current
|
|
|
|
|
@pref = @user.pref
|
|
|
|
|
diskfile = disk_filename('User', @user.id)
|
|
|
|
|
diskfile1 = diskfile + 'temp'
|
|
|
|
|
if request.post?
|
|
|
|
|
@user.safe_attributes = params[:user]
|
|
|
|
|
@user.pref.attributes = params[:pref]
|
|
|
|
@ -97,6 +99,33 @@ class MyController < ApplicationController
|
|
|
|
|
@se.student_id = params[:no] if params[:no]
|
|
|
|
|
|
|
|
|
|
if @user.save && @se.save
|
|
|
|
|
# 头像保存
|
|
|
|
|
if File.exist?(diskfile1)
|
|
|
|
|
if File.exist?(diskfile)
|
|
|
|
|
File.delete(diskfile)
|
|
|
|
|
end
|
|
|
|
|
File.open(diskfile1, "rb") do |f|
|
|
|
|
|
buffer = f.read(10)
|
|
|
|
|
if buffer != "DELETE"
|
|
|
|
|
File.open(diskfile1, "rb") do |f1|
|
|
|
|
|
File.open(diskfile, "wb") do |f|
|
|
|
|
|
buffer = ""
|
|
|
|
|
while (buffer = f1.read(8192))
|
|
|
|
|
f.write(buffer)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# File.rename(diskfile + 'temp',diskfile);
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 确保文件被删除
|
|
|
|
|
if File.exist?(diskfile1)
|
|
|
|
|
File.delete(diskfile1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@user.pref.save
|
|
|
|
|
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
|
|
|
|
|
set_language_if_valid @user.language
|
|
|
|
@ -104,8 +133,17 @@ class MyController < ApplicationController
|
|
|
|
|
redirect_to user_path(@user)
|
|
|
|
|
return
|
|
|
|
|
else
|
|
|
|
|
# 确保文件被删除
|
|
|
|
|
if File.exist?(diskfile1)
|
|
|
|
|
File.delete(diskfile1)
|
|
|
|
|
end
|
|
|
|
|
@user
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
# 确保文件被删除
|
|
|
|
|
if File.exist?(diskfile1)
|
|
|
|
|
File.delete(diskfile1)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|