This commit is contained in:
ouyangxuhua 2015-12-31 16:12:19 +08:00
commit 692f13d1de
59 changed files with 4153 additions and 3420 deletions

View File

@ -185,7 +185,6 @@ class AttachmentsController < ApplicationController
end
@attachment.filename = params[:filename].presence || Redmine::Utils.random_hex(16)
saved = @attachment.save
respond_to do |format|
format.js
format.api {
@ -198,6 +197,33 @@ class AttachmentsController < ApplicationController
end
end
def upload_attachment_version
@flag = false
Attachment.transaction do
@old_attachment = Attachment.find params[:old_attachment_id]
#取出当前上传的文件
@attachment = Attachment.find(params[:attachments ].first[1][:attachment_id])
#将需要修改的记录保存到历史记录
@history = AttachmentHistory.new
@history.attributes = @old_attachment.attributes.dup.except("id")
@history.attachment_id = params[:old_attachment_id]
#需要更新版本号,需要拿到原来该文件最大的历史版本号
@old_history = @old_attachment.attachment_histories.reorder('version desc').first
@history.version = @old_history.nil? ? 1 : @old_history.version + 1
@history.save #历史记录保存完毕
#将最新保存的记录 数据替换到 需要修改的文件记录
@old_attachment.attributes = @attachment.attributes.dup.except("id","container_id","container_type","is_public")
@old_attachment.save
#删除当前记录
@attachment.delete
@flag = true
end
respond_to do |format|
format.js
end
end
def destroy
if @attachment.container.respond_to?(:init_journal)
@attachment.container.init_journal(User.current)
@ -494,6 +520,15 @@ class AttachmentsController < ApplicationController
end
end
#找到文件的所有的历史版本
def attachment_versions
@attachment = Attachment.find(params[:id])
@attachment_histories = @attachment.attachment_histories
respond_to do |format|
format.js
end
end
private
def find_project
@attachment = Attachment.find(params[:id])

View File

@ -745,7 +745,16 @@ class FilesController < ApplicationController
q = "%#{@q.strip}%"
@result = find_course_attache q,@course,sort
@result = visable_attachemnts @result
@result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} unless @tag_name.blank?
if params[:other]
@result = @result.select{|attachment|
!attachment.tag_list.include?('课件') &&
!attachment.tag_list.include?('软件') &&
!attachment.tag_list.include?('媒体') &&
!attachment.tag_list.include?('代码') &&
!attachment.tag_list.include?('论文') }
else
@result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} unless @tag_name.blank?
end
@searched_attach = paginateHelper @result,10
@tag_list = get_course_tag_list @course

View File

@ -63,7 +63,7 @@ class HomeworkCommonController < ApplicationController
end
@homework.end_time = params[:homework_common][:end_time] || Time.now
@homework.course_id = params[:course_id]
@homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 1
@homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 0
homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new
if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0

View File

@ -85,7 +85,7 @@ class IssuesController < ApplicationController
params[:page] = (params[:page] || 1).to_i + 1 #页码需要加1
@offset ||= @issue_pages.offset
@issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version],
:order => sort_clause,
:order => 'issues.updated_on desc',
:offset => @offset,
:limit => @limit)
if params[:set_filter]

View File

@ -1,294 +1,303 @@
# encoding: utf-8
class OrganizationsController < ApplicationController
helper :sort
include SortHelper
helper :custom_fields
include CustomFieldsHelper
include AvatarHelper
include WordsHelper
include GitlabHelper
include UserScoreHelper
include PollHelper
helper :user_score
helper :journals
helper :attachments
# added by liuping 关注
helper :watchers
helper :activities
### added by william
include ActsAsTaggableOn::TagsHelper
# fq
helper :words
helper :project_score
helper :issues
include UsersHelper
before_filter :find_organization, :only => [:show, :members]
layout 'base_org'
def index
end
def new
@organization = Organization.new
render :layout => 'new_base'
end
def edit
@organization = Organization.find(params[:id])
end
def destroy
@organization = Organization.find(params[:id])
@organization.destroy
respond_to do |format|
format.html{ redirect_to admin_organization_path }
end
end
def create
@organization = Organization.new
@organization.name = params[:organization][:name]
@organization.description = params[:organization][:description]
@organization.is_public = params[:organization][:is_public]
@organization.creator_id = User.current.id
member = OrgMember.new(:user_id => User.current.id)
@organization.org_members << member
if @organization.save
OrgMemberRole.create(:org_member_id => member.id, :role_id => 11)
redirect_to organization_path(@organization)
end
end
def show
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
@organization = Organization.find(params[:id])
if params[:org_subfield_id]
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
@org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0
@org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10)
else
project_ids = @organization.projects.map(&:id) << 0
course_ids = @organization.courses.map(&:id) << 0
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
case params[:type]
when nil
@org_activities = OrgActivity.where("(container_id =? and container_type =?) " +
"or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')})) "+
"or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))",
@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10)
when 'project_issue'
@org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Issue' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'project_message'
@org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Message' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'org'
@org_activities = OrgActivity.where("container_id =? and container_type =?",@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_homework'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'HomeworkCommon' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_news'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'News' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_message'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Message' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_poll'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Poll' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
end
end
@page = params[:page]
respond_to do |format|
format.html
format.js
end
else
render_403
end
end
def update
@organization = Organization.find(params[:id])
@organization.name = params[:organization][:name]
@organization.description = params[:organization][:description]
@organization.domain = params[:organization][:domain]
@organization.is_public = params[:organization][:is_public] == 'on' ? 1 : 0
#@organization.name = params[:organization][:name]
@organization.save
respond_to do |format|
format.html { redirect_to setting_organization_path(@organization)}
end
end
def check_uniq
@check = false;
@org_name = params[:org_name].strip
@config_page = params[:config_page]
sameName = @config_page ? Organization.where('name = ? and id != ?',params[:org_name],params[:org_id].to_i).count == 0 : Organization.where('name = ?',params[:org_name]).count == 0
if sameName == true
@check = true
end
respond_to do |format|
format.js
end
end
def find_organization
@organization = Organization.find(params[:id])
end
def setting
@organization = Organization.find(params[:id])
if User.current.admin? || User.current.admin_of_org?(@organization)
else
render_403
end
end
def clear_org_avatar_temp
end
def set_homepage
@org = Organization.find(params[:id])
@org.home_id = params[:home_id]
@org.save
# respond_to do |format|
# format.html {redirect_to organization_path(org)}
# end
end
def cancel_homepage
@org = Organization.find(params[:id])
@org.home_id = nil
@org.save
end
def autocomplete_search
@project = Project.find(params[:project_id])
#@flag = params[:flag] || false
respond_to do |format|
format.js
end
end
def members
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
@members = OrgMember.where("organization_id =?", @organization.id)
else
render_403
end
end
def more_org_projects
@organization = Organization.find params[:id]
@page = params[:page]
@org_projects = @organization.projects.reorder('created_at').uniq.page((params[:page].to_i || 1) +1).per(5)
respond_to do |format|
format.js
end
end
def more_org_courses
@organization = Organization.find(params[:id])
@page = params[:page]
@org_courses = @organization.courses.reorder('created_at').uniq.page((params[:page].to_i || 1) + 1 ).per(5)
respond_to do |format|
format.js
end
end
def join_course_menu
@organization = Organization.find(params[:id])
respond_to do |format|
format.js
end
end
def search_courses
@organization = Organization.find(params[:id])
condition = '%%'
if !params[:name].nil?
condition = "%#{params[:name].strip}%".gsub(" ","")
end
sql = "select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.name like '#{condition}'"+
"and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id})"
#user_courses = Course.find_by_sql(sql)
@courses = Course.find_by_sql(sql)
# @added_course_ids = @organization.courses.map(&:id)
# @courses = []
# user_courses.each do |course|
# if !@added_course_ids.include?(course.id)
# @courses << course
# end
# end
end
def join_courses
@organization = Organization.find(params[:id])
course_ids = params[:courseNames]
course_ids.each do |id|
OrgCourse.create(:organization_id => @organization.id, :course_id => id.to_i, :created_at => Time.now)
end
respond_to do |format|
format.js
end
end
def join_project_menu
@organization = Organization.find(params[:id])
respond_to do |format|
format.js
end
end
def logout
logout_user
respond_to do |format|
format.html {redirect_to organization_path(params[:id])}
end
end
def search_projects
@organization = Organization.find(params[:id])
condition = '%%'
if !params[:name].nil?
condition = "%#{params[:name].strip}%".gsub(" ","")
end
sql = "select projects.* from projects inner join members on projects.id = members.project_id where members.user_id = #{User.current.id} and projects.status != 9 and projects.name like '#{condition}'" +
" and projects.id not in (select org_projects.project_id from org_projects where organization_id = #{@organization.id})"
#user_projects = Course.find_by_sql(sql)
@projects = Course.find_by_sql(sql)
# @added_course_ids = @organization.projects.map(&:id)
# @projects = []
# user_projects.each do |project|
# if !@added_course_ids.include?(project.id)
# @projects << project
# end
# end
end
def join_projects
@organization = Organization.find(params[:id])
project_ids = params[:projectNames]
project_ids.each do |id|
OrgProject.create(:organization_id => @organization.id, :project_id => id.to_i, :created_at => Time.now)
end
respond_to do |format|
format.js
end
end
def hide_org_subfield
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
@org_subfield.update_attribute(:hide, 1)
end
def show_org_subfield
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
@org_subfield.update_attribute(:hide, 0)
end
end
# encoding: utf-8
class OrganizationsController < ApplicationController
helper :sort
include SortHelper
helper :custom_fields
include CustomFieldsHelper
include AvatarHelper
include WordsHelper
include GitlabHelper
include UserScoreHelper
include PollHelper
helper :user_score
helper :journals
helper :attachments
# added by liuping 关注
helper :watchers
helper :activities
### added by william
include ActsAsTaggableOn::TagsHelper
# fq
helper :words
helper :project_score
helper :issues
include UsersHelper
before_filter :find_organization, :only => [:show, :members]
layout 'base_org'
def index
end
def new
@organization = Organization.new
render :layout => 'new_base'
end
def edit
@organization = Organization.find(params[:id])
end
def destroy
@organization = Organization.find(params[:id])
@organization.destroy
respond_to do |format|
format.html{ redirect_to admin_organization_path }
end
end
def create
@organization = Organization.new
@organization.name = params[:organization][:name]
@organization.description = params[:organization][:description]
@organization.is_public = params[:organization][:is_public]
@organization.creator_id = User.current.id
member = OrgMember.new(:user_id => User.current.id)
@organization.org_members << member
if @organization.save
OrgMemberRole.create(:org_member_id => member.id, :role_id => 11)
redirect_to organization_path(@organization)
end
end
def show
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
@organization = Organization.find(params[:id])
if params[:org_subfield_id]
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
@org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0
@org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10)
else
project_ids = @organization.projects.map(&:id) << 0
course_ids = @organization.courses.map(&:id) << 0
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
case params[:type]
when nil
@org_activities = OrgActivity.where("(container_id =? and container_type =?) " +
"or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')})) "+
"or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))",
@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10)
when 'project_issue'
@org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Issue' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'project_message'
@org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Message' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'org'
@org_activities = OrgActivity.where("container_id =? and container_type =?",@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_homework'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'HomeworkCommon' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_news'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'News' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_message'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Message' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_poll'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Poll' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
end
end
@page = params[:page]
respond_to do |format|
format.html
format.js
end
else
render_403
end
end
def update
@organization = Organization.find(params[:id])
@organization.name = params[:organization][:name]
@organization.description = params[:organization][:description]
@organization.domain = params[:organization][:domain]
@organization.is_public = params[:organization][:is_public] == 'on' ? 1 : 0
#@organization.name = params[:organization][:name]
@organization.save
respond_to do |format|
format.html { redirect_to setting_organization_path(@organization)}
end
end
def check_uniq
@check = false;
@org_name = params[:org_name].strip
@config_page = params[:config_page]
sameName = @config_page ? Organization.where('name = ? and id != ?',params[:org_name],params[:org_id].to_i).count == 0 : Organization.where('name = ?',params[:org_name]).count == 0
if sameName == true
@check = true
end
respond_to do |format|
format.js
end
end
def find_organization
@organization = Organization.find(params[:id])
end
def setting
@organization = Organization.find(params[:id])
if User.current.admin? || User.current.admin_of_org?(@organization)
else
render_403
end
end
def clear_org_avatar_temp
end
def set_homepage
@org = Organization.find(params[:id])
@org.home_id = params[:home_id]
@org.save
# respond_to do |format|
# format.html {redirect_to organization_path(org)}
# end
end
def cancel_homepage
@org = Organization.find(params[:id])
@org.home_id = nil
@org.save
end
def autocomplete_search
@project = Project.find(params[:project_id])
#@flag = params[:flag] || false
respond_to do |format|
format.js
end
end
def members
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
@members = OrgMember.where("organization_id =?", @organization.id)
else
render_403
end
end
def more_org_projects
@organization = Organization.find params[:id]
@page = params[:page]
@org_projects = @organization.projects.reorder('created_at').uniq.page((params[:page].to_i || 1) +1).per(5)
respond_to do |format|
format.js
end
end
def more_org_courses
@organization = Organization.find(params[:id])
@page = params[:page]
@org_courses = @organization.courses.reorder('created_at').uniq.page((params[:page].to_i || 1) + 1 ).per(5)
respond_to do |format|
format.js
end
end
def join_course_menu
@organization = Organization.find(params[:id])
respond_to do |format|
format.js
end
end
def search_courses
@organization = Organization.find(params[:id])
condition = '%%'
if !params[:name].nil?
condition = "%#{params[:name].strip}%".gsub(" ","")
end
sql = "select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.name like '#{condition}'"+
"and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id})"
#user_courses = Course.find_by_sql(sql)
@courses = Course.find_by_sql(sql)
# @added_course_ids = @organization.courses.map(&:id)
# @courses = []
# user_courses.each do |course|
# if !@added_course_ids.include?(course.id)
# @courses << course
# end
# end
end
def join_courses
@organization = Organization.find(params[:id])
course_ids = params[:courseNames]
course_ids.each do |id|
OrgCourse.create(:organization_id => @organization.id, :course_id => id.to_i, :created_at => Time.now)
end
respond_to do |format|
format.js
end
end
def join_project_menu
@organization = Organization.find(params[:id])
respond_to do |format|
format.js
end
end
def logout
logout_user
respond_to do |format|
format.html {redirect_to organization_path(params[:id])}
end
end
def search_projects
@organization = Organization.find(params[:id])
condition = '%%'
if !params[:name].nil?
condition = "%#{params[:name].strip}%".gsub(" ","")
end
sql = "select projects.* from projects inner join members on projects.id = members.project_id where members.user_id = #{User.current.id} and projects.status != 9 and projects.name like '#{condition}'" +
" and projects.id not in (select org_projects.project_id from org_projects where organization_id = #{@organization.id})"
#user_projects = Course.find_by_sql(sql)
@projects = Course.find_by_sql(sql)
# @added_course_ids = @organization.projects.map(&:id)
# @projects = []
# user_projects.each do |project|
# if !@added_course_ids.include?(project.id)
# @projects << project
# end
# end
end
def join_projects
@organization = Organization.find(params[:id])
project_ids = params[:projectNames]
project_ids.each do |id|
OrgProject.create(:organization_id => @organization.id, :project_id => id.to_i, :created_at => Time.now)
end
respond_to do |format|
format.js
end
end
def hide_org_subfield
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
@org_subfield.update_attribute(:hide, 1)
end
def show_org_subfield
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
@org_subfield.update_attribute(:hide, 0)
end
def org_resources_subfield
@org = Organization.find(params[:id])
@subfield = @org.org_subfields.where('field_type = "Resource" ')
respond_to do | format|
format.js
end
end
end

View File

@ -522,7 +522,7 @@ class UsersController < ApplicationController
else
homework.publish_time = params[:homework_common][:publish_time]
end
homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 1
homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 0
homework.homework_type = params[:homework_type].to_i || 1
homework.late_penalty = 10
homework.teacher_priority = 1
@ -619,7 +619,7 @@ class UsersController < ApplicationController
end
if(params[:type].blank? || params[:type] == "1") #全部
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@attachments = Attachment.where("(author_id = #{params[:id]} 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(',')}))").order("created_on desc")
elsif params[:type] == "2" #课程资源
user_course_ids = User.current.courses.map { |c| c.id}
@ -1327,12 +1327,12 @@ class UsersController < ApplicationController
if(params[:type].blank?|| params[:type] == "1") #全部
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 in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@attachments = Attachment.where("(author_id = #{params[:id]} 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(',')}))").order("created_on desc")
else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #Ta的资源库的话应该是他上传的公开资源 加上 他加入的所有我可见课程里的公开资源
@attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 " +
"and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
"and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
end
elsif params[:type] == "2" #课程资源
@ -1389,12 +1389,12 @@ class UsersController < ApplicationController
if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') #全部
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 in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@attachments = Attachment.where("(author_id = #{params[:id]} 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(',')}))").order("created_on desc")
else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #Ta的资源库的话应该是他上传的公开资源 加上 他加入的所有我可见课程里的公开资源
@attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 " +
"and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
"and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
end
elsif params[:type] == "2" #课程资源
@ -1489,11 +1489,23 @@ class UsersController < ApplicationController
unless course_ids.nil?
course_ids.each do |id|
next if ori.blank?
@exist = false
Course.find(id).attachments.each do |att| #如果课程中包含该资源
if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from
att.created_on = Time.now
att.save
@exist = true
break
end
end
next if @exist
attach_copied_obj = ori.copy
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
attach_copied_obj.container = Course.find(id)
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
attach_copied_obj.is_public = 0
attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 4
end
@ -1513,11 +1525,23 @@ class UsersController < ApplicationController
unless course_ids.nil?
course_ids.each do |id|
next if ori.blank?
@exist = false
Course.find(id).attachments.each do |att| #如果课程中包含该资源
if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from
att.created_on = Time.now
att.save
@exist = true
break
end
end
next if @exist
attach_copied_obj = ori.copy
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
attach_copied_obj.container = Course.find(id)
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
attach_copied_obj.is_public = 0
attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 4
end
@ -1530,7 +1554,7 @@ class UsersController < ApplicationController
@flag = false
end
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@attachments = Attachment.where("(author_id = #{params[:id]} 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(',')}))").order("created_on desc")
@type = params[:type]
@limit = 25
@ -1559,11 +1583,23 @@ class UsersController < ApplicationController
unless project_ids.nil?
project_ids.each do |project_id|
next if ori.blank?
@exist = false
Project.find(project_id).attachments.each do |att| #如果课程中包含该资源
if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from
att.created_on = Time.now
att.save
@exist = true
break
end
end
next if @exist
attach_copied_obj = ori.copy
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
attach_copied_obj.container = Project.find(project_id)
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
attach_copied_obj.is_public = 0
attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 1
end
@ -1582,11 +1618,23 @@ class UsersController < ApplicationController
unless project_ids.nil?
project_ids.each do |project_id|
next if ori.blank?
@exist = false
Project.find(project_id).attachments.each do |att| #如果课程中包含该资源
if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from
att.created_on = Time.now
att.save
@exist = true
break
end
end
next if @exist
attach_copied_obj = ori.copy
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
attach_copied_obj.container = Project.find(project_id)
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
attach_copied_obj.is_public = 0
attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 1
end
@ -1598,7 +1646,7 @@ class UsersController < ApplicationController
@flag=true
end
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@attachments = Attachment.where("(author_id = #{params[:id]} 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(',')}))").order("created_on desc")
@type = params[:type]
@limit = 25
@ -1614,6 +1662,97 @@ class UsersController < ApplicationController
end
end
def add_exist_file_to_org
@flag = true
if params[:send_id].present?
send_id = params[:send_id]
subfield_id = params[:subfield]
if subfield_id.nil?
@flag = false
end
ori = Attachment.find_by_id(send_id)
unless subfield_id.nil?
attach_copied_obj = ori.copy
@exist = false
OrgSubfield.find(subfield_id).attachments.each do |att| #如果课程中包含该资源
if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from
att.created_on = Time.now
att.save
@exist = true
break
end
end
if @exist == false #如果不存在该资源
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
attach_copied_obj.container = OrgSubfield.find(subfield_id)
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
attach_copied_obj.is_public = 0
attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 1
end
attach_copied_obj.save
end
end
elsif params[:send_ids].present?
send_ids = params[:send_ids].split(" ")
subfield_id = params[:subfield]
if subfield_id.nil?
@flag = false
end
send_ids.each do |send_id|
ori = Attachment.find_by_id(send_id)
unless subfield_id.nil?
next if ori.blank?
@exist = false
OrgSubfield.find(subfield_id).attachments.each do |att| #如果课程中包含该资源
if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from
att.created_on = Time.now
att.save
@exist = true
break
end
end
next if @exist
attach_copied_obj = ori.copy
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
attach_copied_obj.container = OrgSubfield.find(subfield_id)
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
attach_copied_obj.is_public = 0
attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 1
end
attach_copied_obj.save
end
end
else
@flag=true
end
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} 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(',')}))").order("created_on desc")
@type = params[:type]
@limit = 25
@user = User.current
@is_remote = true
@atta_count = @attachments.count
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
@offset ||= @atta_pages.offset
#@curse_attachments_all = @all_attachments[@offset, @limit]
@attachments = paginateHelper @attachments,25
respond_to do |format|
format.js
end
end
def change_org_subfield
end
# 资源预览
def resource_preview
preview_id = params[:resource_id]
@ -1826,12 +1965,12 @@ class UsersController < ApplicationController
if(params[:type].blank? || params[:type] == "1") #全部
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 in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@attachments = Attachment.where("(author_id = #{params[:id]} 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(',')}))").order("created_on desc")
else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #Ta的资源库的话应该是他上传的公开资源 加上 他加入的所有我可见课程里的公开资源
@attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 " +
"and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
"and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
end
elsif params[:type] == "2" #课程资源
@ -1882,7 +2021,7 @@ class UsersController < ApplicationController
if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') #全部
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 in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@attachments = Attachment.where("((author_id = #{params[:id]} 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 (filename like :p) ",:p=>search).order("created_on desc")
else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中
@ -1955,6 +2094,23 @@ class UsersController < ApplicationController
end
end
def search_user_org
@user = User.current
if !params[:search].nil? #发送到有栏目类型为资源的组织中
search = "%#{params[:search].to_s.strip.downcase}%"
@orgs = @user.organizations.where("name like ?", search).select{|org| OrgSubfield.where("organization_id = #{org.id} and field_type='Resource'").count > 0}
else
@orgs = @user.organizations.select{|org| OrgSubfield.where("organization_id = #{org.id} and field_type='Resource'").count > 0}
end
@search = params[:search]
#这里仅仅是传递需要发送的资源id
@send_id = params[:send_id]
@send_ids = params[:checkbox1] || params[:send_ids]
respond_to do |format|
format.js
end
end
private
def find_user

View File

@ -2588,6 +2588,12 @@ module ApplicationHelper
end
end
def file_preview_eye(file, html_options={})
if %w(pdf pptx doc docx xls xlsx).any?{|x| file.filename.downcase.end_with?(x)}
link_to '', download_named_attachment_path(file.id, file.filename, preview: true),html_options
end
end
#将文本内的/n转换为<br>
def text_format text
text.gsub("&","&amp;").gsub("<","&lt;").gsub(">","&gt;").gsub("\n","<br/>").html_safe

View File

@ -49,6 +49,8 @@ module UsersHelper
'批改附件'
when 'Principal'
'用户资源'
when 'OrgSubfield'
'组织资源'
end
end

View File

@ -32,6 +32,7 @@ class Attachment < ActiveRecord::Base
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# end
include UserScoreHelper
has_many :attachment_histories
validates :filename, presence: true, length: {maximum: 254}
validates :author, presence: true
@ -348,11 +349,18 @@ class Attachment < ActiveRecord::Base
# Deletes the file from the file system if it's not referenced by other attachments
def delete_from_disk
if Attachment.where("disk_filename = ? AND id <> ?", disk_filename, id).empty?
#资源存在且历史记录为0 且 该资源没有存在任何拷贝才能删除资源
if Attachment.where("disk_filename = ? AND id <> ?", disk_filename, id).empty? && self.attachment_histories.count == 0 && Attachment.where('copy_from = ?',self.id) .count == 0
delete_from_disk!
end
end
#有了历史记录的数据记录是不能被删除的。
#true 能被删除 false 不能被删除
def destroyable
self.attachment_histories.count == 0
end
# Returns file's location on disk
def diskfile
File.join(self.class.storage_path, disk_directory.to_s, disk_filename.to_s)

View File

@ -0,0 +1,3 @@
class AttachmentHistory < ActiveRecord::Base
belongs_to :attachment,foreign_key: 'attachment_id'
end

View File

@ -17,10 +17,10 @@
class Journal < ActiveRecord::Base
include UserScoreHelper
belongs_to :journalized, :polymorphic => true
belongs_to :journalized, :polymorphic => true,:touch => true
# added as a quick fix to allow eager loading of the polymorphic association
# since always associated to an issue, for now
belongs_to :issue, :foreign_key => :journalized_id
belongs_to :issue, :foreign_key => :journalized_id,:touch => true
belongs_to :user
has_many :details, :class_name => "JournalDetail", :dependent => :delete_all

View File

@ -196,6 +196,8 @@ class CoursesService
@course.tea_id = current_user.id
@course.term = params[:term]
@course.time = params[:time]
@course.end_term = params[:end_term]
@course.end_time = params[:end_time]
#@course.school_id = params[:occupation]
@course.school_id = current_user.user_extensions.school_id
@course.setup_time = params[:setup_time]

View File

@ -0,0 +1,54 @@
<!--<div class="resourceUploadPopup">-->
<span class="uploadDialogText">更新资源版本</span>
<!--<div class="resourcePopupClose"> <a href="javascript:void(0);" class="resourceClose" onclick="closeModal();"></a></div>-->
<div class="uploadBoxContainer mt0">
<div>
<div>当前版本
<span class="attachment" >
<input readonly="readonly" name="attachments[1][filename]" value="<%=@attachment.filename%>" class="upload_filename readonly" type="text">
</span>
</div>
<% unless @attachment_histories.empty? %>
<div >历史版本</div>
<div style="max-height: 95px;overflow-y:auto; background-color: #e3e3e3;" class="mb10 p10">
<% @attachment_histories.each do |history| %>
<span class="attachment">
<input readonly="readonly" name="attachments_versions_<%= history.id%>" value="<%=history.filename%>" class="upload_filename readonly" type="text">
<span>版本号:<%= history.version %></span>
</span>
<% end %>
</div>
<% end %>
</div>
<%= form_tag(upload_attachment_version_path, :multipart => true,:remote => !ie8?,:name=>"upload_form",:id=>'upload_form') do %>
<%= hidden_field_tag :old_attachment_id,@attachment.id %>
<div>
<span id="attachments_fields" xmlns="http://www.w3.org/1999/html">
</span>
</div>
<div class="uploadBox">
<input type="hidden" name="attachment_type" value="1">
<%= render :partial => 'attachments/upload_attachment_new_version' %>
<div class="cl"></div>
<!--<a href="javascript:void(0);" class=" fr grey_btn mr40" onclick="closeModal();"><%#= l(:button_cancel)%></a>-->
<!--<a id="submit_resource" href="javascript:void(0);" class="blue_btn fr" onclick="submit_resource();"><%#= l(:button_confirm)%></a>-->
</div>
<div class="uploadResourceIntr">
<div class="uploadResourceName fl"><span id="upload_file_count">(未选择文件)</span></div>
<div class="uploadResourceIntr2 fl">您可以上传小于<span class="c_red">50MB</span>的文件</div>
</div>
</div>
<div class="cl"></div>
<div style="margin-top: 10px" >
<div class="courseSendSubmit">
<!--<a href="javascript:void(0);" class="sendSourceText" onclick="">确定</a>-->
<%= submit_tag '确定',:onclick=>'upload_attachment_version(event);',:onfocus=>'this.blur()',:id=>'upload_files_submit_btn',:class=>'sendSourceText' %>
</div>
<div class="courseSendCancel"><a href="javascript:void(0);" id="upload_files_cancle_btn" class="sendSourceText" onclick="hideModal();">取消</a></div>
</div>
<% end %>
<div class="cl"></div>
<!--</div>-->

View File

@ -0,0 +1,23 @@
<!--<button name="button" class="sub_btn" onclick="_file.click()" onmouseover="this.focus()" style="<%#= ie8? ? 'display:none' : ''%>" type="button" ><%#= l(:label_browse) %></button>-->
<a href="javascript:void(0);" class="uploadIcon f14" name="button" onclick="_file.click()" onmouseover="" style="<%= ie8? ? 'display:none' : ''%>">
<span class="chooseFile">选择文件</span></a>
<%= file_field_tag 'attachments[dummy][file]',
:id => '_file',
:class => ie8? ? '':'file_selector',
:multiple => true,
:onchange => 'addInputFiles(this,"'+'upload_files_submit_btn'+'");',
:style => ie8? ? '': 'display:none',
:data => {
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
:upload_path => uploads_path(:format => 'js',:old_attachment_id=>@attachment.id),
:description_placeholder => l(:label_optional_description),
:field_is_public => l(:field_is_public),
:are_you_sure => l(:text_are_you_sure),
:file_count => l(:label_file_count),
:lebel_file_uploding => l(:lebel_file_uploding),
:delete_all_files => l(:text_are_you_sure_all)
} %>

View File

@ -0,0 +1,7 @@
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'attachments/show_attachment_history' )%>');
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","46%");
$('#ajax-modal').parent().addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");

View File

@ -1,2 +1,7 @@
$("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>@attachment.id,:newtype=>(@attachment.is_public? ? 0:1)),
:remote=>true,:class=>"f_l re_open",:method => :post) %>");
$("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>@attachment.id,:newtype=>(@attachment.is_public? ? 0:1)),
:remote=>true,:class=>"postOptionLink",:method => :post) %>");
<%if @attachment.is_public? %>
$("#image_private_<%= @attachment.id%>").html('')
<%else%>
$("#image_private_<%= @attachment.id%>").html('<span class="img_private ml5">私有</span>')
<%end%>

View File

@ -11,4 +11,5 @@ fileSpan.find('a.remove-upload')
})
.off('click');
$('<input>', { type: 'hidden', name: 'attachments[<%= j params[:attachment_id] %>][token]' } ).val('<%= j @attachment.token %>').appendTo(fileSpan);
$('<input>',{type:'hidden',name:'attachments[<%= j params[:attachment_id] %>][attachment_id]'}).val('<%= @attachment.id %>').appendTo(fileSpan);
<% end %>

View File

@ -0,0 +1,7 @@
<% if @flag %>
hideModal();
alert('更新成功')
$(".re_search").submit();
<%else%>
$("#upload_file_count").html('(更新失败)')
<%end %>

View File

@ -4,64 +4,82 @@
<div class="hwork_new">
<ul>
<%= labelled_form_for @course do |f| %>
<li class="ml45">
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
<label><span class="c_red">*</span>&nbsp;<%= l(:label_tags_course_name)%>&nbsp;&nbsp;</label>
<input type="text" name="course[name]" id="course_name" class="courses_input" maxlength="100" onkeyup="regex_course_name();">
<span class="c_red" id="course_name_notice" style="display: none;">课程名称不能为空</span>
</li>
<div class="cl"></div>
<li class="ml45">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_class_period)%>&nbsp;&nbsp;</label>
<input type="text" name="class_period" id="class_period" class="hwork_input02" onkeyup="regex_course_class_period();" maxlength="6">
<span class="c_red" id="course_class_period_notice" style="display: none;"></span>
</li>
<div class="cl"></div>
<li class="ml45 mb10">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_course_term)%>&nbsp;&nbsp;</label>
<%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {} %>
<%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{} %>
</li>
<div class="cl"></div>
<li class="ml45 mb10">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_new_course_password)%>&nbsp;&nbsp;</label>
<input type="text" style="display: none;">
<input type="password" name="course[password]" id="course_course_password" class="hwork_input02" onkeyup="regex_course_password();">
<a id="psw_btn" href="javascript:void(0)">显示明码</a>
<span class="c_red" id="course_course_password_notice"></span>
<li class="ml45">
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
<label><span class="c_red">*</span>&nbsp;<%= l(:label_tags_course_name)%>&nbsp;&nbsp;</label>
<input type="text" name="course[name]" id="course_name" class="courses_input" maxlength="100" onkeyup="regex_course_name();">
<span class="c_red" id="course_name_notice" style="display: none;">课程名称不能为空</span>
</li>
<div class="cl"></div>
<span class=" ml80 c_orange">学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。</span>
</li>
<li class="ml45">
<label class="fl" >&nbsp;&nbsp;<%= l(:label_new_course_description)%>&nbsp;&nbsp;</label>
<textarea name="course[description]" placeholder="最多3000个汉字(或6000个英文字符)" class="courses_text fl" ></textarea>
<li class="ml45">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_class_period)%>&nbsp;&nbsp;</label>
<input type="text" name="class_period" id="class_period" class="hwork_input02" onkeyup="regex_course_class_period();" maxlength="6">
<span class="c_red" id="course_class_period_notice" style="display: none;"></span>
</li>
<div class="cl"></div>
</li>
<li class=" mb5 ml80">
<label >公开&nbsp;&nbsp;</label>
<input id="course_is_public" name="course[is_public]" type="checkbox" value="1">
<span class="c_grey">(打钩为公开,不打钩则不公开,若不公开,仅课程成员可见该课程。)</span>
<li class="ml45 mb10">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_course_term)%>&nbsp;&nbsp;</label>
<%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {} %>
<%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{} %>
<span class="c_red" id="course_time_term_notice"></span>
</li>
<div class="cl"></div>
</li>
<li class=" mb5 ml30">
<label >学生列表公开&nbsp;&nbsp;</label>
<input id="course_open_student" name="course[open_student]" type="checkbox" value="1">
<span class="c_grey">(打钩为"学生列表公开",不打钩为不公开,若不公开,则课程外部人员看不到学生列表)</span>
<li class="ml45 mb10">
<label><span class="c_red">*</span>&nbsp;结束学期&nbsp;&nbsp;</label>
<%= select_tag :end_time,options_for_select(course_time_option(@course.end_time),@course.end_time), {} %>
<%= select_tag :end_term,options_for_select(course_term_option,@course.end_term || cur_course_term),{} %>
<span class="mr15 c_red">仅针对跨越多个学期的班级,否则不用修改。</span>
</li>
<div class="cl"></div>
</li>
<li class=" mb5 ml30">
<li class="ml45 mb10">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_new_course_password)%>&nbsp;&nbsp;</label>
<input type="text" style="display: none;">
<input type="password" name="course[password]" id="course_course_password" class="hwork_input02" onkeyup="regex_course_password();">
<a id="psw_btn" href="javascript:void(0)">显示明码</a>
<span class="c_red" id="course_course_password_notice"></span>
<div class="cl"></div>
<span class="ml80 c_red">学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。</span>
</li>
<li class="ml45">
<label class="fl" >&nbsp;&nbsp;<%= l(:label_new_course_description)%>&nbsp;&nbsp;</label>
<textarea name="course[description]" placeholder="最多3000个汉字(或6000个英文字符)" class="courses_text fl" ></textarea>
<div class="cl"></div>
</li>
<li class=" mb5 ml80">
<label >公开&nbsp;&nbsp;</label>
<input id="course_is_public" name="course[is_public]" type="checkbox" value="1">
<span class="c_grey">(选中后课外用户可见该课程,否则仅对课内成员可见)</span>
<div class="cl"></div>
</li>
<li class=" mb5 ml30">
<label >学生列表公开&nbsp;&nbsp;</label>
<input id="course_open_student" name="course[open_student]" type="checkbox" value="1">
<span class="c_grey">(选中后课外用户可见学生列表,否则仅对课内成员可见)</span>
<div class="cl"></div>
</li>
<li class=" mb5 ml30">
<label >学生上传资源&nbsp;&nbsp;</label>
<input <%= @course.publish_resource == 1 ? 'checked' : ''%> id="course_publish_resource" name="course[publish_resource]" type="checkbox" />
<span class="c_grey">(打钩为"允许学生上传资源",不打钩为"不允许学生上传资源"</span>
<span class="c_grey">选中后允许学生上传课程资源,否则不允许</span>
<div class="cl"></div>
</li>
<li class=" ml90" >
<a href="javascript:void(0)" class="blue_btn fl c_white" onclick="submit_new_course();" >提交</a>
<%= link_to "取消",user_activities_path(User.current.id),:class => "blue_btn grey_btn fl c_white"%>
<div class="cl"></div>
</li>
</li>
<li class=" ml90" >
<a href="javascript:void(0)" class="blue_btn fl c_white" onclick="submit_new_course();" >提交</a>
<%= link_to "取消",user_activities_path(User.current.id),:class => "blue_btn grey_btn fl c_white"%>
<div class="cl"></div>
</li>
<% end%>
</ul>
</div><!--talknew end-->
<div class="cl"></div>
<div class="cl"></div>
<script>
$(function(){
$("#time").change(function(){
document.getElementById("end_time").options[document.getElementById("time").selectedIndex].selected = true;
});
$("#term").change(function(){
document.getElementById("end_term").options[document.getElementById("term").selectedIndex].selected = true;
});
});
</script>

View File

@ -2,11 +2,11 @@
<h2 class="project_h2"><%= l(:label_course_modify_settings)%></h2>
</div>
<script>
$(function(){
<% if @select_tab == 'member'%>
$("#tb_2").click();
<% end %>
})
$(function(){
<% if @select_tab == 'member'%>
$("#tb_2").click();
<% end %>
})
</script>
<div class="hwork_new">
<div id="tb_" class="hwork_tb_">
@ -50,6 +50,12 @@
<%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{:id=>"term_selected"} %>
</li>
<div class="cl"></div>
<li class="ml45 mb10">
<label><span class="c_red">*</span>&nbsp;结束学期&nbsp;&nbsp;</label>
<%= select_tag :end_time,options_for_select(course_time_option(@course.end_time),@course.end_time), {:id=>"end_time_selected"} %>
<%= select_tag :end_term,options_for_select(course_term_option,@course.end_term || cur_course_term),{:id=>"end_term_selected"} %>
</li>
<div class="cl"></div>
<li class="ml45 mb10">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_new_course_password)%>&nbsp;&nbsp;</label>
<input type="password" name="course[password]" id="course_course_password" class="hwork_input02" value="<%= @course.password%>" onkeyup="regex_course_password();">
@ -123,15 +129,17 @@
</div><!--talknew end-->
<div class="cl"></div>
<script type="text/javascript">
function select() {
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'courses/term_select') %>');
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("anonymos");
}
$("#time_selected").click(select);
$("#term_selected").click(select);
function select() {
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'courses/term_select') %>');
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("anonymos");
}
$("#time_selected").click(select);
$("#term_selected").click(select);
$("#end_time_selected").click(select);
$("#end_term_selected").click(select);
</script>

View File

@ -1,4 +1,9 @@
<script>
$(function(){
$("#RSide").removeAttr("id")
$("#container").css('width',"1000px")
});
function searchone4reload(fileid){
var url = "<%= searchone4reload_course_files_path(@course)%>";
var data = {};data.fileid=fileid;
@ -64,33 +69,61 @@
}
</script>
<div class="container">
<div class="resource"><!--资源库内容开始--->
<div class="re_top">
<%= form_tag( search_course_files_path(@course), method: 'get',:class => "re_search f_l",:remote=>true) do %>
<%= text_field_tag 'name', params[:name], name: "name", :class => 're_schbox',:style=>"padding: 0px"%>
<%= submit_tag "课内搜索", :class => "re_schbtn b_lblue",:name => "incourse",:id => "incourse", :onmouseover => "presscss('incourse')",:onmouseout =>"buttoncss()" %>
<%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %>
<div class="homepageRight mt0 ml10">
<div class="homepageRightBanner">
<div class="NewsBannerName">资源库</div>
<ul class="resourcesSelect">
<li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a>
<ul class="resourcesType">
<li><a href="javascript:void(0);" onclick="search_tag_attachment('<%= search_tag_attachment_course_files_path(@course)%>','','<%= @q%>','<%= @course.id%>');" class="resourcesTypeAll resourcesGrey">全部</a></li>
<li><a href="javascript:void(0);" onclick="search_tag_attachment('<%= search_tag_attachment_course_files_path(@course)%>','课件','<%= @q%>','<%= @course.id%>');" class="homepagePostTypeAssignment postTypeGrey">课件</a></li>
<li><a href="javascript:void(0);" onclick="search_tag_attachment('<%= search_tag_attachment_course_files_path(@course)%>','软件','<%= @q%>','<%= @course.id%>');" class="softwareIcon postTypeGrey">软件</a></li>
<li><a href="javascript:void(0);" onclick="search_tag_attachment('<%= search_tag_attachment_course_files_path(@course)%>','媒体','<%= @q%>','<%= @course.id%>');" class="mediaIcon resourcesGrey">媒体</a></li>
<li><a href="javascript:void(0);" onclick="search_tag_attachment('<%= search_tag_attachment_course_files_path(@course)%>','代码','<%= @q%>','<%= @course.id%>');" class="codeIcon resourcesGrey">代码</a></li>
<li><a href="javascript:void(0);" onclick="search_tag_attachment('<%= search_tag_attachment_course_files_path(@course)%>','论文','<%= @q%>','<%= @course.id%>');" class="thesisIcon resourcesGrey">论文</a></li>
<li><a href="javascript:void(0);" onclick="search_tag_attachment('<%= search_tag_attachment_course_files_path(@course,:other=>true)%>','其他','<%= @q%>','<%= @course.id%>');" class="othersIcon resourcesGrey">其它</a></li>
</ul>
</li>
</ul>
</div>
<div class="resources mt10" style="padding-bottom:5px;">
<div class="reTop mb5">
<%= form_tag( search_course_files_path(@course), method: 'get',:class => "re_search",:remote=>true) do %>
<%= text_field_tag 'name', params[:name], name: "name", :class => 'researchBox fl',:style=>"padding: 0px"%>
<%= submit_tag "课内搜索", :class => "blueBtn mr5 fl",:name => "incourse",:id => "incourse" %>
<%= submit_tag "全站搜索", :class => "blueBtn mr5 fl",:name => "insite",:id => "insite" %>
<% if is_course_teacher(User.current,@course) || (@course.publish_resource==1 && User.current.member_of_course?(@course) ) %>
<input class="blueBtn fr mr5" value="上传资源" onclick="course_files_upload();">
<% end %>
<% end %>
<% if is_course_teacher(User.current,@course) || (@course.publish_resource==1 && User.current.member_of_course?(@course) ) %> <!-- show_window('light','fade','20%','35%')-->
<!--<a href="javascript:void(0)" class="re_fabu f_r b_lblue" onclick="show_upload();">上传资源</a>-->
<p class="c_grey fr mt10 mr5">
上传:
<a href="javascript:void(0);" class=" c_dblue font_bold" onclick="show_upload(1);">课件</a>&nbsp;|&nbsp;
<a href="javascript:void(0);" class=" c_dblue font_bold" onclick="show_upload(2);">软件</a>&nbsp;|&nbsp;
<a href="javascript:void(0);" class=" c_dblue font_bold" onclick="show_upload(3);">媒体</a>&nbsp;|&nbsp;
<a href="javascript:void(0);" class=" c_dblue font_bold" onclick="show_upload(4);">代码</a>&nbsp;|&nbsp;
<a href="javascript:void(0);" class=" c_dblue font_bold" onclick="show_upload(6);">论文</a>&nbsp;|&nbsp;
<a href="javascript:void(0);" class=" c_dblue font_bold" onclick="show_upload(5);">其他</a>
<!-- show_window('light','fade','20%','35%')-->
<!--<a href="javascript:void(0)" class="re_fabu f_r b_lblue" onclick="show_upload();">上传资源</a>-->
</div>
<div>
<div class="fileTagWrap" id="files_tag">
<%= render :partial => "files/tag_yun", :locals => {:tag_list => @tag_list,:course => @course,:tag_name => @tag_name}%>
</div>
<div class="cl"></div>
<div class="re_con_top">
<p class="f_l fontBlue f_b f_14">共有&nbsp;<span id="attachment_count"><%= @all_attachments.count%></span>&nbsp;个资源</p>
<p class="f_r" style="color: #808080">
<% if @order == "asc" %>
按&nbsp;<%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>&nbsp;/&nbsp;
<%= link_to "引用次数",params.merge(:sort=>"quotes:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %>&nbsp;排序
<% else %>
按&nbsp;<%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>&nbsp; /&nbsp;
<%= link_to "引用次数",params.merge(:sort=>"quotes:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %>&nbsp;排序
<% end %>
</p>
<% end %>
</div><!---re_top end-->
</div>
</div>
<div class="cl"></div>
<div class="re_con" id="course_list">
<%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %>
</div><!---re_con end-->
</div>
<div id="course_list">
<%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %>
</div>
</div>
<% html_title(l(:label_attachment_plural)) -%>

View File

@ -1,79 +1,90 @@
<% delete_allowed = User.current.allowed_to?(:manage_files, course) %>
<div class="re_con_top">
<p class="f_l c_blue f_b f_14">共有&nbsp;<%= all_attachments.count%>&nbsp;个资源</p>
<p class="f_r" style="color: #808080">
<% if order == "asc" %>
按&nbsp;<%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"downloads"} %>&nbsp;/&nbsp;
<%= link_to "引用次数",params.merge(:sort=>"quotes:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"quotes"} %>&nbsp;排序
<% else %>
按&nbsp;<%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"downloads"} %>&nbsp; /&nbsp;
<%= link_to "引用次数",params.merge(:sort=>"quotes:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"quotes"} %>&nbsp;排序
<% end %>
</p>
</div>
<div class="cl"></div>
<div class="files_tag" id="files_tag">
<%= render :partial => "files/tag_yun", :locals => {:tag_list => @tag_list,:course => course,:tag_name => @tag_name}%>
</div>
<div class="cl"></div>
<div class="for_img_thumbnails">
<% curse_attachments.each do |file| %>
<% if file.is_public? || User.current.member_of_course?(course) || User.current.admin? %>
<div class="re_con_box" id="container_files_<%= file.id %>">
<div class="">
<%= link_to truncate(file.filename,length: 35, omission: '...'),
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 => "c_dblue f_14 f_b f_l" %>
<% if User.current.logged? %>
<% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %>
<%= link_to("选入我的其他课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %>
<div class="resources mt10"><!--资源库内容开始--->
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(file.author), :width => 50, :height => 50), user_path(file.author) %>
</div>
<div class="homepagePostDes">
<div class="homepagePostTitle break_word mt-4">
<%= link_to truncate(file.filename,length: 35, omission: '...'),
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 => "linkBlue f_14 f_b" %>
<%= file_preview_eye(file, class: 'preview') %>
<span id="image_private_<%= file.id%>">
<% if file.is_public? == false%>
<span class="img_private ml5">私有</span>
<%end %>
</span>
</div>
<div class="mt5">
<span class="fontGrey2 mr15 fl">上传时间:<%= format_date(file.created_on)%></span>
<% if file.tag_list.length > 0%>
<span class="fontGrey2 fl mr15">上传类型:<%= file.tag_list[0] %></span>
<% end %>
<p class="f_l mb5 fontGrey2">文件大小:<%= number_to_human_size(file.filesize) %></p>
<p class="fl ml15 fontGrey2">下载<%= file.downloads%>&nbsp;&nbsp;|&nbsp;&nbsp;引用<%= file.quotes.nil? ? 0:file.quotes %> </p>
</div>
<div class="cl"></div>
<div class="tag_h">
<!-- container_type = 1 代表是课程里的资源 -->
<%= render :partial => 'tags/tag_new', :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 class="homepagePostSetting">
<% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %>
<% if @course.is_public? %>
<span id="is_public_<%= file.id %>">
<%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open c_blue",:method => :post %>
</span>
<% else %>
<span id="is_public_<%= file.id %>">
<span class="f_l re_open c_blue">私有</span>
</span>
<% end %>
<ul>
<li class="homepagePostSettingIcon">
<% if User.current.logged? %>
<% else %>
<!-- <#%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> -->
<% end %>
<% else %>
<%= link_to("选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %>
<% end %>
<%= file_preview_tag(file, class: 'f_l re_open') %>
<% else %>
<% end %>
</div>
<div class="cl"></div>
<div class="mt5">
<p class="f_l mb5 c_grey02">文件大小:<%= number_to_human_size(file.filesize) %></p>
<%= link_to( l(:button_delete), attachment_path(file),
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course"%>
<p class="f_r c_grey02" ><%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>&nbsp;&nbsp;|&nbsp;&nbsp;下载<%= file.downloads %>&nbsp;&nbsp;|&nbsp;&nbsp;引用<%= file.quotes.nil? ? 0:file.quotes %> </p>
</div>
<div class="cl"></div>
<div class="tag_h">
<!-- container_type = 1 代表是课程里的资源 -->
<%= render :partial => 'tags/tag_new', :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 class="cl"></div>
</div><!---re_con_box end-->
<% 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" %>
<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}')") %></li>
<li><%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %></li>
<% if @course.is_public? %>
<li>
<span id="is_public_<%= file.id %>">
<%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"postOptionLink",:method => :post %>
</span>
</li>
<%end%>
<li>
<%= 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 %>
</li>
</ul>
<% end %>
<%else%>
<ul class="resourceSendO">
<li><%= link_to("发&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink2",:onclick=>"show_send('#{file.id}')") %></li>
</ul>
<% end %>
<% end %>
</li>
</ul>
</div>
<div class="cl"></div>
</div>
<div class="cl"></div>
</div>
</div>
<% else %>
<div class="re_con_box"><span class='fr mr10 pr_join_span '><%= file.filename %>是私有资源</span></div>
<% end %>
<% end %>
</div>
<ul class="wlist">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
</ul>
<div class="cl"></div>
<% if curse_attachments.count == 10%>
<% if params[:action] == 'search' %>
<%=link_to "点击展开更多", search_course_files_path({:course_id => course.id,:page => @obj_pages.nil? ? @feedback_pages.page + 1 : @obj_pages.page + 1}.merge(params)),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
<%else%>
<!-- 全站搜索的时候 返回的页码对象是obj_pages,而站内搜索返回的页码对象是feedback_pages -->
<%=link_to "点击展开更多", course_files_path({:course_id => course.id,:page => @obj_pages.nil? ? @feedback_pages.page + 1 : @obj_pages.page + 1}.merge(params)),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
<%end%>
<% end%>

View File

@ -8,12 +8,12 @@
<% tag_list.each do |k,v|%>
<% if tag_name && tag_name == k%>
<!-- 鼠标不能移动是因为 href="javascript:void(0);"导致的 -->
<span> <a class="files_tag_select" ondblclick="rename_tag($(this),'<%= k %>','',<%= 6 %>);"><%= k%>(<%= v%>)</a></span>
<span> <a class="files_tag_select" ondblclick="rename_tag($(this),'<%= k %>','',<%= 6 %>);"><%= k%> x<%= v%></a></span>
<% else%>
<span class="files_tag_icon" >
<a title="双击可编辑"
onclick="search_tag_attachment('<%= search_tag_attachment_course_files_path(course)%>','<%= k%>','<%= @q%>','<%= course.id%>');"
ondblclick="rename_tag($(this),'<%= k %>','',<%= 6 %>);"><%= k%>(<%= v%>)</a></span>
ondblclick="rename_tag($(this),'<%= k %>','',<%= 6 %>);"><%= k%> x<%= v%></a></span>
<% end%>
<% end%>
<% end%>

View File

@ -1,12 +1,18 @@
<div id="resource_list">
<% if @container_type == 0 %>
<%= render :partial => 'project_file_new', locals: {project: @project} %>
<div id="resource_list">
<%= render :partial => 'project_file_new', locals: {project: @project} %>
</div>
<% elsif @container_type == 1 %>
<%= render :partial => 'course_file', locals: {course: @course} %>
<div id="resource_list">
<%= render :partial => 'course_file', locals: {course: @course} %>
</div>
<% elsif @container_type == 2 %>
<%= render :partial => 'files/subfield_files', locals: {org_subfield: @org_subfield} %>
<div id="resource_list">
<%= render :partial => 'files/subfield_files', locals: {org_subfield: @org_subfield} %>
</div>
<% end %>
</div>
<script type='text/javascript'>
var slideHeight = 29;
@ -179,6 +185,20 @@
}
function org_id_click(){
var sendText = $("input[name='org_id']:checked").next().text();
var orgDirection = "目标地址:"
$(".orgDirection").text(orgDirection + sendText);
}
function subfield_click(){
var sendText = $("input[name='org_id']:checked").next().text();
var orgDirection = "目标地址:"
var sendColumn = $("input[name='subfield']:checked").next().text();
$(".orgDirection").text(orgDirection + sendText + " / " + sendColumn);
}
function course_attachmenttypes_change(id, type) {
<% if @course%>
$.ajax({
@ -225,6 +245,105 @@
});
}
function observeSearchfieldOnInput(fieldId, url,send_id,send_ids) {
$('#'+fieldId).each(function() {
var $this = $(this);
$this.addClass('autocomplete');
$this.attr('data-value-was', $this.val());
var check = function() {
var val = $this.val();
if ($this.attr('data-value-was') != val){
$this.attr('data-value-was', val);
$.ajax({
url: url,
type: 'get',
data: {search: $this.val(),send_id:send_id,send_ids:send_ids},
success: function(data){ },
beforeSend: function(){ $this.addClass('ajax-loading'); },
complete: function(){ $this.removeClass('ajax-loading'); }
});
}
};
var reset = function() {
if (timer) {
clearInterval(timer);
timer = setInterval(check, 300);
}
};
var timer = setInterval(check, 300);
$this.bind('keyup click mousemove', reset);
});
}
function check_des(event){
if($(".sectionContent").find('input[type="radio"]:checked').length <= 0){
event.preventDefault();
$(".orgDirection").text('目标地址组织不能为空')
return false;
}else if($(".columnContent").find('input[type="radio"]:checked').length <= 0){
event.preventDefault();
$(".orgDirection").text('目标地址栏目不能为空')
return false;
}else{
return true;
}
}
<% if User.current.logged? %>
var sendType = '1';
var lastSendType ;//初始为发送到我的课程
function show_send(id){
if (lastSendType === '2'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
$.ajax({
type: 'get',
url: '<%= search_user_project_user_path(User.current)%>' + '?send_id=' + id
});
}else if(lastSendType == '1'){
$.ajax({
type: 'get',
url: '<%= search_user_course_user_path(User.current)%>' + '?send_id=' + id
});
}else if( lastSendType == '3'){//组织
$.ajax({
type: 'get',
url: '<%= search_user_org_user_path(User.current)%>' + '?send_id=' + id
});
}else{
$.ajax({
type: 'get',
url: '<%= search_user_course_user_path(User.current)%>' + '?send_id=' + id
});
}
}
//id 发送的id
//发送的id数组
function chooseSendType(res_id,res_ids){
sendType = $(".resourcesSendType").val();
if (sendType === lastSendType) {
return;
} else if(lastSendType != null) { //不是第一次点击的时候
if (sendType == '1') {
$.ajax({
type: 'get',
url: '<%= search_user_course_user_path(User.current)%>' + '?send_id=' + res_id
});
} else if(sendType == '2') {
$.ajax({
type: 'get',
url: '<%= search_user_project_user_path(User.current)%>' + '?send_id=' + res_id
});
}else if(sendType == '3'){
$.ajax({
type: 'get',
url: '<%= search_user_org_user_path(User.current)%>' + '?send_id=' + res_id
});
}
}
lastSendType = sendType;
}
<% end %>
<% if @course %>
var tagNameHtml; //当前双击的链接的父节点的html
var tagName; //标签的值
@ -368,6 +487,27 @@
}
<%end %>
function show_attachments_history(){
}
//更新文件版本 表单提交确认,原则是只能有一个更新文件
function upload_attachment_version(event){
if($("#upload_form").find('.upload_filename').length > 1){
$("#upload_file_count").html('(只能上传一个更新文件)')
event.preventDefault();
return false;
}else if($("#upload_form").find('.upload_filename').length == 0){
$("#upload_file_count").html('(请上传一个更新文件)')
event.preventDefault();
return false;
}else{
$("#upload_form").submit();
}
}
</script>

View File

@ -0,0 +1,4 @@
<% if @course %>
$("#show_more_attachments").replaceWith("<%= escape_javascript( render :partial => 'files/course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} )%>");
<%end %>

View File

@ -1 +1,6 @@
$("#course_list").html("<%= escape_javascript(render :partial => 'course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach})%>");
<% if (@obj_pages &&( @obj_pages.page > 1)) || (@feedback_pages && (@feedback_pages.page > 1)) %> //搜索的时候有时候是需要加载下一页,有时候是直接替换当前 #course_list。这个根据 page来判定
$("#show_more_attachments").replaceWith("<%= escape_javascript( render :partial => 'files/course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach} )%>");
<% else %>
$("#course_list").html("<%= escape_javascript(render :partial => 'files/course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach})%>");
$("#attachment_count").html("<%= @result.count%>")
<% end %>

View File

@ -1 +1,2 @@
$("#course_list").html("<%= escape_javascript(render :partial => 'course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach})%>");
$("#course_list").html("<%= escape_javascript(render :partial => 'course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach})%>");
$("#attachment_count").html("<%= @result.count%>")

View File

@ -0,0 +1,2 @@
$(".columnContent").html('<%= escape_javascript( render :partial => 'users/org_resources_subfield',:locals => {:subfield=>@subfield})%>')
$(".orgDirection").text('目标地址:'+'<%= @org.name.html_safe%>')

View File

@ -1,4 +1,4 @@
<div class="resources mt10" id="user_activity_<%= user_activity_id%>">
<div class="resources mt10" id="user_activity_<%= user_activity_id%>" onmouseover="$('#message_setting_<%= user_activity_id%>').show();" onmouseout="$('#message_setting_<%= user_activity_id%>').hide();">
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
@ -43,17 +43,34 @@
<div id="intro_content_show_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div>
<div id="intro_content_hide_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[收起]</a></div>
<div class="cl"></div>
<div class="homepagePostSetting" id="act-<%= user_activity_id %>" style="visibility: hidden">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li><a href="javascript:void(0);" class="postOptionLink">编辑</a></li>
<li><a href="javascript:void(0);" class="postOptionLink">复制</a></li>
<li><a href="javascript:void(0);" class="postOptionLink">删除</a></li>
<% if activity.author.id == User.current.id%>
<div class="homepagePostSetting" id="message_setting_<%= user_activity_id%>" style="display: none">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li>
<%= link_to(
l(:button_edit),
edit_board_message_path(activity.id,:board_id=>activity.board_id),
:class => 'postOptionLink'
) if activity.course_editable_by?(User.current) %>
</li>
<li>
<%= link_to(
l(:button_delete),
delete_board_message_path(activity.id,:board_id=>activity.board_id),
:method => :post,
:data => {:confirm => l(:text_are_you_sure)},
:class => 'postOptionLink'
) if activity.course_destroyable_by?(User.current) %>
<%= link_to "发送",messages_join_org_subfield_path(:message_id => activity.id) , :remote=> true,:class => 'postOptionLink' %>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<% end %>
</div>
<div class="cl"></div>
</div>

View File

@ -0,0 +1,10 @@
<li style="background-color:#f1f1f1; color:#555555; padding-top:2px; padding-bottom:2px;">请选择栏目:</li>
<% unless subfield.nil? || subfield.empty? %>
<% subfield.each do |field| %>
<li>
<label>
<input type="radio" name="subfield" onclick="subfield_click();" value="<%= field.id %>" class="mt3 fl mr5" />
<span><%= field.name %></span></label>
</li>
<%end %>
<%end %>

View File

@ -1,4 +1,4 @@
<div class="resources mt10" id="user_activity_<%= user_activity_id%>">
<div class="resources mt10" id="user_activity_<%= user_activity_id%>" onmouseover="$('#message_setting_<%= user_activity_id%>').show();" onmouseout="$('#message_setting_<%= user_activity_id%>').hide();">
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
@ -44,6 +44,33 @@
<div id="intro_content_show_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div>
<div id="intro_content_hide_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[收起]</a></div>
<div class="cl"></div>
<% if activity.author.id == User.current.id%>
<div class="homepagePostSetting" id="message_setting_<%= user_activity_id%>" style="display: none">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li>
<%= link_to(
l(:button_edit),
edit_board_message_path(activity.id,:board_id=>activity.board_id),
:class => 'postOptionLink'
) if activity.editable_by?(User.current) %>
</li>
<li>
<%= link_to(
l(:button_delete),
delete_board_message_path(activity.id,:board_id=>activity.board_id),
:method => :post,
:data => {:confirm => l(:text_are_you_sure)},
:class => 'postOptionLink'
) if activity.destroyable_by?(User.current) %>
<%= link_to "发送",messages_join_org_subfield_path(:message_id => activity.id) , :remote=> true,:class => 'postOptionLink' %>
</li>
</ul>
</li>
</ul>
</div>
<% end %>
</div>
<div class="cl"></div>
</div>

View File

@ -0,0 +1,58 @@
<div >
<div class="relateText fl mb10 mr5">发送到</div>
<div class="resourcesSendTo mr15">
<select class="resourcesSendType" onclick="chooseSendType('<%= send_id%>','<%= send_ids%>');">
<option value="1">课程</option>
<option value="2">项目</option>
<option value="3" selected>组织</option>
</select>
</div>
<%= form_tag search_user_org_user_path(user),:method => 'get',
:remote=>true,:id=>'search_user_org_form' do %>
<%= hidden_field_tag(:send_id, send_id) %>
<%= hidden_field_tag(:send_ids, send_ids) %>
<input type="text" name="serach" id="search_org_input" value="<%=@search %>" placeholder="输入名称搜索" class="orgSendSearch mt15" />
<script>
observeSearchfieldOnInput('search_org_input','<%= search_user_org_user_path(user)%>','<%= send_id %>','<%= send_ids%>')
</script>
<% end %>
<div class="cl"></div>
</div>
<%= form_tag add_exist_file_to_org_user_path(user),:remote=>true,:id=>'orgs_list_form' do %>
<%= hidden_field_tag(:send_id, send_id) %>
<%= hidden_field_tag(:send_ids, send_ids) %>
<div class="sectionWrap fl mr15">
<ul class="fontGrey3 sectionContent">
<% unless @orgs.empty? %>
<% @orgs.each do |org|%>
<li>
<label>
<input type="radio" name="org_id" value="<%= org.id%>" onchange="change_org_subfield('<%= org_resources_subfield_organization_path(:id=>org.id)%>')" class="mt3 fl mr5" />
<span><%= org.name%></span></label>
</li>
<%end%>
<%end%>
</ul>
</div>
<div class="columnWrap">
<ul class="columnContent">
<!--<span class="fontBlue pl10">请在左侧选择要转发的位置</span>-->
<!--<li style="background-color:#f1f1f1; color:#555555; padding-top:2px; padding-bottom:2px;">请选择栏目:</li>-->
<%= render :partial => 'users/org_resources_subfield',:locals => {:subfield=>nil}%>
<!--<li>-->
<!--<label>-->
<!--<input type="radio" name="sendColumn" class="mt3 fl mr5" />-->
<!--<span>动态</span></label>-->
<!--</li>-->
</ul>
</div>
<div class="cl"></div>
<div class="orgDirection mb10 break_word" style="white-space: nowrap;-o-text-overflow:ellipsis;text-overflow: ellipsis;overflow: hidden">目标地址:</div>
<div class="courseSendSubmit mr15">
<%= submit_tag '确定',:class=>'sendSourceText',:onfocus=>'this.blur();',:onclick=>"check_des(event);" %>
</div>
<div class="courseSendCancel">
<a href="javascript:void(0);" onclick="hideModal();" class="sendSourceText">取消</a>
</div>
<div class="cl"></div>
<%end %>

View File

@ -2,11 +2,12 @@
<div class="boxContainer">
<div>
<div class="sendText fl">将资源发送至</div>
<div class="sendText fl mr10" style="width: auto">发送到</div>
<div class="resourcesSendTo">
<select class="resourcesSendType" onclick="chooseSendType('<%= send_id%>','<%= send_ids%>');">
<option value="1">课程</option>
<option value="2" selected>项目</option>
<option value="3">组织</option>
</select>
</div>
<div class="cl"></div>
@ -47,7 +48,7 @@
<!--<a href="javascript:void(0);" class="sendSourceText">确定</a>-->
<%= submit_tag '确定',:class=>'sendSourceText',:onfocus=>'this.blur();' %>
</div>
<div class="courseSendCancel"><a href="javascript:void(0);" class="sendSourceText" onclick="closePopUp();">取消</a></div>
<div class="courseSendCancel"><a href="javascript:void(0);" class="sendSourceText" onclick="hideModal();">取消</a></div>
</div>
<div class="cl"></div>
<% end %>

View File

@ -2,11 +2,12 @@
<div class="boxContainer">
<div>
<div class="sendText fl">将资源发送至</div>
<div class="sendText fl mr10" style="width: auto">发送到</div>
<div class="resourcesSendTo">
<select class="resourcesSendType" onclick="chooseSendType('<%= send_id%>','<%= send_ids%>');">
<option value="1">课程</option>
<option value="2">项目</option>
<option value="3">组织</option>
</select>
</div>
<div class="cl"></div>
@ -47,7 +48,7 @@
<!--<a href="javascript:void(0);" class="sendSourceText">确定</a>-->
<%= submit_tag '确定',:class=>'sendSourceText',:onfocus=>'this.blur();' %>
</div>
<div class="courseSendCancel"><a href="javascript:void(0);" class="sendSourceText mt10" onclick="closePopUp();">取消</a></div>
<div class="courseSendCancel"><a href="javascript:void(0);" class="sendSourceText mt10" onclick="hideModal();">取消</a></div>
</div>
<div class="cl"></div>
<% end %>

View File

@ -7,7 +7,7 @@
<% attachments.each do |attach| %>
<ul class="resourcesList" onmouseover="if($('#contextMenu').css('display') != 'block')$(this).children().css('background-color', '#e1e1e1')" onmouseout=" if($('#contextMenu').css('display') == 'none')$(this).children().css('background-color', 'white')">
<li class="resourcesListCheckbox fl">
<input name="checkbox1[]" type="checkbox" data-deleteble="<%= User.current.id ==attach.author_id ? 'Y' : 'N' %>" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="resourcesCheckbox" />
<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="resourcesCheckbox" />
</li>
<li class="resourcesListName fl">
<!--<a href="javascript:void(0);" class="resourcesBlack"><%#=truncate(attach.filename,:length=>18)%></a>-->

View File

@ -5,9 +5,9 @@
<script type="text/javascript">
$(function(){
if($.trim($("#anonymous_comment").val()) == 1) {
$("#anonymous_comment").attr('checked',false);
} else {
$("#anonymous_comment").attr('checked',true);
} else {
$("#anonymous_comment").attr('checked',false);
}
$("#BluePopupBox a.BlueCirBtn").click();
<% if edit_mode && homework.is_group_homework? %>
@ -16,9 +16,9 @@
});
function checked_val() {
if ($("#anonymous_comment").is(":checked")) {
$("#anonymous_comment").val(0);
} else {
$("#anonymous_comment").val(1);
} else {
$("#anonymous_comment").val(0);
}
}
</script>
@ -53,8 +53,8 @@
</div>
<% if !edit_mode || edit_mode && homework.homework_detail_manual.comment_status < 2 %>
<div class="fl f14 ml10" style="margin-top: 4px;">
<input type="checkbox" name="homework_common[anonymous_comment]" checked="checked" value="<%=edit_mode ? homework.anonymous_comment : 0 %>" id="anonymous_comment"/>
<span class="f14 c_grey mr10">用匿评</span>
<input type="checkbox" name="homework_common[anonymous_comment]" value="<%=edit_mode ? homework.anonymous_comment : 0 %>" id="anonymous_comment"/>
<span class="f14 c_grey mr10">用匿评</span>
</div>
<% end %>
</div>

View File

@ -4,7 +4,7 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_
$("#res_count").html(0);
$("#checkboxAll").attr('checked',false);
$("#res_all_count").html(<%= @atta_count%>);
closePopUp();
hideModal();
alert("发送成功")
<% else%>
<% end %>

View File

@ -0,0 +1,10 @@
<% if @flag == true%>
$("#search_div").html('<%= escape_javascript( render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} ) %>');
$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>');
$("#res_count").html(0);
$("#checkboxAll").attr('checked',false);
$("#res_all_count").html(<%= @atta_count%>);
hideModal();
alert("发送成功")
<% else%>
<% end %>

View File

@ -4,7 +4,7 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_
$("#res_count").html(0);
$("#checkboxAll").attr('checked',false);
$("#res_all_count").html(<%= @atta_count%>);
closePopUp();
hideModal();
alert("发送成功")
<% else%>
<% end %>

View File

@ -9,10 +9,10 @@
//$("#upload_box").css('left','').css('top','');
//$("#upload_box").html('<%#= escape_javascript( render :partial => "resource_share_popup" ,:locals => {:courses=>@course,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>');
//$("#upload_box").css('display','block');
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'resource_share_popup' ,:locals => {:courses=>@course,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>');
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/resource_share_popup' ,:locals => {:courses=>@course,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>');
showModal('ajax-modal', '452px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='closePopUp();' style='margin-left: 435px;' class='resourceClose'></a>");
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 435px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("popbox").addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");

View File

@ -0,0 +1,9 @@
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/resource_share_for_orgs' ,:locals => {:orgs=>@orgs,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>');
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","").css("left","");
$('#ajax-modal').parent().addClass("popbox").addClass("shareDP");
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");
var val = $("#search_org_input").val();
$("#search_org_input").val("").focus().val(val);

View File

@ -8,7 +8,7 @@
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'resource_share_for_project_popup' ,:locals => {:projects=>@projects,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>');
showModal('ajax-modal', '452px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='closePopUp();' style='margin-left: 435px;' class='resourceClose'></a>");
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 435px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("resourceUploadPopup").addClass("popbox")
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");

View File

@ -41,6 +41,20 @@
function submit_files(){
$("#upload_form").submit();
}
function check_des(event){
if($(".sectionContent").find('input[type="radio"]:checked').length <= 0){
event.preventDefault();
$(".orgDirection").text('目标地址组织不能为空')
return false;
}else if($(".columnContent").find('input[type="radio"]:checked').length <= 0){
event.preventDefault();
$(".orgDirection").text('目标地址栏目不能为空')
return false;
}else{
return true;
}
}
</script>
<div class="homepageRightBanner">
<div class="NewsBannerName">资源库</div>
@ -294,10 +308,15 @@
//批量删除
function batch_delete(){
var data = $("#resources_list_form").serialize();
if($("input[type=checkbox][data-has-history=Y]:checked").length != 0){
alert("您只能删除没有历史记录的资源,请重新选择后再删除。");
return;
}
if($("input[type=checkbox][data-deleteble=N]:checked").length != 0){
alert("您只能删除自己上传的资源,请重新选择后再删除。");
return;
}
if(data != "" && confirm('确认要删除这些资源吗?')) {
$.post(
'<%= user_resource_delete_user_path(@user)%>',
@ -441,6 +460,10 @@
line.children().css("background-color", 'white');
id = line.children().last().html();
user_id = line.children().eq(5).html();
if(line.children().first().children().data('hasHistory') == 'Y'){
alert('该资源存在历史版本,不能删除');
return;
}
if(user_id === '<%= User.current.id%>') {
if (confirm('确定要删除资源"' + line.children().eq(1).children().attr('title').trim() + '"么?')) {
$.ajax({
@ -467,11 +490,17 @@
type: 'get',
url: '<%= search_user_course_user_path(@user)%>' + '?send_id=' + id
});
} else {
} else if(sendType === '2') {
$.ajax({
type: 'get',
url: '<%= search_user_project_user_path(@user)%>' + '?send_id=' + id
});
}else if(sendType ==='3')
{
$.ajax({
type: 'get',
url: '<%= search_user_org_user_path(@user)%>' + '?send_id=' + res_id
});
}
}else{//如果是多个发送
if (sendType === '1'){
@ -479,11 +508,16 @@
type: 'get',
url: '<%= search_user_course_user_path(@user)%>' + '?'+ $("#resources_list_form").serialize()
});
}else{
}else if(sendType === '2'){
$.ajax({
type: 'get',
url: '<%= search_user_project_user_path(@user)%>' + '?' + $("#resources_list_form").serialize()
});
}else if(sendType === '3'){
$.ajax({
type: 'get',
url: '<%= search_user_org_user_path(User.current)%>' + '?'+$("#resources_list_form").serialize()
});
}
}
}
@ -521,5 +555,12 @@
});
}
function subfield_click(){
var sendText = $("input[name='org_id']:checked").next().text();
var orgDirection = "目标地址:"
var sendColumn = $("input[name='subfield']:checked").next().text();
$(".orgDirection").text(orgDirection + sendText + " / " + sendColumn);
}
</script>

View File

@ -15,7 +15,7 @@ en:
label_homework: Task
label_course_news: 课程通知
label_main_teacher: 主讲教师
label_course_term: 课学期
label_course_term: 始学期
label_join_course: 加入
label_exit_course: exit course

View File

@ -19,7 +19,7 @@ zh:
label_course_news: 课程通知
label_course_mail_news_reply: 课程通知回复
label_main_teacher: 主讲教师
label_course_term: 学期
label_course_term: 学期
label_isuue_mail_status: 更新了issue状态
label_join_course: 加入

View File

@ -47,6 +47,7 @@ RedmineApp::Application.routes.draw do
post 'join_project_menu'
post 'join_projects'
post 'logout'
get 'org_resources_subfield'
end
collection do
get 'check_uniq'
@ -415,12 +416,12 @@ RedmineApp::Application.routes.draw do
match 'boards/:id/join_to_org_subfields', :to => 'boards#join_to_org_subfields'
get 'boards/:board_id/topics/:id', :to => 'messages#show', :as => 'board_message'
match 'boards/:board_id/topics/quote/:id', :to => 'messages#quote', :via => [:get, :post]
get 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
get 'boards/:board_id/topics/:id/edit', :to => 'messages#edit',:as=>'edit_board_message'
post 'boards/:board_id/topics/preview', :to => 'messages#preview', :as => 'preview_board_message'
post 'boards/:board_id/topics/:id/replies', :to => 'messages#reply'
post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy'
post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy',:as=>'delete_board_message'
match 'messages/join_org_subfield', :to => 'messages#join_org_subfield'
match 'messages/get_subfield_on_click_org', :to => 'messages#get_subfield_on_click_org'
match 'messages/join_org_subfields', :to => 'messages#join_org_subfields'
@ -512,6 +513,7 @@ RedmineApp::Application.routes.draw do
get "search_user_course"
post "add_exist_file_to_course"
post "add_exist_file_to_project"
post 'add_exist_file_to_org'
get 'resource_preview'
get 'rename_resource'
get 'search_user_project'
@ -522,6 +524,8 @@ RedmineApp::Application.routes.draw do
get 'store_selected_resource'
get 'user_organizations'
get 'search_user_orgs'
get 'search_user_org' #for send resource
# end
end
#resources :blogs
@ -813,6 +817,8 @@ RedmineApp::Application.routes.draw do
# 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/attachment_versions/:id',:to=>'attachments#attachment_versions',:as=>'attachments_versions'
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', :to => 'attachments#download', :id => /\d+/
get 'attachments/thumbnail/:id(/:size)', :to => 'attachments#thumbnail', :id => /\d+/, :size => /\d+/, :as => 'thumbnail'

View File

@ -0,0 +1,24 @@
class CreateAttachmentHistories < ActiveRecord::Migration
def change
create_table :attachment_histories do |t|
t.integer :container_id
t.string :container_type
t.string :filename , :default => ""
t.string :disk_filename, :default => ""
t.integer :filesize, :default => 0
t.string :content_type, :default => ""
t.string :digest , :default => "",:limit=>40
t.integer :downloads, :default => 0
t.integer :author_id
t.datetime :created_on
t.string :description
t.string :disk_directory
t.integer :attachtype
t.integer :is_public
t.integer :copy_from
t.integer :quotes
t.integer :version
t.integer :version_id
end
end
end

View File

@ -0,0 +1,8 @@
class RenameAttachmentHistoriesColumnVersionIdToAttachmentId < ActiveRecord::Migration
def up
rename_column :attachment_histories,:version_id,:attachment_id
end
def down
end
end

View File

@ -0,0 +1,17 @@
class AddLastTermToCourse < ActiveRecord::Migration
def change
add_column :courses, :end_time, :integer
add_column :courses, :end_term, :string
count = Course.all.count / 30 + 2
transaction do
for i in 1 ... count do
Course.page(i).per(30).each do |course|
course.end_time = course.time
course.end_term = course.term
course.save
end
end
end
end
end

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

@ -978,6 +978,15 @@ $(document).ready(function () {
}
});
//点击发送资源弹出框中的组织,要更改选择栏目中的内容
//@dom 选中的radio值为org_id
function change_org_subfield(url){
$.ajax({
type:'get',
url:url
})
}
//点击图片即显示大图
function showNormalImage(id) {
var description_images=$('div#'+id).find("img");
@ -1001,4 +1010,4 @@ $(function(){
var userId = $(this).attr('data-user-id');
$(window.location).attr('href', '/users/'+userId);
});
});
});

View File

@ -119,6 +119,46 @@ function regex_course_class_period()
return false;
}
}
//验证开始学期和结束学期
function regex_time_term(){
var obj_time = document.getElementById("time");
var obj_end_time = document.getElementById("end_time");
var obj_term = document.getElementById("term");
var obj_end_term = document.getElementById("end_term");
var time = obj_time.options[obj_time.selectedIndex];
var end_time = obj_end_time.options[obj_end_time.selectedIndex];
var term = obj_term.options[obj_term.selectedIndex];
var end_term = obj_end_term.options[obj_end_term.selectedIndex];
if(time.value == end_time.value) {
if(set_term_val(term.value) > set_term_val(end_term.value)) {
$("#course_time_term_notice").html("开始学期不能晚于结束学期");
$("#course_time_term_notice").show();
return false;
} else {
$("#course_time_term_notice").html("");
$("#course_time_term_notice").hide();
return true;
}
} else if(time.value < end_time.value) {
$("#course_time_term_notice").html("");
$("#course_time_term_notice").hide();
return true;
} else {
$("#course_time_term_notice").html("开始学期不能晚于结束学期");
$("#course_time_term_notice").show();
return false;
}
}
//学期转换为数字
function set_term_val(val) {
if(val == "春季学期"){
return 1;
} else if(val == "夏季学期"){
return 2;
} else if(val == "秋季学期"){
return 3;
}
}
//验证密码
function regex_course_password()
{
@ -145,7 +185,7 @@ function regex_course_password()
//提交新建课程
function submit_new_course()
{
if(regex_course_name()&&regex_course_class_period()&&regex_course_password())
if(regex_course_name()&&regex_course_class_period()&&regex_time_term()&&regex_course_password())
{
$("#new_course").submit();
}

View File

@ -154,9 +154,12 @@ a.postReplyCancel:hover {color:#ffffff;}
.homepagePostSetting ul li:hover ul {display:block;}
.homepagePostSettingIcon {background:url(../images/homepage_icon.png) -93px -5px no-repeat; width:20px; height:20px;}
.homepagePostSettiongText {width:85px; line-height:2; font-size:12px; color:#616060; background-color:#ffffff; border:1px solid #eaeaea; border-radius:3px; position:absolute; left:-68px; top:20px; padding:5px 0px; display:none;}
.resourceSendO {width:65px; line-height:2; font-size:12px; color:#616060; background-color:#ffffff; border:1px solid #eaeaea; border-radius:3px; position:absolute; left:-48px; top:20px; padding:2px 0px; display:none;}
.homepagePostSettingIcon:hover {background:url(../images/homepage_icon.png) -93px -44px no-repeat;cursor: pointer}
a.postOptionLink {color:#616060; display:block; width:55px; padding:0px 15px; text-align:center;}
a.postOptionLink:hover {color:#ffffff; background-color:#269ac9;}
a.postOptionLink2 {color:#616060; display:block; width:35px; padding:0px 15px;}
a.postOptionLink2:hover {color:#ffffff; background-color:#269ac9;}
.homepagePostReplyPortrait {float:left; width:33px;}
.imageFuzzy {filter:alpha(opacity=50); -moz-opacity:0.5; -khtml-opacity:0.5;opacity: 0.5;}
.homepagePostReplyDes {float:left; width:632px; margin-left:15px;}
@ -756,7 +759,14 @@ a.wzan_visited{background:url(../images/new_project/public_icon.png) 0px -503px
.files_tag{ width:670px; min-height:22px;margin-bottom:10px;}/* overflow:hidden; */
/*padding:1px 10px 修改原因padding会导致内部输入框和外边框有边距*/
a.files_tag_icon{ width:auto;background:#e2f3f9; color:#54aeca; border:1px solid #bbe2ef; padding:1px 5px; float:left; margin-right:10px;margin-bottom:10px; }
span.files_tag_icon{ width:auto;background:#e2f3f9; color:#54aeca; border:1px solid #bbe2ef; padding:1px 5px; float:left; margin-right:10px;margin-bottom:10px;cursor: pointer }
span.files_tag_icon{ width: auto;
background: #E1ECF4;
color: #39739D;
padding: 2px 5px;
float: left;
margin-right: 10px;
margin-bottom: 10px;
cursor: pointer; }
a.files_tag_select{ background:#64bdd9; color:#fff; border:1px solid #bbe2ef; padding:1px 1px; float:left; margin-right:10px;margin-bottom:10px;}/* padding:1px 10px;*/
/* 20150423作业评分*/
@ -1232,6 +1242,9 @@ div.disable_link {background-color: #c1c1c1 !important;}
/*新课程资源库*/
.reCon{ margin:5px; width:710px;}
.reTop{width:710px; height:40px; background:#eaeaea; padding:5px;}
.researchBox { width:240px; height:24px; border:1px solid #dddddd; color:#666666; outline:none;}
.blueBtn{ width:60px; height:26px; color:#FFF; border:none; background-color:#269ac9; cursor:pointer; padding-left:0px; text-align:center;}
.blueBtn:hover {background-color:#298fbd;}
/*问题状态图片*/
.issues{ background:url(../images/public_icon.png) -66px 5px no-repeat; width:18px; height:21px;}
@ -1240,4 +1253,9 @@ div.disable_link {background-color: #c1c1c1 !important;}
.function{ background:url(../images/public_icon.png) -66px -70px no-repeat; width:18px; height:21px;}
.weekly{ background:url(../images/public_icon.png) -66px -95px no-repeat; width:18px; height:21px;}
.reCon{ margin:5px; width:710px;}
.reTop{width:710px; height:40px; background:#eaeaea; padding:5px;}
.filesTag{ width:auto;background:#e2f3f9; color:#54aeca; border:1px solid #bbe2ef; padding:1px 5px; float:left; margin-right:10px;cursor: pointer }
.fileTagWrap{ width:710px;}
.boxShadow {box-shadow:0px 2px 8px rgba(146, 153, 169, 0.5);}

View File

@ -1396,3 +1396,19 @@ span.at {color:#269ac9;}
.function{ background:url(../images/public_icon.png) -66px -70px no-repeat; width:18px; height:21px;}
.weekly{ background:url(../images/public_icon.png) -66px -95px no-repeat; width:18px; height:21px;}
/*资源发送到org*/
.shareDP {width:415px; height:auto; border:3px solid #269ac9; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:relative; z-index:1000;}
.shareArrow {background:url(../images/arrowList.png) -90px -108px no-repeat; display:inline-block; width:5px; height:10px; margin-right:3px;}
.sectionWrap {float:left; max-height:150px; margin-bottom:10px; overflow:auto; overflow-x:hidden; width:205px; min-height:150px; padding-top:5px; border:1px solid #dddddd;}
.columnWrap {float:left; max-height:155px; margin-bottom:10px; overflow:auto; overflow-x:hidden; width:178px; min-height:155px; border:1px solid #dddddd;}
.columnWrap li {padding-left:10px; color:#585858; line-height:20px;}
.columnWrap li:hover {background-color:#cccccc;}
.columnWrap span {width:150px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; display:inline-block; height:20px; vertical-align:top;}
.sectionRow:hover {background-color:#cccccc; cursor:pointer;}
.sectionContent {}
.sectionContent li {padding-left:10px; line-height:20px;}
.sectionContent li:hover {background-color:#cccccc;}
.sectionContent span {width:160px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; display:inline-block; height:20px; vertical-align:top;}
.orgDirection {width:392px; background-color:#f1f1f1; height:30px; vertical-align:middle; line-height:30px; color:#585858; padding-left:10px;}
.orgSendSearch {border:1px solid #dddddd; outline:none; width:262px; height:22px; padding-left:10px; float:left;}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :attachment_history do
end
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe AttachmentHistory, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end