Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
54ed41e483
|
@ -28,6 +28,13 @@ class AvatarController < ApplicationController
|
||||||
if @temp_file && (@temp_file.size > 0)
|
if @temp_file && (@temp_file.size > 0)
|
||||||
diskfile=disk_filename(@source_type,@source_id)
|
diskfile=disk_filename(@source_type,@source_id)
|
||||||
@urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),avatar_filename(@source_id,@image_file))
|
@urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),avatar_filename(@source_id,@image_file))
|
||||||
|
|
||||||
|
# 用户头像上传时进行特别处理
|
||||||
|
if @source_type == 'User'
|
||||||
|
diskfile += "temp"
|
||||||
|
@urlfile += "temp"
|
||||||
|
end
|
||||||
|
|
||||||
logger.info("Saving avatar '#{diskfile}' (#{@temp_file.size} bytes)")
|
logger.info("Saving avatar '#{diskfile}' (#{@temp_file.size} bytes)")
|
||||||
path = File.dirname(diskfile)
|
path = File.dirname(diskfile)
|
||||||
unless File.directory?(path)
|
unless File.directory?(path)
|
||||||
|
@ -96,7 +103,16 @@ class AvatarController < ApplicationController
|
||||||
unless diskfile.nil? || diskfile == ""
|
unless diskfile.nil? || diskfile == ""
|
||||||
path = File.dirname(diskfile)
|
path = File.dirname(diskfile)
|
||||||
if File.directory?(path) && File.exist?(diskfile)
|
if File.directory?(path) && File.exist?(diskfile)
|
||||||
File.delete(diskfile)
|
# 用户头像进行特别处理
|
||||||
|
if @source_type == 'User'
|
||||||
|
diskfile1 = diskfile + 'temp'
|
||||||
|
File.open(diskfile1, "wb") do |f|
|
||||||
|
buffer = "DELETE"
|
||||||
|
f.write(buffer)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
File.delete(diskfile)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue e do
|
rescue e do
|
||||||
|
|
|
@ -76,6 +76,8 @@ class MyController < ApplicationController
|
||||||
def account
|
def account
|
||||||
@user = User.current
|
@user = User.current
|
||||||
@pref = @user.pref
|
@pref = @user.pref
|
||||||
|
diskfile = disk_filename('User', @user.id)
|
||||||
|
diskfile1 = diskfile + 'temp'
|
||||||
if request.post?
|
if request.post?
|
||||||
@user.safe_attributes = params[:user]
|
@user.safe_attributes = params[:user]
|
||||||
@user.pref.attributes = params[:pref]
|
@user.pref.attributes = params[:pref]
|
||||||
|
@ -97,6 +99,33 @@ class MyController < ApplicationController
|
||||||
@se.student_id = params[:no] if params[:no]
|
@se.student_id = params[:no] if params[:no]
|
||||||
|
|
||||||
if @user.save && @se.save
|
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.pref.save
|
||||||
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
|
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
|
||||||
set_language_if_valid @user.language
|
set_language_if_valid @user.language
|
||||||
|
@ -104,8 +133,17 @@ class MyController < ApplicationController
|
||||||
redirect_to user_path(@user)
|
redirect_to user_path(@user)
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
|
# 确保文件被删除
|
||||||
|
if File.exist?(diskfile1)
|
||||||
|
File.delete(diskfile1)
|
||||||
|
end
|
||||||
@user
|
@user
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
# 确保文件被删除
|
||||||
|
if File.exist?(diskfile1)
|
||||||
|
File.delete(diskfile1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -27,14 +27,15 @@
|
||||||
<p><label><%= l(:label_board) %></label><br />
|
<p><label><%= l(:label_board) %></label><br />
|
||||||
<%# modify by nwb%>
|
<%# modify by nwb%>
|
||||||
<% if @message.project %>
|
<% if @message.project %>
|
||||||
<%= f.select :board_id, boards_options_for_select(@message.project.boards) %></p>
|
<%= f.select :board_id, boards_options_for_select(@message.project.boards) %>
|
||||||
<% elsif @message.course %>
|
<% elsif @message.course %>
|
||||||
<%= f.select :board_id, boards_options_for_select(@message.course.boards) %></p>
|
<%= f.select :board_id, boards_options_for_select(@message.course.boards) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div id="message_quote" class="wiki" style="width: 100%;word-break: break-all;word-wrap: break-word;"></div>
|
<p><label for="message_subject"><%= l(:field_description) %><span class="required"> * </span></label>
|
||||||
|
<%= text_area :quote,:quote,:style => 'display:none' %>
|
||||||
<%= text_area :quote,:quote,:style => 'display:none' %>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<%= label_tag "message_content", l(:description_message_content), :class => "hidden-for-sighted" %>
|
<%= label_tag "message_content", l(:description_message_content), :class => "hidden-for-sighted" %>
|
||||||
<%= f.text_area :content, :cols => 80, :rows => 13, :class => 'wiki-edit', :id => 'message_content' %></p>
|
<%= f.text_area :content, :cols => 80, :rows => 13, :class => 'wiki-edit', :id => 'message_content' %></p>
|
||||||
|
|
|
@ -276,6 +276,7 @@ zh:
|
||||||
field_is_default: 默认值
|
field_is_default: 默认值
|
||||||
field_tracker: 跟踪
|
field_tracker: 跟踪
|
||||||
field_subject: 主题
|
field_subject: 主题
|
||||||
|
field_quote: 描述
|
||||||
field_due_date: 计划完成日期
|
field_due_date: 计划完成日期
|
||||||
field_assigned_to: 指派给
|
field_assigned_to: 指派给
|
||||||
field_priority: 优先级
|
field_priority: 优先级
|
||||||
|
|
Loading…
Reference in New Issue