修复课程、项目无法上传资源的问题
This commit is contained in:
parent
d608d092da
commit
c6a19209f4
|
@ -26,6 +26,18 @@ class FilesController < ApplicationController
|
||||||
include SortHelper
|
include SortHelper
|
||||||
helper :project_score
|
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
|
def index
|
||||||
#sort_init 'filename', 'asc'
|
#sort_init 'filename', 'asc'
|
||||||
sort_init 'created_on', 'desc'
|
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.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
|
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
|
||||||
|
|
||||||
all_attachments = []
|
show_attachments @containers
|
||||||
@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?
|
render :layout => !request.xhr?
|
||||||
elsif params[:course_id]
|
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)]
|
@containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on desc").find(@course.id)]
|
||||||
end
|
end
|
||||||
|
|
||||||
all_attachments = []
|
show_attachments @containers
|
||||||
@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'
|
render :layout => 'base_courses'
|
||||||
end
|
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.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
|
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
|
||||||
|
|
||||||
|
show_attachments @containers
|
||||||
|
|
||||||
@attachtype = 0
|
@attachtype = 0
|
||||||
@contenttype = 0
|
@contenttype = 0
|
||||||
|
|
||||||
|
@ -159,6 +156,8 @@ class FilesController < ApplicationController
|
||||||
|
|
||||||
@containers = [Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)]
|
@containers = [Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)]
|
||||||
|
|
||||||
|
show_attachments @containers
|
||||||
|
|
||||||
@attachtype = 0
|
@attachtype = 0
|
||||||
@contenttype = 0
|
@contenttype = 0
|
||||||
|
|
||||||
|
|
16
db/schema.rb
16
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# 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|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
@ -441,21 +441,21 @@ ActiveRecord::Schema.define(:version => 20140812065417) do
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.integer "sort_type"
|
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_course", :default => 1
|
||||||
t.integer "show_contest", :default => 1
|
t.integer "show_contest", :default => 1
|
||||||
|
t.integer "image_width", :default => 107
|
||||||
|
t.integer "image_height", :default => 63
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "forums", :force => true do |t|
|
create_table "forums", :force => true do |t|
|
||||||
t.string "name", :null => false
|
t.string "name", :null => false
|
||||||
t.string "description", :default => ""
|
t.text "description"
|
||||||
t.integer "topic_count", :default => 0
|
t.integer "topic_count", :default => 0
|
||||||
t.integer "memo_count", :default => 0
|
t.integer "memo_count", :default => 0
|
||||||
t.integer "last_memo_id", :default => 0
|
t.integer "last_memo_id", :default => 0
|
||||||
t.integer "creator_id", :null => false
|
t.integer "creator_id", :null => false
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "groups_users", :id => false, :force => true do |t|
|
create_table "groups_users", :id => false, :force => true do |t|
|
||||||
|
|
Loading…
Reference in New Issue