From 2c77d1b4cf5df9a214d1ca9b249fd74bfd14dc7a Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 5 Aug 2014 11:10:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BF=E9=97=AE=E8=B5=84=E6=BA=90=E5=BA=93?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 14 +++++++++++++- app/helpers/project_score_helper.rb | 5 +++++ app/models/attachment.rb | 2 +- .../files/_course_show_all_attachment.html.erb | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) 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} %>