Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
b89ff45fc2
|
@ -98,6 +98,7 @@ module Mobile
|
||||||
params do
|
params do
|
||||||
requires :token, type: String
|
requires :token, type: String
|
||||||
requires :user_id, type: Integer,desc: '被留言的用户id'
|
requires :user_id, type: Integer,desc: '被留言的用户id'
|
||||||
|
requires :page,type:Integer,desc:'请求数据的页码'
|
||||||
end
|
end
|
||||||
get ':user_id/messages' do
|
get ':user_id/messages' do
|
||||||
us = UsersService.new
|
us = UsersService.new
|
||||||
|
@ -106,7 +107,7 @@ module Mobile
|
||||||
present :status,0
|
present :status,0
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "给用户留言或回复用户留言"
|
desc "回复用户留言"
|
||||||
params do
|
params do
|
||||||
requires :token, type: String
|
requires :token, type: String
|
||||||
requires :user_id, type: Integer,desc: '被留言的用户id'
|
requires :user_id, type: Integer,desc: '被留言的用户id'
|
||||||
|
@ -115,12 +116,23 @@ module Mobile
|
||||||
requires :parent_id,type:Integer,desc:'留言父id'
|
requires :parent_id,type:Integer,desc:'留言父id'
|
||||||
requires :ref_message_id,type:Integer,desc:'引用消息id'
|
requires :ref_message_id,type:Integer,desc:'引用消息id'
|
||||||
end
|
end
|
||||||
post ':user_id/leave_message' do
|
post ':user_id/reply_message' do
|
||||||
us = UsersService.new
|
us = UsersService.new
|
||||||
jours = us.reply_user_messages params,current_user
|
jours = us.reply_user_messages params,current_user
|
||||||
present :status,0
|
present :status,0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "给用户留言"
|
||||||
|
params do
|
||||||
|
requires :token, type: String
|
||||||
|
requires :user_id, type: Integer,desc:'被留言的用户id'
|
||||||
|
requires :content, type: String,desc:'留言内容'
|
||||||
|
end
|
||||||
|
post ':user_id/leave_message' do
|
||||||
|
us = UsersService.new
|
||||||
|
us.leave_message params,current_user
|
||||||
|
present :data,0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,6 +24,7 @@ class AvatarController < ApplicationController
|
||||||
else
|
else
|
||||||
@image_file=params[:filename]
|
@image_file=params[:filename]
|
||||||
end
|
end
|
||||||
|
@temp_file = StringIO.new(@temp_file)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -32,7 +33,7 @@ class AvatarController < ApplicationController
|
||||||
if @temp_file.size > Setting.upload_avatar_max_size.to_i
|
if @temp_file.size > Setting.upload_avatar_max_size.to_i
|
||||||
@status = 1
|
@status = 1
|
||||||
@msg = l(:error_upload_avatar_to_large, :max_size => number_to_human_size(Setting.upload_avatar_max_size.to_i))
|
@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?
|
elsif Trustie::Utils::Image.new(@temp_file).image?
|
||||||
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))
|
||||||
|
|
||||||
|
@ -50,6 +51,7 @@ class AvatarController < ApplicationController
|
||||||
md5 = Digest::MD5.new
|
md5 = Digest::MD5.new
|
||||||
File.open(diskfile, "wb") do |f|
|
File.open(diskfile, "wb") do |f|
|
||||||
if @temp_file.respond_to?(:read)
|
if @temp_file.respond_to?(:read)
|
||||||
|
@temp_file.rewind
|
||||||
buffer = ""
|
buffer = ""
|
||||||
while (buffer = @temp_file.read(8192))
|
while (buffer = @temp_file.read(8192))
|
||||||
f.write(buffer)
|
f.write(buffer)
|
||||||
|
|
|
@ -9,11 +9,15 @@ class ZipdownController < ApplicationController
|
||||||
|
|
||||||
#统一下载功能
|
#统一下载功能
|
||||||
def download
|
def download
|
||||||
|
if User.current.logged?
|
||||||
begin
|
begin
|
||||||
send_file "#{OUTPUT_FOLDER}/#{params[:file]}", :filename => params[:filename], :type => detect_content_type(params[:file])
|
send_file "#{OUTPUT_FOLDER}/#{params[:file]}", :filename => params[:filename], :type => detect_content_type(params[:file])
|
||||||
rescue => e
|
rescue => e
|
||||||
render file: 'public/no_file_found.html'
|
render file: 'public/no_file_found.html'
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
render_403
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#一个作业下所有文件打包下载,只有admin和课程老师有权限
|
#一个作业下所有文件打包下载,只有admin和课程老师有权限
|
||||||
|
|
|
@ -158,7 +158,7 @@ class UsersService
|
||||||
# 获取某个用户的所有留言信息
|
# 获取某个用户的所有留言信息
|
||||||
def get_all_messages params
|
def get_all_messages params
|
||||||
user = User.find(params[:user_id])
|
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.update_all(:is_readed => true, :status => false)
|
||||||
jours.each do |journal|
|
jours.each do |journal|
|
||||||
fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false)
|
fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false)
|
||||||
|
@ -184,7 +184,11 @@ class UsersService
|
||||||
user.add_jour(nil, nil,nil,options)
|
user.add_jour(nil, nil,nil,options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 给用户留言
|
||||||
|
def leave_message params,current_user
|
||||||
|
obj = User.find(params[:user_id]).add_jour(current_user, params[:content], 0)
|
||||||
|
obj
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
#关注列表
|
#关注列表
|
||||||
|
|
|
@ -1,16 +1,9 @@
|
||||||
<script>
|
<script>
|
||||||
$(function(){
|
$(function(){
|
||||||
$("input[nhtype='dateinput']").each(function(){
|
$("input[nhname='date_show']").change(function(){
|
||||||
$(this).attr('readonly',true);
|
if($(this).val()=='创建日期起始' || $(this).val()=='创建日期结束')return;
|
||||||
$(this).datepicker({
|
$("input[nhname='date_val']",$(this).parent('div')).val($(this).val());
|
||||||
dateFormat: 'yy-mm-dd',
|
remote_function();
|
||||||
showButtonPanel: true,showClearButton: true,showTodayButton: true,
|
|
||||||
changeMonth: true,
|
|
||||||
changeYear: true
|
|
||||||
});
|
|
||||||
$(this).change(function(){
|
|
||||||
$("#issue_query_form").submit();
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
function remote_function() {
|
function remote_function() {
|
||||||
|
@ -32,6 +25,7 @@
|
||||||
}
|
}
|
||||||
function nh_reset_form() {
|
function nh_reset_form() {
|
||||||
$("#issue_query_form")[0].reset();
|
$("#issue_query_form")[0].reset();
|
||||||
|
$("input[nhname='date_val']").val('');//涛哥的火狐reset 清不掉这个值 我擦
|
||||||
remote_function();
|
remote_function();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,10 +49,15 @@
|
||||||
<div class="problem_search" >
|
<div class="problem_search" >
|
||||||
<input class="problem_search_input fl" id="v_subject" type="text" name="subject" value="<%= @subject ? @subject : ""%>" onkeypress="EnterPress(event)" onkeydown="EnterPress()">
|
<input class="problem_search_input fl" id="v_subject" type="text" name="subject" value="<%= @subject ? @subject : ""%>" onkeypress="EnterPress(event)" onkeydown="EnterPress()">
|
||||||
<a href="javascript:void(0)" class="problem_search_btn fl" onclick="remote_function();" >搜索</a>
|
<a href="javascript:void(0)" class="problem_search_btn fl" onclick="remote_function();" >搜索</a>
|
||||||
<!--<a href="javascript:void(0)" class="problem_search_btn fl" onclick="nh_reset_form();" >清空</a>-->
|
<a href="javascript:void(0)" class="grey_btn fl ml10" onclick="nh_reset_form();" >清空</a>
|
||||||
</div><!--problem_search end-->
|
</div><!--problem_search end-->
|
||||||
|
<%= link_to '新建问题', new_project_issue_path(@project) , :class => "green_u_btn fr ml10" %>
|
||||||
|
<p class="problem_p fr" ><%= l(:label_issues_sum) %>:<a href="javascript:void(0)" class="c_red"><%= @project.issues.visible.all.count %></a>
|
||||||
|
<%= l(:lable_issues_undo) %>:<a href="javascript:void(0)" class="c_red"><%= @project.issues.where('status_id in (1,2,4,6)').visible.all.count %> </a>
|
||||||
|
</p>
|
||||||
|
|
||||||
<div id="filter_form" class="fr" >
|
<div class="cl"></div>
|
||||||
|
<div id="filter_form" class="fl">
|
||||||
|
|
||||||
<%= select( :issue, :user_id, principals_options_for_isuue_list(@project),
|
<%= select( :issue, :user_id, principals_options_for_isuue_list(@project),
|
||||||
{ :include_blank => false,:selected=>@assign_to_id ? @assign_to_id : 0
|
{ :include_blank => false,:selected=>@assign_to_id ? @assign_to_id : 0
|
||||||
|
@ -85,24 +84,22 @@
|
||||||
)
|
)
|
||||||
%>
|
%>
|
||||||
</div><!--filter_form end-->
|
</div><!--filter_form end-->
|
||||||
|
<div>
|
||||||
|
<div class="fl"> </div>
|
||||||
|
<div>
|
||||||
|
<input name="issue_create_date_start" nhname="date_val" type="hidden"/>
|
||||||
|
<%= text_field_tag 'issue_create_date_start_show', '创建日期起始',:readonly=>true, :size=>15, :nhname=>'date_show',:style=>'float:left;'%>
|
||||||
|
<%= calendar_for('issue_create_date_start_show') %>
|
||||||
|
</div>
|
||||||
|
<div style="float:left;"> - </div>
|
||||||
|
<div>
|
||||||
|
<input name="issue_create_date_end" nhname="date_val" type="hidden"/>
|
||||||
|
<%= text_field_tag 'issue_create_date_end_show', '创建日期结束',:readonly=>true, :size=>15, :nhname=>'date_show',:style=>'float:left;'%>
|
||||||
|
<%= calendar_for('issue_create_date_end_show') %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<!--<div>-->
|
|
||||||
<!--<div style="float:left;">创建时间 : </div>-->
|
|
||||||
<!--<div>-->
|
|
||||||
<!--<%#= text_field_tag 'issue_create_date_start', '',:readonly=>true, :size=>15, :onchange => "remote_function()",:style=>'float:left;'%>-->
|
|
||||||
<!--<%#= calendar_for('issue_create_date_start') %>-->
|
|
||||||
<!--</div>-->
|
|
||||||
<!--<div style="float:left;"> - </div>-->
|
|
||||||
<!--<div>-->
|
|
||||||
<!--<%#= text_field_tag 'issue_create_date_end', '',:readonly=>true, :size=>15, :onchange => "remote_function()",:style=>'float:left;'%>-->
|
|
||||||
<!--<%#= calendar_for('issue_create_date_end') %>-->
|
|
||||||
<!--</div>-->
|
|
||||||
<!--</div>-->
|
|
||||||
<!--<div class="cl"></div>-->
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<p class="problem_p fl" ><%= l(:label_issues_sum) %>:<a href="javascript:void(0)" class="c_red"><%= @project.issues.visible.all.count %></a>
|
|
||||||
<%= l(:lable_issues_undo) %>:<a href="javascript:void(0)" class="c_red"><%= @project.issues.where('status_id in (1,2,4,6)').visible.all.count %> </a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -2,3 +2,4 @@
|
||||||
$('#message_quote').html("<%= raw escape_javascript(@temp.content.html_safe) %>");
|
$('#message_quote').html("<%= raw escape_javascript(@temp.content.html_safe) %>");
|
||||||
$('#quote').val("<%= raw escape_javascript(@content) %>");
|
$('#quote').val("<%= raw escape_javascript(@content) %>");
|
||||||
showAndScrollTo("new_memo", "cke_editor01");
|
showAndScrollTo("new_memo", "cke_editor01");
|
||||||
|
$("img").removeAttr("align");
|
|
@ -182,4 +182,5 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
$("img").removeAttr("align");
|
||||||
</script>
|
</script>
|
|
@ -15,6 +15,11 @@
|
||||||
<p style="padding-left: 180px;"><%= setting_text_field :activity_days_default, :size => 6 %> <%= l(:label_day_plural) %></p>
|
<p style="padding-left: 180px;"><%= setting_text_field :activity_days_default, :size => 6 %> <%= l(:label_day_plural) %></p>
|
||||||
|
|
||||||
<p style="padding-left: 180px;"><%= setting_text_field :host_name, :size => 60 %>
|
<p style="padding-left: 180px;"><%= setting_text_field :host_name, :size => 60 %>
|
||||||
|
<p style="padding-left: 180px;"><%= setting_text_field :host_course, :size => 60 %>
|
||||||
|
<p style="padding-left: 180px;"><%= setting_text_field :host_contest, :size => 60 %>
|
||||||
|
<p style="padding-left: 180px;"><%= setting_text_field :host_user, :size => 60 %>
|
||||||
|
<p style="padding-left: 180px;"><%= setting_text_field :host_repository, :size => 60 %>
|
||||||
|
|
||||||
<em class="info"><%= l(:label_example) %>: <%= @guessed_host_and_path %></em></p>
|
<em class="info"><%= l(:label_example) %>: <%= @guessed_host_and_path %></em></p>
|
||||||
|
|
||||||
<p style="padding-left: 180px;"><%= setting_select :protocol, [['HTTP', 'http'], ['HTTPS', 'https']] %></p>
|
<p style="padding-left: 180px;"><%= setting_select :protocol, [['HTTP', 'http'], ['HTTPS', 'https']] %></p>
|
||||||
|
|
|
@ -183,6 +183,10 @@ en:
|
||||||
setting_bcc_recipients: Blind carbon copy recipients (bcc)
|
setting_bcc_recipients: Blind carbon copy recipients (bcc)
|
||||||
setting_plain_text_mail: Plain text mail (no HTML)
|
setting_plain_text_mail: Plain text mail (no HTML)
|
||||||
setting_host_name: Host name and path
|
setting_host_name: Host name and path
|
||||||
|
setting_host_course: Host course and path
|
||||||
|
setting_host_contest: Host contest and path
|
||||||
|
setting_host_user: Host user and path
|
||||||
|
setting_host_repository: Host repository and path
|
||||||
setting_text_formatting: Text formatting
|
setting_text_formatting: Text formatting
|
||||||
setting_wiki_compression: Wiki history compression
|
setting_wiki_compression: Wiki history compression
|
||||||
setting_feeds_limit: Maximum number of items in Atom feeds
|
setting_feeds_limit: Maximum number of items in Atom feeds
|
||||||
|
|
|
@ -190,6 +190,10 @@ zh:
|
||||||
setting_bcc_recipients: 使用密件抄送 (bcc)
|
setting_bcc_recipients: 使用密件抄送 (bcc)
|
||||||
setting_plain_text_mail: 纯文本(无HTML)
|
setting_plain_text_mail: 纯文本(无HTML)
|
||||||
setting_host_name: 主机名称
|
setting_host_name: 主机名称
|
||||||
|
setting_host_course: 课程域名
|
||||||
|
setting_host_contest: 竞赛域名
|
||||||
|
setting_host_user: 用户域名
|
||||||
|
setting_host_repository: 仓库域名
|
||||||
setting_text_formatting: 文本格式
|
setting_text_formatting: 文本格式
|
||||||
setting_wiki_compression: 压缩Wiki历史文档
|
setting_wiki_compression: 压缩Wiki历史文档
|
||||||
setting_feeds_limit: RSS Feed内容条数限制
|
setting_feeds_limit: RSS Feed内容条数限制
|
||||||
|
|
10
db/schema.rb
10
db/schema.rb
|
@ -659,6 +659,16 @@ ActiveRecord::Schema.define(:version => 20150514133640) do
|
||||||
|
|
||||||
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
|
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
|
||||||
|
|
||||||
|
create_table "journal_details_copy", :force => true do |t|
|
||||||
|
t.integer "journal_id", :default => 0, :null => false
|
||||||
|
t.string "property", :limit => 30, :default => "", :null => false
|
||||||
|
t.string "prop_key", :limit => 30, :default => "", :null => false
|
||||||
|
t.text "old_value"
|
||||||
|
t.text "value"
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id"
|
||||||
|
|
||||||
create_table "journal_replies", :id => false, :force => true do |t|
|
create_table "journal_replies", :id => false, :force => true do |t|
|
||||||
t.integer "journal_id"
|
t.integer "journal_id"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
|
|
|
@ -17,21 +17,20 @@ module Trustie
|
||||||
end
|
end
|
||||||
|
|
||||||
def jpeg?(data)
|
def jpeg?(data)
|
||||||
data[0,4]== 0xff.chr + 0xd8.chr + 0xff.chr + 0xe0.chr
|
data[0,3]== 0xff.chr + 0xd8.chr + 0xff.chr
|
||||||
end
|
end
|
||||||
def png?(data)
|
def png?(data)
|
||||||
data[0,2]==0x89.chr + 80.chr
|
data[0,2]==0x89.chr + 80.chr
|
||||||
end
|
end
|
||||||
|
|
||||||
def image?
|
def image?
|
||||||
begin
|
data = ''
|
||||||
f = File.open(@file,'rb') # rb means to read using binary
|
if @file.respond_to?(:read)
|
||||||
return false if f.size < 9
|
data = @file.read(9)
|
||||||
data = f.read(9) # magic numbers are up to 9 bytes
|
@file.rewind
|
||||||
return bitmap?(data) || gif?(data) || jpeg?(data) || png?(data)
|
|
||||||
ensure
|
|
||||||
f.close
|
|
||||||
end
|
end
|
||||||
|
return false if data.size < 9
|
||||||
|
bitmap?(data) || gif?(data) || jpeg?(data) || png?(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def compress(size=300)
|
def compress(size=300)
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe "avatar request", type: :request do
|
||||||
|
describe "上传头像" do
|
||||||
|
let(:user){FactoryGirl.create(:user)}
|
||||||
|
|
||||||
|
it "参数正确,可以成功上传头像" do
|
||||||
|
data = File.open("#{Rails.root}/spec/fixtures/test.jpg").read
|
||||||
|
binding.pry
|
||||||
|
post upload_avatar_path(source_type: 'User', source_id: user.id, filename: 'test.jpg')
|
||||||
|
expect(response).to have_http_status(:success)
|
||||||
|
expect(response.body).to include(/\/images\/avatars\/User\//)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue