From 16d86a1fbd2596a9e3381a84b5980c82cf85788a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 21 Aug 2014 10:37:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E3=80=81=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E5=A2=9E=E5=8A=A0=E5=88=86=E9=A1=B5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 23 +++++ app/models/attachment.rb | 6 +- .../_course_show_all_attachment.html.erb | 94 ++++++++++--------- app/views/files/_show_all_attachment.html.erb | 26 +++-- 4 files changed, 95 insertions(+), 54 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index c80ce6d69..666c39d30 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -38,6 +38,17 @@ class FilesController < ApplicationController @isproject = true @containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] @containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort + + all_attachments = [] + @containers.each do |container| + all_attachments += container.attachments + end + @limit = 10 + @feedback_count = all_attachments.count + @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @offset ||= @feedback_pages.offset + @curse_attachments = all_attachments[@offset, @limit] + render :layout => !request.xhr? elsif params[:course_id] @isproject = false @@ -67,6 +78,18 @@ class FilesController < ApplicationController else @containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on desc").find(@course.id)] end + + all_attachments = [] + @containers.each do |container| + all_attachments += container.attachments + end + + @limit = 10 + @feedback_count = all_attachments.count + @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @offset ||= @feedback_pages.offset + @curse_attachments = all_attachments[@offset, @limit] + render :layout => 'base_courses' end end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 8f3d68d02..e25434e6e 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -29,9 +29,9 @@ class Attachment < ActiveRecord::Base include UserScoreHelper validates_presence_of :filename, :author - validates_length_of :filename, :maximum => 255 - validates_length_of :disk_filename, :maximum => 255 - validates_length_of :description, :maximum => 255 + validates_length_of :filename, :maximum => 254 + validates_length_of :disk_filename, :maximum => 254 + validates_length_of :description, :maximum => 254 validate :validate_max_file_size diff --git a/app/views/files/_course_show_all_attachment.html.erb b/app/views/files/_course_show_all_attachment.html.erb index 76112bc78..f70142a05 100644 --- a/app/views/files/_course_show_all_attachment.html.erb +++ b/app/views/files/_course_show_all_attachment.html.erb @@ -25,60 +25,70 @@
- <% @containers.each do |container| %> - <% next if container.attachments.empty? -%> - <% if container.is_a?(Version) -%> -