diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index 9ce76dca8..36093f33b 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -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])
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index 121cd3a42..5cbf1ab2f 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -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
diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb
index 46362c2d3..d345fba5f 100644
--- a/app/controllers/homework_common_controller.rb
+++ b/app/controllers/homework_common_controller.rb
@@ -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
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index 77dc1a9aa..c3f926867 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -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]
diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb
index dabf45da8..45256bb1b 100644
--- a/app/controllers/organizations_controller.rb
+++ b/app/controllers/organizations_controller.rb
@@ -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
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 78d8e2b46..b4891f12b 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -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,94 @@ 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
+ @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 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
@@ -1614,6 +1749,10 @@ class UsersController < ApplicationController
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
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 4bdffb9dc..55a017019 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -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转换为
def text_format text
text.gsub("&","&").gsub("<","<").gsub(">",">").gsub("\n","
").html_safe
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 963284f7f..d1ab6661a 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -49,6 +49,8 @@ module UsersHelper
'批改附件'
when 'Principal'
'用户资源'
+ when 'OrgSubfield'
+ '组织资源'
end
end
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index ad5655b02..c8fe0811e 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -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)
diff --git a/app/models/attachment_history.rb b/app/models/attachment_history.rb
new file mode 100644
index 000000000..2160d242d
--- /dev/null
+++ b/app/models/attachment_history.rb
@@ -0,0 +1,3 @@
+class AttachmentHistory < ActiveRecord::Base
+ belongs_to :attachment,foreign_key: 'attachment_id'
+end
diff --git a/app/models/journal.rb b/app/models/journal.rb
index 638a98006..a66c4327a 100644
--- a/app/models/journal.rb
+++ b/app/models/journal.rb
@@ -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
diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb
index 5d60238bf..aabe1a921 100644
--- a/app/services/courses_service.rb
+++ b/app/services/courses_service.rb
@@ -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]
diff --git a/app/views/attachments/_show_attachment_history.html.erb b/app/views/attachments/_show_attachment_history.html.erb
new file mode 100644
index 000000000..c1a6464e8
--- /dev/null
+++ b/app/views/attachments/_show_attachment_history.html.erb
@@ -0,0 +1,54 @@
+
+更新资源版本
+
+
共有 <%= @all_attachments.count%> 个资源
++ <% if @order == "asc" %> + 按 <%= 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"} %> / + <%= 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"} %> / + <%= 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"} %> 排序 + <% else %> + 按 <%= 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"} %> / + <%= 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"} %> / + <%= 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"} %> 排序 + <% end %>
- <% end %> -共有 <%= all_attachments.count%> 个资源
-- <% if order == "asc" %> - 按 <%= 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"} %> / - <%= 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"} %> / - <%= 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"} %> 排序 - <% else %> - 按 <%= 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"} %> / - <%= 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"} %> / - <%= 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"} %> 排序 - <% end %> -
-文件大小:<%= number_to_human_size(file.filesize) %>
+下载<%= file.downloads%> | 引用<%= file.quotes.nil? ? 0:file.quotes %>
+文件大小:<%= number_to_human_size(file.filesize) %>
- <%= 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"%> -<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %> | 下载<%= file.downloads %> | 引用<%= file.quotes.nil? ? 0:file.quotes %>
-