diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index b5e0b2d85..e0bd9582d 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -28,17 +28,25 @@ class BoardsController < ApplicationController helper :watchers def index - @boards = @project.boards.includes(:last_message => :author).all - @boards = [] << @boards[0] if @boards.any? - if @boards.size == 1 - @board = @boards.first - show and return - end - if @project.project_type == 1 - render :layout => 'base_courses' - else - render :layout => false if request.xhr? + #modify by nwb + if @project + @boards = @project.boards.includes(:last_message => :author).all + @boards = [] << @boards[0] if @boards.any? + if @boards.size == 1 + @board = @boards.first + show and return + end + render :layout => false if request.xhr? + elsif @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 + end + render :layout => 'base_courses' end + end def show @@ -60,10 +68,11 @@ class BoardsController < ApplicationController preload(:author, {:last_reply => :author}). all @message = Message.new(:board => @board) - if @project.project_type ==1 - render :action => 'show', :layout => 'base_courses' - else + #modify by nwb + if @project render :action => 'show', :layout => !request.xhr? + elsif @course + render :action => 'show', :layout => 'base_courses' end } format.atom { @@ -72,7 +81,12 @@ class BoardsController < ApplicationController includes(:author, :board). limit(Setting.feeds_limit.to_i). all - render_feed(@messages, :title => "#{@project}: #{@board}") + if @project + render_feed(@messages, :title => "#{@project}: #{@board}") + elsif @course + render_feed(@messages, :title => "#{@course}: #{@board}") + end + } end end diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index cfa1b6bba..7fbbc83e5 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -87,9 +87,13 @@ class NewsController < ApplicationController def show @comments = @news.comments - @comments.reverse! if User.current.wants_comments_in_reverse_order? - if @project.project_type == 1 - render :layout => 'base_courses' + @comments.reverse! if User.current.wants_comments_in_reverse_order? + #modify by nwb + if @news.course_id + @course = Course.find(@news.course_id) + if @course + render :layout => 'base_courses' + end end end diff --git a/app/helpers/boards_helper.rb b/app/helpers/boards_helper.rb index 84b979c44..341de8932 100644 --- a/app/helpers/boards_helper.rb +++ b/app/helpers/boards_helper.rb @@ -29,6 +29,19 @@ module BoardsHelper breadcrumb links end + # add by nwb + def course_board_breadcrumb(item) + board = item.is_a?(Message) ? item.board : item + links = [link_to(l(:label_board_plural), course_boards_path(item.course))] + boards = board.ancestors.reverse + if item.is_a?(Message) + boards << board + end + links += boards.map {|ancestor| link_to(h(ancestor.name), course_board_path(ancestor.course, ancestor))} + breadcrumb links + end + + def boards_options_for_select(boards) options = [] Board.board_tree(boards) do |board, level| diff --git a/config/routes.rb b/config/routes.rb index 3000af94b..c733bb8d7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -567,6 +567,7 @@ RedmineApp::Application.routes.draw do end end resources :news, :except => [:show, :edit, :update, :destroy] + resources :boards end # end of resources :courses match 'courses/:id/feedback', :to => 'courses#feedback', :via => :get, :as => 'course_feedback' match '/courses/search', :controller => 'courses', :action => 'search', :via => [:get, :post]