Mercurial > hg > soundsoftware-site
diff app/controllers/boards_controller.rb @ 1115:433d4f72a19b redmine-2.2
Update to Redmine SVN revision 11137 on 2.2-stable branch
author | Chris Cannam |
---|---|
date | Mon, 07 Jan 2013 12:01:42 +0000 |
parents | 5f33065ddc4b |
children | 3e4c3460b6ca |
line wrap: on
line diff
--- a/app/controllers/boards_controller.rb Wed Jun 27 14:54:18 2012 +0100 +++ b/app/controllers/boards_controller.rb Mon Jan 07 12:01:42 2013 +0000 @@ -1,5 +1,5 @@ # Redmine - project management software -# Copyright (C) 2006-2011 Jean-Philippe Lang +# Copyright (C) 2006-2012 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -17,18 +17,15 @@ class BoardsController < ApplicationController default_search_scope :messages - before_filter :find_project, :find_board_if_available, :authorize + before_filter :find_project_by_project_id, :find_board_if_available, :authorize accept_rss_auth :index, :show - helper :messages - include MessagesHelper helper :sort include SortHelper helper :watchers - include WatchersHelper def index - @boards = @project.boards + @boards = @project.boards.includes(:last_message => :author).all # show the board if there is only one if @boards.size == 1 @board = @boards.first @@ -46,11 +43,11 @@ @topic_count = @board.topics.count @topic_pages = Paginator.new self, @topic_count, per_page_option, params['page'] - @topics = @board.topics.find :all, :order => ["#{Message.table_name}.sticky DESC", sort_clause].compact.join(', '), + @topics = @board.topics.reorder("#{Message.table_name}.sticky DESC").order(sort_clause).all( :include => [:author, {:last_reply => :author}], :limit => @topic_pages.items_per_page, - :offset => @topic_pages.current.offset - @message = Message.new + :offset => @topic_pages.current.offset) + @message = Message.new(:board => @board) render :action => 'show', :layout => !request.xhr? } format.atom { @@ -62,22 +59,31 @@ end end - verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :index } + def new + @board = @project.boards.build + @board.safe_attributes = params[:board] + end - def new - @board = Board.new + def create + @board = @project.boards.build @board.safe_attributes = params[:board] - @board.project = @project - if request.post? && @board.save + if @board.save flash[:notice] = l(:notice_successful_create) redirect_to_settings_in_projects + else + render :action => 'new' end end def edit + end + + def update @board.safe_attributes = params[:board] - if request.post? && @board.save + if @board.save redirect_to_settings_in_projects + else + render :action => 'edit' end end @@ -91,12 +97,6 @@ redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards' end - def find_project - @project = Project.find(params[:project_id]) - rescue ActiveRecord::RecordNotFound - render_404 - end - def find_board_if_available @board = @project.boards.find(params[:id]) if params[:id] rescue ActiveRecord::RecordNotFound