Merge branch 'hjq_new_course' into develop

This commit is contained in:
huang 2016-03-17 16:02:50 +08:00
commit 6f356d2595
30 changed files with 421 additions and 283 deletions

View File

@ -572,6 +572,15 @@ class AttachmentsController < ApplicationController
end end
end end
#找到文件的所有的历史版本及当前版本
def attachment_history_download
@attachment = Attachment.find(params[:id])
@attachment_histories = @attachment.attachment_histories
respond_to do |format|
format.js
end
end
private private
def find_project def find_project
@attachment = Attachment.find(params[:id]) @attachment = Attachment.find(params[:id])

View File

@ -110,8 +110,7 @@ class UsersController < ApplicationController
elsif @user != User.current && !User.current.admin? elsif @user != User.current && !User.current.admin?
return render_403 return render_403
end end
# 初始化/更新 点击按钮时间 # 初始化/更新 点击按钮时间, 24小时内显示系统消息
# 24小时内显示系统消息
update_onclick_time update_onclick_time
# 全部设为已读 # 全部设为已读
if params[:viewed] == "all" if params[:viewed] == "all"
@ -190,17 +189,19 @@ class UsersController < ApplicationController
# 消息设置为已读 # 消息设置为已读
def update_message_viewed(user) def update_message_viewed(user)
if User.current.id == @user.id
course_querys = CourseMessage.where("user_id =? and viewed =?", user, 0) course_querys = CourseMessage.where("user_id =? and viewed =?", user, 0)
forge_querys = ForgeMessage.where("user_id =? and viewed =?", user, 0) forge_querys = ForgeMessage.where("user_id =? and viewed =?", user, 0)
user_querys = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0) user_querys = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0)
forum_querys = MemoMessage.where("user_id =? and viewed =?", user, 0) forum_querys = MemoMessage.where("user_id =? and viewed =?", user, 0)
org_querys = OrgMessage.where("user_id=? and viewed=0", user) org_querys = OrgMessage.where("user_id=? and viewed=0", user)
if User.current.id == @user.id at_querys = AtMessage.where("user_id=? and viewed=0", user)
course_querys.update_all(:viewed => true) course_querys.update_all(:viewed => true) unless course_querys.nil?
forge_querys.update_all(:viewed => true) forge_querys.update_all(:viewed => true) unless forge_querys.nil?
user_querys.update_all(:viewed => true) user_querys.update_all(:viewed => true) unless user_querys.nil?
forum_querys.update_all(:viewed => true) forum_querys.update_all(:viewed => true) unless forum_querys.nil?
org_querys.update_all(:viewed => true) org_querys.update_all(:viewed => true) unless org_querys.nil?
at_querys.update_all(:viewed => true) unless at_querys.nil?
end end
end end
@ -823,20 +824,33 @@ class UsersController < ApplicationController
user_course_ids = User.current.courses.map { |c| c.id} user_course_ids = User.current.courses.map { |c| c.id}
user_project_ids = User.current.projects.map {|p| p.id} user_project_ids = User.current.projects.map {|p| p.id}
# user_org_ids = User.current.organizations.map {|o| o.id} # user_org_ids = User.current.organizations.map {|o| o.id}
if(params[:type].blank? || params[:type] == "1") #全部 if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, params[:order]) if params[:status] == "2"
elsif params[:type] == "2" # 课程资源 @attachments = get_course_resources(params[:id], user_course_ids, @order, @score)
@attachments = get_course_resources(params[:id], user_course_ids, params[:order]) elsif params[:status] == "3"
elsif params[:type] == "3" # 项目资源 @attachments = get_project_resources(params[:id], user_project_ids, @order, @score)
@attachments = get_project_resources(params[:id], user_project_ids, params[:order]) elsif params[:status] == "4"
elsif params[:type] == "4" #附件 @attachments = get_attch_resources(params[:id], @order, @score)
@attachments = get_attch_resources params[:id], params[:order] elsif params[:status] == "5"
elsif params[:type] == "5" #用户资源 @attachments = get_principal_resources(params[:id], @order, @score)
@attachments = get_principal_resources params[:id], params[:order] else
elsif params[:type] == "6" # 公共资源
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
end
elsif params[:type] == "6" # 公共资源
if params[:status] == "2"
@attachments = get_course_resources_public( user_course_ids, @order, @score)
elsif params[:status] == "3"
@attachments = get_project_resources_public(user_project_ids, @order, @score)
elsif params[:status] == "4"
@attachments = get_attch_resources_public(@order, @score)
elsif params[:status] == "5"
@attachments = get_principal_resources_public(@order, @score)
else
# 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
end
end end
@type = params[:type] @type = params[:type]
@limit = 7 @limit = 7
@ -1548,43 +1562,39 @@ class UsersController < ApplicationController
user_project_ids = User.current.projects.map {|p| p.id} user_project_ids = User.current.projects.map {|p| p.id}
# user_org_ids = User.current.organizations.map {|o| o.id} # user_org_ids = User.current.organizations.map {|o| o.id}
@user = User.find(params[:id]) @user = User.find(params[:id])
#@user.save_attachments(params[:attachments],User.current) # 保存文件
# Container_type为Principal
attach = Attachment.attach_filesex_public(@user, params[:attachments], params[:attachment_type], is_public = true) attach = Attachment.attach_filesex_public(@user, params[:attachments], params[:attachment_type], is_public = true)
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@score = @b_sort == "desc" ? "asc" : "desc"
user_course_ids = User.current.courses.map { |c| c.id}
user_project_ids = User.current.projects.map {|p| p.id}
# user_org_ids = User.current.organizations.map {|o| o.id}
if(params[:type].blank? || params[:type] == "1") # 我的资源 if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
if params[:status] == 2 if params[:status] == "2"
@attachments = get_course_resources(params[:id], user_course_ids, params[:order]) @attachments = get_course_resources(params[:id], user_course_ids, @order, @score)
elsif params[:status] == "3" elsif params[:status] == "3"
@attachments = get_project_resources(params[:id], user_project_ids, params[:order]) @attachments = get_project_resources(params[:id], user_project_ids, @order, @score)
elsif params[:status] == "4" elsif params[:status] == "4"
@attachments = get_attch_resources params[:id], params[:order] @attachments = get_attch_resources(params[:id], @order, @score)
elsif params[:status] == "5" elsif params[:status] == "5"
@attachments = get_principal_resources params[:id], params[:order] @attachments = get_principal_resources(params[:id], @order, @score)
else else
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, params[:order]) @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
end end
elsif params[:type] == "2" # 课程资源
@attachments = get_course_resources(params[:id], user_course_ids, params[:order])
elsif params[:type] == "3" # 项目资源
@attachments = get_project_resources(params[:id], user_project_ids, params[:order])
elsif params[:type] == "4" #附件
@attachments = get_attch_resources params[:id], params[:order]
elsif params[:type] == "5" #用户资源
@attachments = get_principal_resources params[:id], params[:order]
elsif params[:type] == "6" # 公共资源 elsif params[:type] == "6" # 公共资源
if params[:status] == "2" if params[:status] == "2"
@attachments = get_course_resources_public( user_course_ids, params[:order]) @attachments = get_course_resources_public( user_course_ids, @order, @score)
elsif params[:status] == "3" elsif params[:status] == "3"
@attachments = get_project_resources_public(user_project_ids, params[:order]) @attachments = get_project_resources_public(user_project_ids, @order, @score)
elsif params[:status] == "4" elsif params[:status] == "4"
@attachments = get_attch_resources_public params[:order] @attachments = get_attch_resources_public(@order, @score)
elsif params[:status] == "5" elsif params[:status] == "5"
@attachments = get_principal_resources_public params[:order] @attachments = get_principal_resources_public(@order, @score)
else else
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
end end
end end
@status = params[:status] @status = params[:status]
@ -1604,49 +1614,44 @@ class UsersController < ApplicationController
# 删除用户资源,分为批量删除 和 单个删除,只能删除自己上传的资源 # 删除用户资源,分为批量删除 和 单个删除,只能删除自己上传的资源
def user_resource_delete def user_resource_delete
if params[:resource_id].present? if params[:resource_id].present?
Attachment.where("author_id = #{User.current.id}").delete(params[:resource_id]) Attachment.where("author_id =? and id =?", User.current.id, params[:resource_id]).first.destroy
elsif params[:checkbox1].present? elsif params[:checkbox1].present?
params[:checkbox1].each do |id| params[:checkbox1].each do |id|
Attachment.where("author_id = #{User.current.id}").delete(id) Attachment.where("author_id =? and id =?", User.current.id, id).first.destroy
end end
end end
@user = User.current
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@score = @b_sort == "desc" ? "asc" : "desc"
user_course_ids = User.current.courses.map { |c| c.id} user_course_ids = User.current.courses.map { |c| c.id}
user_project_ids = User.current.projects.map {|p| p.id} user_project_ids = User.current.projects.map {|p| p.id}
# user_org_ids = User.current.organizations.map {|o| o.id} # user_org_ids = User.current.organizations.map {|o| o.id}
if(params[:type].blank? || params[:type] == "1") # 我的资源 if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
if params[:status] == 2 if params[:status] == "2"
@attachments = get_course_resources(params[:id], user_course_ids, params[:order]) @attachments = get_course_resources(params[:id], user_course_ids, @order, @score)
elsif params[:status] == "3" elsif params[:status] == "3"
@attachments = get_project_resources(params[:id], user_project_ids, params[:order]) @attachments = get_project_resources(params[:id], user_project_ids, @order, @score)
elsif params[:status] == "4" elsif params[:status] == "4"
@attachments = get_attch_resources params[:id], params[:order] @attachments = get_attch_resources(params[:id], @order, @score)
elsif params[:status] == "5" elsif params[:status] == "5"
@attachments = get_principal_resources params[:id], params[:order] @attachments = get_principal_resources(params[:id], @order, @score)
else else
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, params[:order]) @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
end end
elsif params[:type] == "2" # 课程资源
@attachments = get_course_resources(params[:id], user_course_ids, params[:order])
elsif params[:type] == "3" # 项目资源
@attachments = get_project_resources(params[:id], user_project_ids, params[:order])
elsif params[:type] == "4" #附件
@attachments = get_attch_resources params[:id], params[:order]
elsif params[:type] == "5" #用户资源
@attachments = get_principal_resources params[:id], params[:order]
elsif params[:type] == "6" # 公共资源 elsif params[:type] == "6" # 公共资源
if params[:status] == "2" if params[:status] == "2"
@attachments = get_course_resources_public( user_course_ids, params[:order]) @attachments = get_course_resources_public( user_course_ids, @order, @score)
elsif params[:status] == "3" elsif params[:status] == "3"
@attachments = get_project_resources_public(user_project_ids, params[:order]) @attachments = get_project_resources_public(user_project_ids, @order, @score)
elsif params[:status] == "4" elsif params[:status] == "4"
@attachments = get_attch_resources_public params[:order] @attachments = get_attch_resources_public(@order, @score)
elsif params[:status] == "5" elsif params[:status] == "5"
@attachments = get_principal_resources_public params[:order] @attachments = get_principal_resources_public(@order, @score)
else else
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
end end
end end
@status = params[:status] @status = params[:status]
@ -1669,10 +1674,10 @@ class UsersController < ApplicationController
if !params[:search].nil? if !params[:search].nil?
search = "%#{params[:search].to_s.strip.downcase}%" search = "%#{params[:search].to_s.strip.downcase}%"
@course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search) @course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search)
.select { |course| @user.allowed_to?(:as_teacher,course)} .select { |course| @user.allowed_to?(:as_teacher,course) and course.is_delete == 0 }
else else
@course = @user.courses @course = @user.courses
.select { |course| @user.allowed_to?(:as_teacher,course)} .select { |course| @user.allowed_to?(:as_teacher,course) and course.is_delete == 0 }
end end
@search = params[:search] @search = params[:search]
#这里仅仅是传递需要发送的资源id #这里仅仅是传递需要发送的资源id
@ -1690,7 +1695,7 @@ class UsersController < ApplicationController
search = "%#{params[:search].to_s.strip.downcase}%" search = "%#{params[:search].to_s.strip.downcase}%"
@projects = @user.projects.where(" #{Project.table_name}.id = #{params[:search].to_i } or #{Project.table_name}.name like :p",:p=>search) @projects = @user.projects.where(" #{Project.table_name}.id = #{params[:search].to_i } or #{Project.table_name}.name like :p",:p=>search)
else else
@projects = @user.projects @projects = @user.projects.visible
end end
@search = params[:search] @search = params[:search]
#这里仅仅是传递需要发送的资源id #这里仅仅是传递需要发送的资源id
@ -2338,6 +2343,11 @@ class UsersController < ApplicationController
attachments = Attachment.where("(is_publish = 1 and is_public =1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) ").order("#{order.nil? ? 'created_on' : order} #{score}") attachments = Attachment.where("(is_publish = 1 and is_public =1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) ").order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取公共资源搜索
def get_public_resources_search user_course_ids, user_project_ids, order, score, search
attachments = Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)" ,:p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我的资源 # 获取我的资源
def get_my_resources author_id, user_course_ids, user_project_ids, order, score def get_my_resources author_id, user_course_ids, user_project_ids, order, score
attachments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ attachments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@ -2347,7 +2357,7 @@ class UsersController < ApplicationController
# 获取我的资源查询结果 # 获取我的资源查询结果
def get_my_resources_search (author_id, user_course_ids, user_project_ids, order, score, search) def get_my_resources_search (author_id, user_course_ids, user_project_ids, order, score, search)
@attachments = Attachment.where("((author_id = #{params[:id]} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ @attachments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" + "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" +
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("#{order.nil? ? 'created_on' : order} #{score}") "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
end end
@ -2359,11 +2369,23 @@ class UsersController < ApplicationController
and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}") and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取公共资源课程 # 获取我的课程资源中搜索结果
def get_course_resources_search author_id, user_course_ids, order, score, search
attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Course')"+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})
and is_publish = 1 and container_id is not null)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取公共资源中课程资源
def get_course_resources_public user_course_ids, order, score def get_course_resources_public user_course_ids, order, score
attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1)").order("#{order.nil? ? 'created_on' : order} #{score}") attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1)").order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取公共资源中课程资源搜索结果
def get_course_resources_public_search user_course_ids, order, score, search
attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我的项目资源 # 获取我的项目资源
def get_project_resources author_id, user_project_ids, order, score def get_project_resources author_id, user_project_ids, order, score
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+ attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+
@ -2371,25 +2393,55 @@ class UsersController < ApplicationController
and is_publish = 1 and container_id is not null)").order("#{order.nil? ? 'created_on' : order} #{score}") and is_publish = 1 and container_id is not null)").order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取我的项目资源搜索
def get_project_resources_search author_id, user_project_ids, order, score, search
attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')})
and is_publish = 1 and container_id is not null)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取公共资源的项目资源 # 获取公共资源的项目资源
def get_project_resources_public user_project_ids, order, score def get_project_resources_public user_project_ids, order, score
attchments = Attachment.where("container_type = 'Project' and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}") attchments = Attachment.where("container_type = 'Project' and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取公共资源的项目资源搜索
def get_project_resources_public_search user_project_ids, order, score, search
attchments = Attachment.where("(container_type = 'Project' and container_id is not null and is_public =1) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我上传的附件 # 获取我上传的附件
def get_attch_resources author_id, order, score def get_attch_resources author_id, order, score
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue', attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue',
'Document','Message','News','StudentWorkScore','HomewCommon')) ").order("#{order.nil? ? 'created_on' : order} #{score}") 'Document','Message','News','StudentWorkScore','HomewCommon'))").order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我上传的附件搜索结果
def get_attch_resources_search author_id, order, score, search
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue',
'Document','Message','News','StudentWorkScore','HomewCommon')) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取公共资源中我上传的附件 # 获取公共资源中我上传的附件
def get_attch_resources_public order, score def get_attch_resources_public order, score
attchments = Attachment.where("container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal') and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}") attchments = Attachment.where("container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')
and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取公共资源中我上传的附件
def get_attch_resources_public_search order, score, search
attchments = Attachment.where("(container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')
and container_id is not null and is_public =1) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取我的用户类型资源 # 获取我的用户类型资源
def get_principal_resources author_id, order, score def get_principal_resources author_id, order, score
attchments = Attachment.where("author_id = #{params[:id]} and is_publish = 1 and container_id is not null and container_type = 'Principal'").order("#{order.nil? ? 'created_on' : order} #{score}") attchments = Attachment.where("author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal'").order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我的用户类型资源搜索
def get_principal_resources_search author_id, order, score, search
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal') and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取我的用户类型资源 # 获取我的用户类型资源
@ -2397,6 +2449,11 @@ class UsersController < ApplicationController
attchments = Attachment.where("container_type = 'Principal'and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}") attchments = Attachment.where("container_type = 'Principal'and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取我的用户类型资源
def get_principal_resources_public_search order, score, search
attchments = Attachment.where("(container_type = 'Principal'and container_id is not null and is_public =1) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 资源库 分为全部 课程资源 项目资源 附件 # 资源库 分为全部 课程资源 项目资源 附件
def user_resource def user_resource
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@ -2423,23 +2480,15 @@ class UsersController < ApplicationController
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score) @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
end end
elsif params[:type] == "2" # 课程资源
@attachments = get_course_resources(params[:id], user_course_ids, params[:order], @score)
elsif params[:type] == "3" # 项目资源
@attachments = get_project_resources(params[:id], user_project_ids, params[:order], @score)
elsif params[:type] == "4" #附件
@attachments = get_attch_resources(params[:id], params[:order], @score)
elsif params[:type] == "5" #用户资源
@attachments = get_principal_resources(params[:id], params[:order], @score)
elsif params[:type] == "6" # 公共资源 elsif params[:type] == "6" # 公共资源
if params[:status] == "2" if params[:status] == "2"
@attachments = get_course_resources_public( user_course_ids, params[:order], @score) @attachments = get_course_resources_public( user_course_ids, @order, @score)
elsif params[:status] == "3" elsif params[:status] == "3"
@attachments = get_project_resources_public(user_project_ids, params[:order], @score) @attachments = get_project_resources_public(user_project_ids, @order, @score)
elsif params[:status] == "4" elsif params[:status] == "4"
@attachments = get_attch_resources_public(params[:order], @score) @attachments = get_attch_resources_public(@order, @score)
elsif params[:status] == "5" elsif params[:status] == "5"
@attachments = get_principal_resources_public(params[:order], @score) @attachments = get_principal_resources_public(@order, @score)
else else
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
@ -2467,16 +2516,19 @@ class UsersController < ApplicationController
render_403 render_403
return return
end end
@user = User.find(params[:id])
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@score = @b_sort == "desc" ? "asc" : "desc"
user_course_ids = User.current.courses.map { |c| c.id} user_course_ids = User.current.courses.map { |c| c.id}
user_project_ids = User.current.projects.map {|p| p.id} user_project_ids = User.current.projects.map {|p| p.id} # user_org_ids = User.current.organizations.map {|o| o.id}
# user_org_ids = User.current.organizations.map {|o| o.id}
if(params[:type].blank? || params[:type] == "1") # 我的资源 if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, params[:order]) @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
elsif params[:type] == "6" # 公共资源 elsif params[:type] == "6" # 公共资源
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
end end
@status = params[:status]
@type = params[:type] @type = params[:type]
@limit = 10 @limit = 10
@is_remote = true @is_remote = true
@ -2492,26 +2544,25 @@ class UsersController < ApplicationController
end end
def import_resources_search def import_resources_search
search = "%#{params[:search].strip.downcase}%" @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@score = @b_sort == "desc" ? "asc" : "desc"
@user = User.current
@switch_search = params[:name].nil? ? " " : params[:name]
search = "%#{@switch_search.strip.downcase}%"
# 别人的资源库是没有权限去看的 # 别人的资源库是没有权限去看的
if User.current.id.to_i != params[:id].to_i if User.current.id.to_i != params[:id].to_i
render_403 render_403
return return
end end
user_course_ids = User.current.courses.map { |c| c.id}
user_project_ids = User.current.projects.map {|p| p.id}
# user_org_ids = User.current.organizations.map {|o| o.id}
if(params[:type].blank? || params[:type] == "1") # 我的资源 if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
user_course_ids = User.current.courses.map { |c| c.id} user_course_ids = User.current.courses.map { |c| c.id}
user_project_ids = User.current.projects.map {|p| p.id} user_project_ids = User.current.projects.map {|p| p.id}
# user_org_ids = User.current.organizations.map {|o| o.id} # user_org_ids = User.current.organizations.map {|o| o.id}
@attachments = Attachment.where("((author_id = #{params[:id]} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ @attachments = get_my_resources_search(params[:id], user_course_ids, user_project_ids, @order, @score, search)
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" +
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("#{params[:order].nil? ? 'created_on' : params[:order]} desc")
elsif params[:type] == "6" # 公共资源 elsif params[:type] == "6" # 公共资源
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) @attachments = get_public_resources_search(user_course_ids, user_project_ids, @order, @score, search)
end end
@type = params[:type] @type = params[:type]
@limit = 10 @limit = 10
@ -2520,10 +2571,10 @@ class UsersController < ApplicationController
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
@offset ||= @atta_pages.offset @offset ||= @atta_pages.offset
#@curse_attachments_all = @all_attachments[@offset, @limit] #@curse_attachments_all = @all_attachments[@offset, @limit]
@attachments = paginateHelper @attachments,10 @attachments = paginateHelper @attachments, 10
respond_to do |format| respond_to do |format|
format.js format.js
format.html {render :layout => 'new_base'} # format.html {render :layout => 'new_base'}
end end
end end
@ -2584,69 +2635,39 @@ class UsersController < ApplicationController
@order, @b_sort = params[:order] || "created_on", params[:sort] || "desc" @order, @b_sort = params[:order] || "created_on", params[:sort] || "desc"
@score = @b_sort == "desc" ? "asc" : "desc" @score = @b_sort == "desc" ? "asc" : "desc"
@user = User.current @user = User.current
switch_search = params[:search].nil? ? " " : params[:search] @switch_search = params[:search].nil? ? " " : params[:search]
search = "%#{switch_search.strip.downcase}%" search = "%#{@switch_search.strip.downcase}%"
user_course_ids = User.current.courses.map { |c| c.id} user_course_ids = User.current.courses.map {|c| c.id}
user_project_ids = User.current.projects.map {|p| p.id} user_project_ids = User.current.projects.map {|p| p.id}
# user_org_ids = User.current.organizations.map {|o| o.id}
if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') # 全部 if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') # 全部
if params[:status] == "2" if params[:status] == "2"
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like :p) ",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") @attachments = get_course_resources_search(params[:id], user_course_ids, @order, @score, search)
elsif params[:status] == "3" elsif params[:status] == "3"
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") @attachments = get_project_resources_search(params[:id], user_project_ids, @order, @score, search)
elsif params[:status] == "4" elsif params[:status] == "4"
@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") @attachments = get_attch_resources_search(params[:id], @order, @score, search)
elsif params[:status] == "5" elsif params[:status] == "5"
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") @attachments = get_principal_resources_search(params[:id], @order, @score, search)
else else
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
get_my_resources_search(@user.id, user_course_ids, user_project_ids, @order, @score, search) @attachments = get_my_resources_search(params[:id], user_course_ids, user_project_ids, @order, @score, search)
end end
elsif params[:type] == "2" #课程资源 elsif params[:type] == "6" # 公共资源
if User.current.id.to_i == params[:id].to_i
user_course_ids = User.current.courses.map { |c| c.id}
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like :p) ",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}")
else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中
@attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type = 'Course') "+
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )"+
" and (filename like :p) ",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}")
end
elsif params[:type] == "3" # 项目资源
if User.current.id.to_i == params[:id].to_i
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}")
else
@attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' and (filename like :p) ",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}")
end
elsif params[:type] == "4" # 附件
if User.current.id.to_i == params[:id].to_i
@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}")
else
@attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}")
end
elsif params[:type] == "5" # 用户资源
if User.current.id.to_i == params[:id].to_i
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}")
else
@attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Principal' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}")
end
elsif params[:type] == "6" # 全部资源
if params[:status] == "2" if params[:status] == "2"
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like :p) ",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") @attachments = get_course_resources_public_search(user_course_ids, @order, @score, search)
elsif params[:status] == "3" elsif params[:status] == "3"
@attachments = Attachment.where("container_type = 'Project' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") @attachments = get_project_resources_public_search(user_project_ids, @order, @score, search)
elsif params[:status] == "4" elsif params[:status] == "4"
@attachments = Attachment.where("container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") @attachments = get_attch_resources_public_search(@order, @score, search)
elsif params[:status] == "5" elsif params[:status] == "5"
@attachments = Attachment.where("container_type = 'Principal' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") @attachments = get_principal_resources_public_search(@order, @score, search)
else else
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)" ,:p => search).order("created_on desc") @attachments = get_public_resources_search(user_course_ids, user_project_ids, @order, @score, search)
end end
end end
@status = params[:status] @status = params[:status]
@type = params[:type] @type = params[:type]
@type = params[:type]
@limit = 25 @limit = 25
@is_remote = true @is_remote = true
@atta_count = @attachments.count @atta_count = @attachments.count

View File

@ -90,8 +90,8 @@ class Attachment < ActiveRecord::Base
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails") @@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
before_save :files_to_final_location before_save :files_to_final_location
after_save :act_as_course_activity after_save :act_as_course_activity,:act_as_forge_activity
after_create :office_conver, :be_user_score,:act_as_forge_activity,:create_attachment_ealasticsearch_index after_create :office_conver, :be_user_score,:create_attachment_ealasticsearch_index
after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index
after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index, :decrease_attchments_count, :down_course_score after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index, :decrease_attchments_count, :down_course_score
@ -606,7 +606,7 @@ class Attachment < ActiveRecord::Base
# Author lizanle # Author lizanle
# Description 上传该项目的文档资料也要保存一份在公共表中 # Description 上传该项目的文档资料也要保存一份在公共表中
def act_as_forge_activity def act_as_forge_activity
if self.container_type == 'Project' if self.container_type == 'Project' && self.forge_acts.empty?
self.forge_acts << ForgeActivity.new(:user_id => self.author_id, self.forge_acts << ForgeActivity.new(:user_id => self.author_id,
:project_id => self.container_id) :project_id => self.container_id)
end end

View File

@ -0,0 +1,30 @@
<script>
$(document).ready(function(){
$(".popupClose").click(function(){
$(".popupWrap").css("display","none");
});
});
</script>
<span class="f16 fontBlue fb">选择版本 </span>
<p class="c_red">注:该文件有历史版本,请选择您需要的文件,点击文件名下载。</p>
<p class="fontGrey3 mb4 fb">版本及序号</p>
<div style="max-height:165px; overflow-y:auto; background-color: #e3e3e3; line-height:33px;" class="p10">
<span class="attachment">
<%= link_to truncate(@attachment.filename,length: 35, omission: '...'),
download_named_attachment_path(@attachment.id, @attachment.filename),
:title => @attachment.filename+"\n"+@attachment.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis; max-width:300px;",:class => "linkBlue f14 fb link_file_a2 fl" %>
</span>
<span class="fr">版本号:当前</span>
<div class="cl"></div>
<% @attachment_histories.each do |history| %>
<span class="attachment">
<%= link_to truncate(history.filename,length: 35, omission: '...'),
download_history_attachment_path(history.id, history.filename),
:title => history.filename+"\n"+history.description.to_s,
:style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis; max-width:300px;",:class => "linkBlue f14 fb link_file_a2 fl" %>
</span>
<span class="fr">版本号:<%= history.version %></span>
<div class="cl"></div>
<% end %>
</div>

View File

@ -0,0 +1,7 @@
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'attachments/attachment_history_download' )%>');
showModal('ajax-modal', '452px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 435px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top","40%").css("left","50%");
$('#ajax-modal').parent().addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");

View File

@ -9,9 +9,17 @@
</div> </div>
<div class="homepagePostDes"> <div class="homepagePostDes">
<div class="homepagePostTitle break_word mt-4"> <div class="homepagePostTitle break_word mt-4">
<%= link_to file.is_public? ? truncate(file.filename, length: 70) : truncate(file.filename,length: 50, omission: '...'), <%# 如果有历史版本则提供历史版本下载 %>
<% if file.attachment_histories.count == 0 %>
<%= link_to truncate(file.filename,length: 35, omission: '...'),
download_named_attachment_path(file.id, file.filename), download_named_attachment_path(file.id, file.filename),
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14 f_l" %> :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %>
<% else %>
<%= link_to truncate(file.filename,length: 35, omission: '...'), attachment_history_download_path(file.id),
:title => file.filename+"\n"+file.description.to_s,
:class => "linkGrey3 f_14",
:style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;", :remote=>true %>
<% end %>
<%= file_preview_eye(file, class: 'preview') %> <%= file_preview_eye(file, class: 'preview') %>
<span id="image_private_<%= file.id%>"> <span id="image_private_<%= file.id%>">
<% if file.is_public? == false%> <% if file.is_public? == false%>

View File

@ -8,9 +8,17 @@
</div> </div>
<div class="homepagePostDes"> <div class="homepagePostDes">
<div class="homepagePostTitle break_word mt-4"> <div class="homepagePostTitle break_word mt-4">
<%# 如果有历史版本则提供历史版本下载 %>
<% if file.attachment_histories.count == 0 %>
<%= link_to truncate(file.filename,length: 35, omission: '...'), <%= link_to truncate(file.filename,length: 35, omission: '...'),
download_named_attachment_path(file.id, file.filename), download_named_attachment_path(file.id, file.filename),
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %> :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %>
<% else %>
<%= link_to truncate(file.filename,length: 35, omission: '...'), attachment_history_download_path(file.id),
:title => file.filename+"\n"+file.description.to_s,
:class => "linkGrey3 f_14",
:style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;", :remote=>true %>
<% end %>
<%= file_preview_eye(file, class: 'preview') %> <%= file_preview_eye(file, class: 'preview') %>
<span id="image_private_<%= file.id%>"> <span id="image_private_<%= file.id%>">
<% if file.is_public? == false%> <% if file.is_public? == false%>

View File

@ -6,9 +6,17 @@
</div> </div>
<div class="homepagePostDes"> <div class="homepagePostDes">
<div class="homepagePostTitle break_word mt-4"> <div class="homepagePostTitle break_word mt-4">
<%# 如果有历史版本则提供历史版本下载 %>
<% if file.attachment_histories.count == 0 %>
<%= link_to truncate(file.filename,length: 35, omission: '...'), <%= link_to truncate(file.filename,length: 35, omission: '...'),
download_named_attachment_path(file.id, file.filename), download_named_attachment_path(file.id, file.filename),
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %> :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %>
<% else %>
<%= link_to truncate(file.filename,length: 35, omission: '...'), attachment_history_download_path(file.id),
:title => file.filename+"\n"+file.description.to_s,
:class => "linkGrey3 f_14",
:style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;", :remote=>true %>
<% end %>
<%= file_preview_eye(file, class: 'preview') %> <%= file_preview_eye(file, class: 'preview') %>
<span id="image_private_<%= file.id%>"> <span id="image_private_<%= file.id%>">
<% if file.is_public? == false%> <% if file.is_public? == false%>
@ -38,15 +46,12 @@
<%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %> <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
</div> </div>
<div class="homepagePostSetting"> <div class="homepagePostSetting">
<ul> <ul>
<li class="homepagePostSettingIcon"> <li class="homepagePostSettingIcon">
<% if User.current.logged? %> <% if User.current.logged? %>
<% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %> <% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %>
<% if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" %> <% if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" %>
<ul class="homepagePostSettiongText"> <ul class="homepagePostSettiongText">
<li><%= link_to("发&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %></li> <li><%= link_to("发&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %></li>
<li><%= link_to '延期发布',file_hidden_course_file_path(@course,file),:class => "postOptionLink",:remote=>true %></li> <li><%= link_to '延期发布',file_hidden_course_file_path(@course,file),:class => "postOptionLink",:remote=>true %></li>
<li><%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %></li> <li><%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %></li>
@ -59,10 +64,10 @@
<%end%> <%end%>
<li> <li>
<%= link_to( '删除资源', attachment_path(file), <%= link_to( '删除资源', attachment_path(file),
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" && file.destroyable %> :data => {:confirm => l(:text_are_you_sure)},
:method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" && file.destroyable %>
</li> </li>
</ul> </ul>
<% end %> <% end %>
<%else%> <%else%>
<ul class="resourceSendO"> <ul class="resourceSendO">

View File

@ -109,7 +109,7 @@
<div class="navHomepageNews"> <div class="navHomepageNews">
<%= link_to "", user_message_path(User.current), :class => "homepageNewsIcon", :target =>"_Blank", :title => "您的所有消息" %> <%= link_to "", user_message_path(User.current), :class => "homepageNewsIcon", :target =>"_Blank", :title => "您的所有消息" %>
<% if User.current.count_new_message >0 %> <% if User.current.count_new_message.to_i >0 %>
<div ><%= link_to User.current.count_new_message , user_message_path(User.current), :class => "newsActive", :target =>"_Blank" %></div> <div ><%= link_to User.current.count_new_message , user_message_path(User.current), :class => "newsActive", :target =>"_Blank" %></div>
<% end %> <% end %>
<%#= link_to User.current.count_new_message, user_message_path(User.current), :class => "homepageNewsIcon" %> <%#= link_to User.current.count_new_message, user_message_path(User.current), :class => "homepageNewsIcon" %>

View File

@ -319,7 +319,7 @@
} }
}) })
//资源库上传附件
function course_files_upload(){ function course_files_upload(){
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'files/upload_course_files',:locals => {:course => @course,:course_attachment_type => 1}) %>'); $('#ajax-modal').html('<%= escape_javascript(render :partial => 'files/upload_course_files',:locals => {:course => @course,:course_attachment_type => 1}) %>');
showModal('ajax-modal', '513px'); showModal('ajax-modal', '513px');

View File

@ -78,7 +78,7 @@
<% end %> <% end %>
<!--Attachment --> <!--Attachment -->
<% when "Attachment" %> <% when "Attachment" %>
<%= render :partial => 'projects/attachment_acts', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id } %> <%= render :partial => 'users/course_attachment', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id } %>
<!--<div class="problem_main">--> <!--<div class="problem_main">-->
<!--<a class="problem_pic fl"><%#= image_tag(url_to_avatar(activity.user), :width => "42", :height => "42") %></a>--> <!--<a class="problem_pic fl"><%#= image_tag(url_to_avatar(activity.user), :width => "42", :height => "42") %></a>-->

View File

@ -21,7 +21,7 @@
<%= call_hook(:view_projects_settings_members_table_header, :project => @project) %> <%= call_hook(:view_projects_settings_members_table_header, :project => @project) %>
<% members.each do |member| %> <% members.each do |member| %>
<li > <li >
<%= link_to_user_header member.principal,false,:class => "w140_h c_setting_blue fl" %> <%= link_to_user_header member.principal, true, :class => "w140_h c_setting_blue fl" %>
<span class="w180_h fl"> <span class="w180_h fl">
<!--区分中英文角色显示的不同--> <!--区分中英文角色显示的不同-->
<% if User.current.language == "zh" %> <% if User.current.language == "zh" %>

View File

@ -4,6 +4,9 @@
$("#pro_st_edit_ku").toggle(); $("#pro_st_edit_ku").toggle();
} }
</script> </script>
<% unless @project.repositories.any? %>
<p class="nodata">温馨提示:<%= l(:label_repository_no_data) %></p>
<% end %>
<%= str = error_messages_for 'repository' %> <%= str = error_messages_for 'repository' %>
<% project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT %> <% project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT %>
<% ip = RepositoriesHelper::REPO_IP_ADDRESS %><!--Added by tanxianbo For formatting project's path--> <% ip = RepositoriesHelper::REPO_IP_ADDRESS %><!--Added by tanxianbo For formatting project's path-->
@ -87,8 +90,6 @@
<% end %> <% end %>
</tbody> </tbody>
</table> </table>
<% else %>
<p class="nodata">温馨提示:<%= l(:label_repository_no_data) %></p>
<% end %> <% end %>

View File

@ -18,7 +18,7 @@
<li><%= link_to "问题动态", {:controller => "projects", :action => "show", :type => "issue"}, :class => "homepagePostTypeMessage postTypeGrey" %></li> <li><%= link_to "问题动态", {:controller => "projects", :action => "show", :type => "issue"}, :class => "homepagePostTypeMessage postTypeGrey" %></li>
<!--<li><%#= link_to "作业动态", {:controller => "courses", :action => "show", :type => "homework"}, :class => "homepagePostTypeAssignment postTypeGrey" %></li>--> <!--<li><%#= link_to "作业动态", {:controller => "courses", :action => "show", :type => "homework"}, :class => "homepagePostTypeAssignment postTypeGrey" %></li>-->
<li><%= link_to "新闻动态", {:controller => "projects", :action => "show", :type => "news"}, :class => "homepagePostTypeNotice postTypeGrey" %></li> <li><%= link_to "新闻动态", {:controller => "projects", :action => "show", :type => "news"}, :class => "homepagePostTypeNotice postTypeGrey" %></li>
<!--<li><%#= link_to "资源库动态", {:controller => "projects", :action => "show", :type => "attachment"}, :class => "homepagePostTypeResource resourcesGrey" %></li>--> <li><%= link_to "资源库动态", {:controller => "projects", :action => "show", :type => "attachment"}, :class => "homepagePostTypeResource resourcesGrey" %></li>
<li><%= link_to "讨论区动态", {:controller => "projects", :action => "show", :type => "message"}, :class => "homepagePostTypeForum postTypeGrey" %></li> <li><%= link_to "讨论区动态", {:controller => "projects", :action => "show", :type => "message"}, :class => "homepagePostTypeForum postTypeGrey" %></li>
<!--<li><%#= link_to "问卷动态", {:controller => "courses", :action => "show", :type => "poll"}, :class => "homepagePostTypeQuiz postTypeGrey" %></li>--> <!--<li><%#= link_to "问卷动态", {:controller => "courses", :action => "show", :type => "poll"}, :class => "homepagePostTypeQuiz postTypeGrey" %></li>-->
</ul> </ul>

View File

@ -26,11 +26,14 @@
<a href="<%= import_resources_user_path(User.current, :type => '6', :subfield_file_id => params[:subfield_file_id]) %>" id="public_resources_choose" class="subject-choose choose-active fl" data-remote="true">公共资源</a> <a href="<%= import_resources_user_path(User.current, :type => '6', :subfield_file_id => params[:subfield_file_id]) %>" id="public_resources_choose" class="subject-choose choose-active fl" data-remote="true">公共资源</a>
<a href="<%= import_resources_user_path(User.current, :type => '1', :subfield_file_id => params[:subfield_file_id]) %>" id="my_resources_choose" class="subject-choose fl" data-remote="true">我的资源</a> <a href="<%= import_resources_user_path(User.current, :type => '1', :subfield_file_id => params[:subfield_file_id]) %>" id="my_resources_choose" class="subject-choose fl" data-remote="true">我的资源</a>
<% end %> <% end %>
<%#= form_tag( url_for(:controller => 'users', :action => 'import_resources_search', :id => User.current.id, :type => 1), <div id="user_import_resource_search">
:remote => true , :method => 'get', :id => 'resource_search_form') do %> <%=render :partial=>'users/user_import_resource_search', :locals => {:type => @type, :search => ''} %>
</div>
<!--<%#= form_tag( url_for(:controller => 'users', :action => 'import_resources_search', :id => User.current.id), :remote => true , :method => 'get', :id => 'resource_search_form') do %>-->
<!--<input type="text" name="search" placeholder="输入资源关键词进行搜索" class="subjectSearch fr" />--> <!--<input type="text" name="search" placeholder="输入资源关键词进行搜索" class="subjectSearch fr" />-->
<%#= hidden_field_tag(:type,type.nil? ? 1 : type) %> <!--<%#= hidden_field_tag(:type,type.nil? ? 1 : type) %>-->
<%# end %> <!--<%#= submit_tag '', :class => 'homepageSearchIcon', :onfocus => 'this.blur();', :style => 'border-style:none' %>-->
<!--<%# end %>-->
<div class="cl"></div> <div class="cl"></div>
@ -42,25 +45,10 @@
<li class="subjectPublisher fl">上传者</li> <li class="subjectPublisher fl">上传者</li>
<li class="fl subjectDate">上传时间</li> <li class="fl subjectDate">上传时间</li>
</ul> </ul>
<%= form_tag( url_for({:controller => 'users', :action => 'import_into_container', <div id="import_resource_info_list">
:mul_id => params[:project_id].nil? ? (params[:course_id].nil? ? params[:subfield_file_id] : params[:course_id]) : params[:project_id], <%= render :partial => 'users/user_import_resource_list',:locals => {:project_id => params[:project_id], :subfield_file_id => params[:subfield_file_id], :course_id => params[:course_id]} %>
:mul_type => params[:project_id].nil? ? (params[:course_id].nil? ? "SubfieldFile" : "Course") : "Project"}), </div>
:method => 'post', :id => 'resource_import_container_form') do %>
<% @attachments.each do |attach| %>
<ul class="subjectRow">
<li class="subjectName fl hidden">
<label>
<input name="checkbox1[]" type="checkbox" data-has-history="<%= attach.attachment_histories.count == 0 ? 'N' : 'Y' %>" data-deleteble="<%= User.current.id ==attach.author_id ? 'Y' : 'N' %>" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="mr5" style="vertical-align:middle;" />
<span><%= link_to truncate(attach.filename, :length => 30), download_named_attachment_path(attach.id, attach.filename), :title => attach.filename%></span>
</label>
</li>
<li class="subjectType fl"><%= get_resource_type(attach.container_type)%></li>
<li class="subjectCount fl hidden"><%= number_to_human_size(attach.filesize) %></li>
<li class="subjectPublisher fl"><%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %></li>
<li class="fl subjectDate"><%= format_date(attach.created_on) %></li>
</ul>
<% end %>
<% end %>
</div> </div>
<div class="courseSendSubmit mr15"><a href="javascript:void(0);" class="sendSourceText" onclick="$('#resource_import_container_form').submit();hideModal()">选用</a></div> <div class="courseSendSubmit mr15"><a href="javascript:void(0);" class="sendSourceText" onclick="$('#resource_import_container_form').submit();hideModal()">选用</a></div>

View File

@ -16,7 +16,7 @@
<li class="resource-list-quote fr"><%= attach.quotes.nil? ? 0 : attach.quotes %></li> <li class="resource-list-quote fr"><%= attach.quotes.nil? ? 0 : attach.quotes %></li>
<li class="resource-list-download fr"><%= attach.downloads %></li> <li class="resource-list-download fr"><%= attach.downloads %></li>
<li style="display: none"><%= attach.author_id %></li> <li style="display: none"><%= attach.author_id %></li>
<li class="resource-list-size fr"><%= number_to_human_size(attach.filesize) %></li> <li class="resource-list-size fr"><%= (number_to_human_size(attach.filesize)).gsub("ytes", "") %></li>
<li class="resource-list-uploader fr hidden"><%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %></li> <li class="resource-list-uploader fr hidden"><%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %></li>
<li class="resource-list-type fr"><%= get_resource_type(attach.container_type)%></li> <li class="resource-list-type fr"><%= get_resource_type(attach.container_type)%></li>
<li class="resource-list-from fr hidden" title="<%= get_resource_origin(attach) %>"><%= get_resource_origin(attach) %></li> <li class="resource-list-from fr hidden" title="<%= get_resource_origin(attach) %>"><%= get_resource_origin(attach) %></li>

View File

@ -0,0 +1,19 @@
<%= form_tag( url_for({:controller => 'users', :action => 'import_into_container',
:mul_id => project_id.nil? ? (course_id.nil? ? subfield_file_id : course_id) : project_id,
:mul_type => project_id.nil? ? (course_id.nil? ? "SubfieldFile" : "Course") : "Project"}),
:method => 'post', :id => 'resource_import_container_form') do %>
<% @attachments.each do |attach| %>
<ul class="subjectRow">
<li class="subjectName fl hidden">
<label>
<input name="checkbox1[]" type="checkbox" data-has-history="<%= attach.attachment_histories.count == 0 ? 'N' : 'Y' %>" data-deleteble="<%= User.current.id ==attach.author_id ? 'Y' : 'N' %>" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="mr5" style="vertical-align:middle;" />
<span><%= link_to truncate(attach.filename, :length => 30), download_named_attachment_path(attach.id, attach.filename), :title => attach.filename%></span>
</label>
</li>
<li class="subjectType fl"><%= get_resource_type(attach.container_type)%></li>
<li class="subjectCount fl hidden"><%= (number_to_human_size(attach.filesize)).gsub("ytes", "") %></li>
<li class="subjectPublisher fl"><%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %></li>
<li class="fl subjectDate"><%= format_date(attach.created_on) %></li>
</ul>
<% end %>
<% end %>

View File

@ -0,0 +1,29 @@
<input type="text" name="search" placeholder="输入资源关键词进行搜索" class="subjectSearch fr" />
<script type="text/javascript">
var lastSearchCondition = '';
var count = 0;
function search_hws(e){
if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
{
return;
}
lastSearchCondition = $(e.target).val().trim();
$.ajax({
url: '<%= url_for(:controller => 'users', :action => 'import_resources_search', :id => User.current.id) %>'+'?name='+ e.target.value+'&type=<%=type %>',
type:'get'
});
}
function throttle(method,context,e){
clearTimeout(method.tId);
method.tId=setTimeout(function(){
method.call(context,e);
},500);
}
//查询项目
$("input[name='search']").on('input', function (e) {
throttle(search_hws,window,e);
});
</script>

View File

@ -2,24 +2,24 @@
<li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a> <li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a>
<ul class="resourcesType"> <ul class="resourcesType">
<li> <li>
<a href="<%= user_resource_user_path(:id => @user.id, :type => @type, :status => 1)%>" id="resource_type_all" class="resourcesTypeAll resourcesGrey" data-method="get" data-remote="true">全部 </a> <a href="<%= resource_search_user_path(:id => @user.id, :type => @type, :status => 1, :search => @switch_search) %>" id="resource_type_all" class="resourcesTypeAll resourcesGrey" data-method="get" data-remote="true">全部 </a>
</li> </li>
<li> <li>
<a href="<%= user_resource_user_path(:id => @user.id, :type => @type, :status => 2) %>" id="resource_type_course" class="homepagePostTypeAssignment postTypeGrey'" data-method="get" data-remote="true">课程资源 </a> <a href="<%= resource_search_user_path(:id => @user.id, :type => @type, :status => 2, :search => @switch_search) %>" id="resource_type_course" class="homepagePostTypeAssignment postTypeGrey'" data-method="get" data-remote="true">课程资源 </a>
<%#= link_to '课程资源' ,user_resource_user_path(:id => @user.id, :type => 2), id="resource_type_course", :remote => true, :method => 'get', :class=> 'homepagePostTypeAssignment postTypeGrey' %> <%#= link_to '课程资源' ,user_resource_user_path(:id => @user.id, :type => 2), id="resource_type_course", :remote => true, :method => 'get', :class=> 'homepagePostTypeAssignment postTypeGrey' %>
</li> </li>
<li> <li>
<a href="<%= user_resource_user_path(:id => @user.id, :type => @type, :status => 3) %>" id="resource_type_project" class="homepagePostTypeQuiz postTypeGrey" data-method="get" data-remote="true">项目资源 </a> <a href="<%= resource_search_user_path(:id => @user.id, :type => @type, :status => 3, :search => @switch_search) %>" id="resource_type_project" class="homepagePostTypeQuiz postTypeGrey" data-method="get" data-remote="true">项目资源 </a>
<%#= link_to '项目资源' ,user_resource_user_path(:id => @user.id, :type => 3), id="resource_type_project", :remote => true, :method => 'get', :class => 'homepagePostTypeQuiz postTypeGrey' %> <%#= link_to '项目资源' ,user_resource_user_path(:id => @user.id, :type => 3), id="resource_type_project", :remote => true, :method => 'get', :class => 'homepagePostTypeQuiz postTypeGrey' %>
</li> </li>
<li> <li>
<a href="<%= user_resource_user_path(:id => @user.id, :type => @type, :status => 5) %>" id="resource_type_user" class="resourcesTypeUser resourcesGrey" data-method="get" data-remote="true">用户资源 </a> <a href="<%= resource_search_user_path(:id => @user.id, :type => @type, :status => 5, :search => @switch_search) %>" id="resource_type_user" class="resourcesTypeUser resourcesGrey" data-method="get" data-remote="true">用户资源 </a>
<%#= link_to '用户资源' ,user_resource_user_path(:id=>@user.id,:type=>5), id="resource_type_user", :remote=>true,:method => 'get', :class=>'resourcesTypeUser resourcesGrey' %> <%#= link_to '用户资源' ,user_resource_user_path(:id=>@user.id,:type=>5), id="resource_type_user", :remote=>true,:method => 'get', :class=>'resourcesTypeUser resourcesGrey' %>
</li> </li>
<div id="my_files_resource"> <div id="my_files_resource">
<% if @type != "6" %> <% if @type != "6" %>
<li> <li>
<a href="<%= user_resource_user_path(:id => @user.id, :type => @type, :status => 4) %>" id="resource_type_file" class="resourcesTypeAtt resourcesGrey" data-method="get" data-remote="true">附件 </a> <a href="<%= resource_search_user_path(:id => @user.id, :type => @type, :status => 4, :search => @switch_search) %>" id="resource_type_file" class="resourcesTypeAtt resourcesGrey" data-method="get" data-remote="true">附件 </a>
<%#= link_to '附件' ,user_resource_user_path(:id=>@user.id,:type=>4), id="resource_type_file", :remote=>true,:method => 'get',:class=>'resourcesTypeAtt resourcesGrey' %> <%#= link_to '附件' ,user_resource_user_path(:id=>@user.id,:type=>4), id="resource_type_file", :remote=>true,:method => 'get',:class=>'resourcesTypeAtt resourcesGrey' %>
</li> </li>
<% end %> <% end %>

View File

@ -1,25 +1,3 @@
//$("#resources_list").html('<%#= escape_javascript( render :partial => 'users/import_resource_info' ,:locals=>{ :attachments => @attachments, :type => @type})%>'); $("#import_resource_info_list").html('<%= escape_javascript( render :partial => 'user_import_resource_list',
//$("#pages").html('<%#= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); :locals => {:user => @user, :type => @type, :project_id => params[:project_id], :subfield_file_id => params[:subfield_file_id], :course_id => params[:course_id]} ) %>');
//$("#res_all_count").html(<%#= @atta_count%>); $("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
//$("#res_count").html(0);
//$("#checkboxAll").attr('checked',false);
<% if params[:project_id] %>
$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => 1, :project_id => params[:project_id]} ) %>');
<% elsif params[:course_id] %>
$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => 1, :course_id => params[:course_id]} ) %>');
<% elsif params[:subfield_file_id] %>
$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => 1, :subfield_file_id => params[:subfield_file_id]} ) %>');
<% end %>
showModal('ajax-modal', '615px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal()' style='margin-left: 580px;'><img src='/images/bid/close.png' width='26px' height='26px' /></a>");
<% if params[:project_id] %>
$('#ajax-modal').parent().css("top","10%").css("left","34%").css("border","3px solid #269ac9");
<% else %>
$('#ajax-modal').parent().css("top","20%").css("left","42%").css("border","3px solid #269ac9");
<% end %>
$('#ajax-modal').parent().addClass("popbox_polls");

View File

@ -5,10 +5,10 @@ $("#res_all_count").html(<%= @atta_count%>);
$("#res_count").html(0); $("#res_count").html(0);
$("#checkboxAll").attr('checked',false); $("#checkboxAll").attr('checked',false);
//更新状态 //更新状态
$("#public_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '6', :status => @status) %>'); $("#public_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '6') %>');
$("#my_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '1', :status => @status) %>'); $("#my_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '1') %>');
$("#resource_type_all").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 1) %>'); $("#resource_type_all").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 1, :search => @switch_search) %>');
$("#resource_type_course").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 2) %>'); $("#resource_type_course").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 2, :search => @switch_search) %>');
$("#resource_type_project").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 3) %>'); $("#resource_type_project").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 3, :search => @switch_search) %>');
$("#resource_type_user").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 5) %>'); $("#resource_type_user").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 5, :search => @switch_search) %>');
$("#resource_type_file").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 4) %>'); $("#resource_type_file").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 4, :search => @switch_search) %>');

View File

@ -1,12 +1,8 @@
<%= javascript_include_tag 'bootstrap'%> <%= javascript_include_tag 'bootstrap' %>
<%= stylesheet_link_tag 'project' %> <%= stylesheet_link_tag 'project' %>
<%= stylesheet_link_tag 'leftside' %> <%= stylesheet_link_tag 'leftside' %>
<%= javascript_include_tag 'attachments'%> <%= javascript_include_tag 'attachments' %>
<!--<script type="text/css">-->
<!--html,body{ overflow-y:scroll;}-->
<!--html,body{ overflow:scroll; min-height:101%;}-->
<!--html{ overflow:-moz-scrollbars-vertical;}-->
<!--</script>-->
<script> <script>
function remote_get_resources(user_id,type){ function remote_get_resources(user_id,type){

View File

@ -9,8 +9,7 @@ $("#res_all_count").html(<%= @atta_count %>);
$("#public_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '6') %>'); $("#public_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '6') %>');
$("#my_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '1') %>'); $("#my_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '1') %>');
$("#resource_type_all").attr('href','<%= user_resource_user_path(@user, :type => @type, :status => 1) %>');
$("#resource_type_all").attr('href','<%= user_resource_user_path(@user,:type => @type, :status => 1) %>');
$("#resource_type_course").attr('href','<%= user_resource_user_path(@user,:type => @type, :status => 2) %>'); $("#resource_type_course").attr('href','<%= user_resource_user_path(@user,:type => @type, :status => 2) %>');
$("#resource_type_project").attr('href','<%= user_resource_user_path(@user,:type => @type, :status => 3) %>'); $("#resource_type_project").attr('href','<%= user_resource_user_path(@user,:type => @type, :status => 3) %>');
$("#resource_type_user").attr('href','<%= user_resource_user_path(@user,:type => @type, :status => 5) %>'); $("#resource_type_user").attr('href','<%= user_resource_user_path(@user,:type => @type, :status => 5) %>');

View File

@ -1,6 +1,15 @@
closeModal(); closeModal();
$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>');
//这里不能将翻页的更新 $("#resource_tip_list").html('<%= escape_javascript( render :partial => 'users/user_resource_tip_list', :locals => {:user => @user, :type => @type, :status => @status}) %>');
$("#res_all_count").html('<%= @atta_count%>'); $("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
$("#res_all_count").html(<%= @atta_count%>);
$("#res_count").html(0); $("#res_count").html(0);
$("#checkboxAll").attr('checked',false); $("#checkboxAll").attr('checked',false);
//更新状态
$("#public_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '6') %>');
$("#my_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '1') %>');
$("#resource_type_all").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 1, :search => @switch_search) %>');
$("#resource_type_course").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 2, :search => @switch_search) %>');
$("#resource_type_project").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 3, :search => @switch_search) %>');
$("#resource_type_user").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 5, :search => @switch_search) %>');
$("#resource_type_file").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 4, :search => @switch_search) %>');

View File

@ -1,5 +1,14 @@
$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>');
$("#resource_tip_list").html('<%= escape_javascript( render :partial => 'users/user_resource_tip_list', :locals => {:user => @user, :type => @type, :status => @status}) %>');
$("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); $("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
$("#res_all_count").html('<%= @atta_count%>') $("#res_all_count").html(<%= @atta_count%>);
$("#res_count").html(0); $("#res_count").html(0);
$("#checkboxAll").attr('checked',false); $("#checkboxAll").attr('checked',false);
//更新状态
$("#public_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '6') %>');
$("#my_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '1') %>');
$("#resource_type_all").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 1, :search => @switch_search) %>');
$("#resource_type_course").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 2, :search => @switch_search) %>');
$("#resource_type_project").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 3, :search => @switch_search) %>');
$("#resource_type_user").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 5, :search => @switch_search) %>');
$("#resource_type_file").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 4, :search => @switch_search) %>');

View File

@ -876,6 +876,7 @@ RedmineApp::Application.routes.draw do
# additional routes for having the file name at the end of url # additional routes for having the file name at the end of url
get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment' get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment'
get 'attachments/attachment_versions/:id',:to=>'attachments#attachment_versions',:as=>'attachments_versions' get 'attachments/attachment_versions/:id',:to=>'attachments#attachment_versions',:as=>'attachments_versions'
get 'attachments/attachment_history_download/:id',:to=>'attachments#attachment_history_download',:as=>'attachment_history_download'
post 'attachments/upload_attachment_version',:to=>'attachments#upload_attachment_version',:as=>'upload_attachment_version' post 'attachments/upload_attachment_version',:to=>'attachments#upload_attachment_version',:as=>'upload_attachment_version'
get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment' get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment'
get 'attachments/download_history/:id/:filename', :to => 'attachments#download_history', :id => /\d+/, :filename => /.*/, :as => 'download_history_attachment' get 'attachments/download_history/:id/:filename', :to => 'attachments#download_history', :id => /\d+/, :filename => /.*/, :as => 'download_history_attachment'

View File

@ -0,0 +1,19 @@
class AttachmentProjectCountUpdate < ActiveRecord::Migration
def up
Project.all.each do |project|
unless project.attachments.count.to_i == 0
attachment_count = Attachment.find_by_sql("SELECT * FROM `attachments` where container_id = #{project.id} and container_type ='Project'").count
project_score = ProjectScore.where("project_id=?", project.id).first
if project_score.nil?
ProjectScore.create(:project_id => project.id, :attach_num => 0)
else
project_score.attach_num = attachment_count
project_score.save
end
end
end
end
def down
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20160225031230) do ActiveRecord::Schema.define(:version => 20160316055201) do
create_table "activities", :force => true do |t| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false
@ -435,6 +435,8 @@ ActiveRecord::Schema.define(:version => 20160225031230) do
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.integer "total_score" t.integer "total_score"
t.integer "homework_journal_num", :default => 0
t.integer "news_num", :default => 0
end end
create_table "course_groups", :force => true do |t| create_table "course_groups", :force => true do |t|
@ -506,6 +508,7 @@ ActiveRecord::Schema.define(:version => 20160225031230) do
t.integer "is_excellent", :default => 0 t.integer "is_excellent", :default => 0
t.integer "excellent_option", :default => 0 t.integer "excellent_option", :default => 0
t.integer "is_copy", :default => 0 t.integer "is_copy", :default => 0
t.integer "visits", :default => 0
end end
create_table "custom_fields", :force => true do |t| create_table "custom_fields", :force => true do |t|
@ -1282,6 +1285,7 @@ ActiveRecord::Schema.define(:version => 20160225031230) do
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.boolean "allow_guest_download", :default => true t.boolean "allow_guest_download", :default => true
t.integer "visits", :default => 0
end end
create_table "phone_app_versions", :force => true do |t| create_table "phone_app_versions", :force => true do |t|
@ -1441,6 +1445,7 @@ ActiveRecord::Schema.define(:version => 20160225031230) do
t.integer "acts_count", :default => 0 t.integer "acts_count", :default => 0
t.integer "journals_count", :default => 0 t.integer "journals_count", :default => 0
t.integer "boards_reply_count", :default => 0 t.integer "boards_reply_count", :default => 0
t.integer "visits", :default => 0
end end
add_index "projects", ["lft"], :name => "index_projects_on_lft" add_index "projects", ["lft"], :name => "index_projects_on_lft"
@ -1900,6 +1905,7 @@ ActiveRecord::Schema.define(:version => 20160225031230) do
t.string "mail_notification", :default => "", :null => false t.string "mail_notification", :default => "", :null => false
t.string "salt", :limit => 64 t.string "salt", :limit => 64
t.integer "gid" t.integer "gid"
t.integer "visits", :default => 0
end end
add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id"
@ -2013,11 +2019,6 @@ ActiveRecord::Schema.define(:version => 20160225031230) do
add_index "wikis", ["project_id"], :name => "wikis_project_id" add_index "wikis", ["project_id"], :name => "wikis_project_id"
create_table "wlcs", :force => true do |t|
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "workflows", :force => true do |t| create_table "workflows", :force => true do |t|
t.integer "tracker_id", :default => 0, :null => false t.integer "tracker_id", :default => 0, :null => false
t.integer "old_status_id", :default => 0, :null => false t.integer "old_status_id", :default => 0, :null => false

View File

@ -1432,3 +1432,4 @@ function submit_course_feedback() {
function show_more_tool(){ function show_more_tool(){
$('#navContentCourse').css('display', 'block'); $('#navContentCourse').css('display', 'block');
} }