修复课程、项目无法上传资源的问题

This commit is contained in:
sw 2014-08-22 12:32:16 +08:00
parent d608d092da
commit c6a19209f4
2 changed files with 26 additions and 27 deletions

View File

@ -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

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140812065417) do
ActiveRecord::Schema.define(:version => 20140814062455) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -441,21 +441,21 @@ ActiveRecord::Schema.define(:version => 20140812065417) do
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "sort_type"
t.integer "image_width", :default => 107
t.integer "image_height", :default => 63
t.integer "show_course", :default => 1
t.integer "show_contest", :default => 1
t.integer "image_width", :default => 107
t.integer "image_height", :default => 63
end
create_table "forums", :force => true do |t|
t.string "name", :null => false
t.string "description", :default => ""
t.string "name", :null => false
t.text "description"
t.integer "topic_count", :default => 0
t.integer "memo_count", :default => 0
t.integer "last_memo_id", :default => 0
t.integer "creator_id", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "creator_id", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "groups_users", :id => false, :force => true do |t|