diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 3d4d33be8..b4b92cc38 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -162,16 +162,21 @@ class FilesController < ApplicationController end # 返回制定资源类型的资源列表 + # added by nwb def getattachtype sort_init 'created_on', 'desc' sort_update 'created_on' => "#{Attachment.table_name}.created_on", 'filename' => "#{Attachment.table_name}.filename", 'size' => "#{Attachment.table_name}.filesize", 'downloads' => "#{Attachment.table_name}.downloads" - - @containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] #modify by Long Jun - @containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort - + + if @project + @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 + elsif @course + @containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)] + end + @attachtype = params[:type].to_i @contenttype = params[:contentType].to_s diff --git a/app/views/files/_course_sort_by_attachtypel.html.erb b/app/views/files/_course_sort_by_attachtypel.html.erb new file mode 100644 index 000000000..fe3311bdd --- /dev/null +++ b/app/views/files/_course_sort_by_attachtypel.html.erb @@ -0,0 +1,71 @@ +<% selAttachType =@attachtype %> +<% selContentType =@contenttype %> +<% attachmenttypes = @course.attachmenttypes %> +<% delete_allowed = User.current.allowed_to?(:manage_files, @course) %> +<% edit_allowed = User.current.allowed_to?(:manage_files, @course) %> +
<%= 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 %> + + + <%= render :partial => 'attachments/type_edit', :locals => {:attachmenttypes => attachmenttypes, + :attachment => file,:contentype=>selContentType} %> + + | +<%= file.show_suffix_type %> | +<%= file.downloads %> | + ++ <%= link_to(image_tag('delete.png'), attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> + | +
+ | + + +