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) -%> - + <%# @containers.each do |container| %> + <%# next if container.attachments.empty? -%> + <%# if container.is_a?(Version) -%> + - <%= number_to_human_size(file.filesize) %> - - <%= file.attachmentstype.typeName unless file.attachmentstype.nil? %> + --> + <%# end -%> + <% if @curse_attachments != nil %> + <% @curse_attachments.each do |file| %> + <%if file.is_public == 0 && !User.current.member_of_course?(@course)%> + <%next%> + <%end%> + "> + <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %> + + <%= number_to_human_size(file.filesize) %> + + <%= file.attachmentstype.typeName unless file.attachmentstype.nil? %> <%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes, :attachment => file, :contentype => selContentType} %> - - <%= file.show_suffix_type %> - - <%= file.file_dense_str %> -   + + <%= file.show_suffix_type %> + + <%= file.file_dense_str %> +   <%= render :partial => 'course_file_dense_edit', :locals => {:file_dense_list => file.file_dense_list, :attachment => file} %> - - <%= file.downloads %> - - - <%= link_to(image_tag('delete.png'), attachment_path(file), - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> - - - - -
- <%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> - <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %> -
-
- - - - <% end -%> - <% reset_cycle %> + + <%= file.downloads %> + + + <%= link_to(image_tag('delete.png'), attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> + + + + +
+ <%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> + <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %> +
+
+ + + <% end -%> + <% end %> + <%# reset_cycle %> + <%# end -%> + + + + diff --git a/app/views/files/_show_all_attachment.html.erb b/app/views/files/_show_all_attachment.html.erb index 838153c78..043fe1183 100644 --- a/app/views/files/_show_all_attachment.html.erb +++ b/app/views/files/_show_all_attachment.html.erb @@ -25,16 +25,17 @@ - <% @containers.each do |container| %> - <% next if container.attachments.empty? -%> - <% if container.is_a?(Version) -%> - + <%# @containers.each do |container| %> + <%# next if container.attachments.empty? -%> + <%# if container.is_a?(Version) -%> + + <%# end -%> + <% if @curse_attachments != nil %> + <% @curse_attachments.each do |file| %> <%if file.is_public == 0 && !User.current.member_of?(@project)%> <%next%> <%end%> @@ -75,10 +76,17 @@ <% end -%> - <% reset_cycle %> + <%# reset_cycle %> <% end -%> + + +