|
|
|
@ -42,12 +42,19 @@ class BoardsController < ApplicationController
|
|
|
|
|
elsif @course
|
|
|
|
|
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
|
|
|
|
|
@boards = @course.boards.includes(:last_message => :author).all
|
|
|
|
|
@boards = [] << @boards[0] if @boards.any?
|
|
|
|
|
if @course.boards.empty?
|
|
|
|
|
@board = @course.boards.build
|
|
|
|
|
@board.name = " #{l(:label_borad_course) }"
|
|
|
|
|
@board.description = @course.name.to_s
|
|
|
|
|
@board.project_id = -1
|
|
|
|
|
if @board.save
|
|
|
|
|
@boards = @course.boards.includes(:last_message => :author).all
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if @boards.size == 1
|
|
|
|
|
@board = @boards.first
|
|
|
|
|
show and return
|
|
|
|
|
@board = @course.boards.first
|
|
|
|
|
end
|
|
|
|
|
render :layout => 'base_courses'
|
|
|
|
|
show and return
|
|
|
|
|
else
|
|
|
|
|
render_403
|
|
|
|
|
end
|
|
|
|
@ -65,7 +72,7 @@ class BoardsController < ApplicationController
|
|
|
|
|
'replies' => "#{Message.table_name}.replies_count",
|
|
|
|
|
'updated_on' => "COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on)"
|
|
|
|
|
|
|
|
|
|
@topic_count = @board.topics.count
|
|
|
|
|
@topic_count = @board ? @board.topics.count : 0
|
|
|
|
|
if @project
|
|
|
|
|
@topic_pages = Paginator.new @topic_count, per_page_option, params['page']
|
|
|
|
|
@topics = @board.topics.
|
|
|
|
@ -77,14 +84,13 @@ class BoardsController < ApplicationController
|
|
|
|
|
preload(:author, {:last_reply => :author}).
|
|
|
|
|
all
|
|
|
|
|
elsif @course
|
|
|
|
|
board_topics = @board.topics.
|
|
|
|
|
reorder("#{Message.table_name}.sticky DESC").
|
|
|
|
|
board_topics = @board ? @board.topics.reorder("#{Message.table_name}.sticky DESC").
|
|
|
|
|
includes(:last_reply).
|
|
|
|
|
# limit(@topic_pages.per_page).
|
|
|
|
|
# offset(@topic_pages.offset).
|
|
|
|
|
order(sort_clause).
|
|
|
|
|
preload(:author, {:last_reply => :author}).
|
|
|
|
|
all
|
|
|
|
|
all : []
|
|
|
|
|
@topics = paginateHelper board_topics,10
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|