Mercurial > hg > soundsoftware-site
comparison app/controllers/boards_controller.rb @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | 622f24f53b42 |
children |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2012 Jean-Philippe Lang | 2 # Copyright (C) 2006-2013 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
35 | 35 |
36 def show | 36 def show |
37 respond_to do |format| | 37 respond_to do |format| |
38 format.html { | 38 format.html { |
39 sort_init 'updated_on', 'desc' | 39 sort_init 'updated_on', 'desc' |
40 sort_update 'created_on' => "#{Message.table_name}.created_on", | 40 sort_update 'created_on' => "#{Message.table_name}.created_on", |
41 'replies' => "#{Message.table_name}.replies_count", | 41 'replies' => "#{Message.table_name}.replies_count", |
42 'updated_on' => "COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on)" | 42 'updated_on' => "COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on)" |
43 | 43 |
44 @topic_count = @board.topics.count | 44 @topic_count = @board.topics.count |
45 @topic_pages = Paginator.new self, @topic_count, per_page_option, params['page'] | 45 @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] |
46 @topics = @board.topics. | 46 @topics = @board.topics. |
47 reorder("#{Message.table_name}.sticky DESC"). | 47 reorder("#{Message.table_name}.sticky DESC"). |
48 includes(:last_reply). | 48 includes(:last_reply). |
49 limit(@topic_pages.items_per_page). | 49 limit(@topic_pages.per_page). |
50 offset(@topic_pages.current.offset). | 50 offset(@topic_pages.offset). |
51 order(sort_clause). | 51 order(sort_clause). |
52 preload(:author, {:last_reply => :author}). | 52 preload(:author, {:last_reply => :author}). |
53 all | 53 all |
54 @message = Message.new(:board => @board) | 54 @message = Message.new(:board => @board) |
55 render :action => 'show', :layout => !request.xhr? | 55 render :action => 'show', :layout => !request.xhr? |
56 } | 56 } |
57 format.atom { | 57 format.atom { |
58 @messages = @board.messages.find :all, :order => 'created_on DESC', | 58 @messages = @board.messages. |
59 :include => [:author, :board], | 59 reorder('created_on DESC'). |
60 :limit => Setting.feeds_limit.to_i | 60 includes(:author, :board). |
61 limit(Setting.feeds_limit.to_i). | |
62 all | |
61 render_feed(@messages, :title => "#{@project}: #{@board}") | 63 render_feed(@messages, :title => "#{@project}: #{@board}") |
62 } | 64 } |
63 end | 65 end |
64 end | 66 end |
65 | 67 |
96 redirect_to_settings_in_projects | 98 redirect_to_settings_in_projects |
97 end | 99 end |
98 | 100 |
99 private | 101 private |
100 def redirect_to_settings_in_projects | 102 def redirect_to_settings_in_projects |
101 redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards' | 103 redirect_to settings_project_path(@project, :tab => 'boards') |
102 end | 104 end |
103 | 105 |
104 def find_board_if_available | 106 def find_board_if_available |
105 @board = @project.boards.find(params[:id]) if params[:id] | 107 @board = @project.boards.find(params[:id]) if params[:id] |
106 rescue ActiveRecord::RecordNotFound | 108 rescue ActiveRecord::RecordNotFound |