From 70901832a86229b5065a0a90d991e209eda4fb76 Mon Sep 17 00:00:00 2001 From: nwb Date: Thu, 12 Jun 2014 09:44:22 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E8=AF=BE=E7=A8=8B=E8=AE=A8?= =?UTF-8?q?=E8=AE=BA=E5=8C=BAcontrol=20index=E3=80=81show=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=8F=8A=E8=B7=AF=E7=94=B1=202.BoardsHelper=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=AF=BE=E7=A8=8B=E7=9B=B8=E5=85=B3=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/boards_controller.rb | 42 ++++++++++++++++++---------- app/controllers/news_controller.rb | 10 +++++-- app/helpers/boards_helper.rb | 13 +++++++++ config/routes.rb | 1 + 4 files changed, 49 insertions(+), 17 deletions(-) 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]