当课程没有讨论区时自动创建其讨论区
This commit is contained in:
parent
5b5423b8c5
commit
6d058940ec
|
@ -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 @boards.size == 1
|
||||
@board = @boards.first
|
||||
show and return
|
||||
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
|
||||
render :layout => 'base_courses'
|
||||
if @boards.size == 1
|
||||
@board = @course.boards.first
|
||||
end
|
||||
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
|
||||
|
||||
|
|
|
@ -132,8 +132,8 @@
|
|||
</div>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_board), course_boards_path(@course), :class => "f14 c_blue02" %>
|
||||
<%= link_to "(#{@course.boards[0].topics.count})", course_boards_path(@course), :class => "subnav_num c_orange" %>
|
||||
<%= link_to( "+#{l(:label_message_new)}", new_board_message_path(@course.boards[0]), :class => 'subnav_green ml95 c_white') if User.current.member_of_course?(@course) %>
|
||||
<%= link_to "(#{@course.boards.first ? @course.boards.first.topics.count : 0})", course_boards_path(@course), :class => "subnav_num c_orange" %>
|
||||
<%= link_to( "+#{l(:label_message_new)}", new_board_message_path(@course.boards.first), :class => 'subnav_green ml95 c_white') if User.current.member_of_course?(@course) && @course.boards.first %>
|
||||
</div>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_feedback), course_feedback_path(@course), :class => "f14 c_blue02" %>
|
||||
|
|
Loading…
Reference in New Issue