|
|
|
@ -26,6 +26,18 @@ class FilesController < ApplicationController
|
|
|
|
|
include SortHelper
|
|
|
|
|
helper :project_score
|
|
|
|
|
|
|
|
|
|
def show_attachments obj
|
|
|
|
|
all_attachments = []
|
|
|
|
|
obj.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]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
|
#sort_init 'filename', 'asc'
|
|
|
|
|
sort_init 'created_on', 'desc'
|
|
|
|
@ -39,15 +51,7 @@ class FilesController < ApplicationController
|
|
|
|
|
@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]
|
|
|
|
|
show_attachments @containers
|
|
|
|
|
|
|
|
|
|
render :layout => !request.xhr?
|
|
|
|
|
elsif params[:course_id]
|
|
|
|
@ -79,16 +83,7 @@ class FilesController < ApplicationController
|
|
|
|
|
@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]
|
|
|
|
|
show_attachments @containers
|
|
|
|
|
|
|
|
|
|
render :layout => 'base_courses'
|
|
|
|
|
end
|
|
|
|
@ -133,6 +128,8 @@ class FilesController < ApplicationController
|
|
|
|
|
@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
|
|
|
|
|
|
|
|
|
|
show_attachments @containers
|
|
|
|
|
|
|
|
|
|
@attachtype = 0
|
|
|
|
|
@contenttype = 0
|
|
|
|
|
|
|
|
|
@ -159,6 +156,8 @@ class FilesController < ApplicationController
|
|
|
|
|
|
|
|
|
|
@containers = [Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)]
|
|
|
|
|
|
|
|
|
|
show_attachments @containers
|
|
|
|
|
|
|
|
|
|
@attachtype = 0
|
|
|
|
|
@contenttype = 0
|
|
|
|
|
|
|
|
|
|