diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index a8ba3d426..e619ef843 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -40,7 +40,19 @@ class FilesController < ApplicationController render :layout => !request.xhr? elsif params[:course_id] @isproject = false - @containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)] + + if params[:sort] + @oder = params[:sort].split(",")[0] + @order_by = @oder.split(":")[0] + @order_tyoe = @oder.split(":")[1] + if @order_by == "size" + @order_by = "filesize" + end + @containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.#{@order_by} #{@order_tyoe}").find(@course.id)] + else + @containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)] + end + render :layout => 'base_courses' end end diff --git a/app/helpers/project_score_helper.rb b/app/helpers/project_score_helper.rb index 3df2e05b5..fe7c8307e 100644 --- a/app/helpers/project_score_helper.rb +++ b/app/helpers/project_score_helper.rb @@ -2,7 +2,12 @@ class ProjectScoreHelper #缺陷数量 def issue_num project + project.issues.count + end + #缺陷留言数量 + def issue_journal_num project + project end end \ No newline at end of file diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 85f36fc5f..67e46eb5e 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -193,7 +193,7 @@ class Attachment < ActiveRecord::Base def show_suffix_type suffix = 'other' temp = self.suffix_type.downcase - if self.attachmentstype.suffixArr.include?(temp) + if self.attachmentstype && self.attachmentstype.suffixArr.include?(temp) suffix = temp end suffix diff --git a/app/views/files/_course_show_all_attachment.html.erb b/app/views/files/_course_show_all_attachment.html.erb index f94ddc20b..abece1ae1 100644 --- a/app/views/files/_course_show_all_attachment.html.erb +++ b/app/views/files/_course_show_all_attachment.html.erb @@ -43,7 +43,7 @@ <%= number_to_human_size(file.filesize) %> - <%= file.attachmentstype.typeName %> + <%= file.attachmentstype.typeName unless file.attachmentstype.nil? %> <%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes, :attachment => file, :contentype => selContentType} %>