Merge branch 'szzh' into develop
This commit is contained in:
commit
26cb6225c5
|
@ -98,6 +98,7 @@ module Mobile
|
|||
params do
|
||||
requires :token, type: String
|
||||
requires :user_id, type: Integer,desc: '被留言的用户id'
|
||||
requires :page,type:Integer,desc:'请求数据的页码'
|
||||
end
|
||||
get ':user_id/messages' do
|
||||
us = UsersService.new
|
||||
|
|
|
@ -29,51 +29,43 @@ class AvatarController < ApplicationController
|
|||
end
|
||||
|
||||
if @temp_file && (@temp_file.size > 0)
|
||||
if @temp_file.size > Setting.upload_avatar_max_size.to_i
|
||||
@status = 1
|
||||
@msg = l(:error_upload_avatar_to_large, :max_size => number_to_human_size(Setting.upload_avatar_max_size.to_i))
|
||||
elsif Trustie::Utils::Image.new(@temp_file.tempfile.path).image?
|
||||
diskfile=disk_filename(@source_type,@source_id)
|
||||
@urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),avatar_filename(@source_id,@image_file))
|
||||
diskfile=disk_filename(@source_type,@source_id)
|
||||
@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)")
|
||||
path = File.dirname(diskfile)
|
||||
unless File.directory?(path)
|
||||
FileUtils.mkdir_p(path)
|
||||
end
|
||||
md5 = Digest::MD5.new
|
||||
File.open(diskfile, "wb") do |f|
|
||||
if @temp_file.respond_to?(:read)
|
||||
buffer = ""
|
||||
while (buffer = @temp_file.read(8192))
|
||||
f.write(buffer)
|
||||
md5.update(buffer)
|
||||
end
|
||||
else
|
||||
f.write(@temp_file)
|
||||
md5.update(@temp_file)
|
||||
end
|
||||
end
|
||||
|
||||
Trustie::Utils::Image.new(diskfile,true).compress(300)
|
||||
@status = 0
|
||||
@msg = ''
|
||||
else
|
||||
@status = 2
|
||||
@msg = l(:not_valid_image_file)
|
||||
# 用户头像上传时进行特别处理
|
||||
if @source_type == 'User'
|
||||
diskfile += "temp"
|
||||
@urlfile += "temp"
|
||||
end
|
||||
|
||||
logger.info("Saving avatar '#{diskfile}' (#{@temp_file.size} bytes)")
|
||||
path = File.dirname(diskfile)
|
||||
unless File.directory?(path)
|
||||
FileUtils.mkdir_p(path)
|
||||
end
|
||||
md5 = Digest::MD5.new
|
||||
File.open(diskfile, "wb") do |f|
|
||||
if @temp_file.respond_to?(:read)
|
||||
buffer = ""
|
||||
while (buffer = @temp_file.read(8192))
|
||||
f.write(buffer)
|
||||
md5.update(buffer)
|
||||
end
|
||||
else
|
||||
f.write(@temp_file)
|
||||
md5.update(@temp_file)
|
||||
end
|
||||
end
|
||||
# self.digest = md5.hexdigest
|
||||
end
|
||||
@temp_file = nil
|
||||
|
||||
image = Trustie::Utils::Image.new(diskfile,true)
|
||||
image.compress(300)
|
||||
|
||||
respond_to do |format|
|
||||
format.json{
|
||||
render :inline => {status: @status, message:@msg, url:"#{@urlfile.to_s}?#{Time.now.to_i}"}.to_json,:content_type => 'text/html'
|
||||
render :inline => "#{@urlfile.to_s}?#{Time.now.to_i}",:content_type => 'text/html'
|
||||
return
|
||||
}
|
||||
format.js
|
||||
|
|
|
@ -158,7 +158,7 @@ class UsersService
|
|||
# 获取某个用户的所有留言信息
|
||||
def get_all_messages params
|
||||
user = User.find(params[:user_id])
|
||||
jours = user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||
jours = user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC').page(params[:page] || 1).per(10)
|
||||
jours.update_all(:is_readed => true, :status => false)
|
||||
jours.each do |journal|
|
||||
fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<script>
|
||||
$(function(){
|
||||
$("input[nhname='nhname']").change(function(){
|
||||
$("input[nhname='date_show']").change(function(){
|
||||
if($(this).val()=='创建日期起始' || $(this).val()=='创建日期结束')return;
|
||||
$("input[nhname='nhname']",$(this).parent('div')).val($(this).val());
|
||||
$("input[nhname='date_val']",$(this).parent('div')).val($(this).val());
|
||||
remote_function();
|
||||
});
|
||||
});
|
||||
|
@ -25,6 +25,7 @@
|
|||
}
|
||||
function nh_reset_form() {
|
||||
$("#issue_query_form")[0].reset();
|
||||
$("input[nhname='date_val']").val('');//涛哥的火狐reset 清不掉这个值 我擦
|
||||
remote_function();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue