@@ -1,105 +1,105 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2012 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2012 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. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | class BoardsController < ApplicationController |
|
18 | class BoardsController < ApplicationController | |
19 | default_search_scope :messages |
|
19 | default_search_scope :messages | |
20 | before_filter :find_project_by_project_id, :find_board_if_available, :authorize |
|
20 | before_filter :find_project_by_project_id, :find_board_if_available, :authorize | |
21 | accept_rss_auth :index, :show |
|
21 | accept_rss_auth :index, :show | |
22 |
|
22 | |||
23 | helper :sort |
|
23 | helper :sort | |
24 | include SortHelper |
|
24 | include SortHelper | |
25 | helper :watchers |
|
25 | helper :watchers | |
26 |
|
26 | |||
27 | def index |
|
27 | def index | |
28 | @boards = @project.boards |
|
28 | @boards = @project.boards.includes(:last_message => :author).all | |
29 | # show the board if there is only one |
|
29 | # show the board if there is only one | |
30 | if @boards.size == 1 |
|
30 | if @boards.size == 1 | |
31 | @board = @boards.first |
|
31 | @board = @boards.first | |
32 | show |
|
32 | show | |
33 | end |
|
33 | end | |
34 | end |
|
34 | end | |
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' => "#{Message.table_name}.updated_on" |
|
42 | 'updated_on' => "#{Message.table_name}.updated_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 self, @topic_count, per_page_option, params['page'] | |
46 | @topics = @board.topics.reorder("#{Message.table_name}.sticky DESC").order(sort_clause).all( |
|
46 | @topics = @board.topics.reorder("#{Message.table_name}.sticky DESC").order(sort_clause).all( | |
47 | :include => [:author, {:last_reply => :author}], |
|
47 | :include => [:author, {:last_reply => :author}], | |
48 | :limit => @topic_pages.items_per_page, |
|
48 | :limit => @topic_pages.items_per_page, | |
49 | :offset => @topic_pages.current.offset) |
|
49 | :offset => @topic_pages.current.offset) | |
50 | @message = Message.new(:board => @board) |
|
50 | @message = Message.new(:board => @board) | |
51 | render :action => 'show', :layout => !request.xhr? |
|
51 | render :action => 'show', :layout => !request.xhr? | |
52 | } |
|
52 | } | |
53 | format.atom { |
|
53 | format.atom { | |
54 | @messages = @board.messages.find :all, :order => 'created_on DESC', |
|
54 | @messages = @board.messages.find :all, :order => 'created_on DESC', | |
55 | :include => [:author, :board], |
|
55 | :include => [:author, :board], | |
56 | :limit => Setting.feeds_limit.to_i |
|
56 | :limit => Setting.feeds_limit.to_i | |
57 | render_feed(@messages, :title => "#{@project}: #{@board}") |
|
57 | render_feed(@messages, :title => "#{@project}: #{@board}") | |
58 | } |
|
58 | } | |
59 | end |
|
59 | end | |
60 | end |
|
60 | end | |
61 |
|
61 | |||
62 | def new |
|
62 | def new | |
63 | @board = @project.boards.build |
|
63 | @board = @project.boards.build | |
64 | @board.safe_attributes = params[:board] |
|
64 | @board.safe_attributes = params[:board] | |
65 | end |
|
65 | end | |
66 |
|
66 | |||
67 | def create |
|
67 | def create | |
68 | @board = @project.boards.build |
|
68 | @board = @project.boards.build | |
69 | @board.safe_attributes = params[:board] |
|
69 | @board.safe_attributes = params[:board] | |
70 | if @board.save |
|
70 | if @board.save | |
71 | flash[:notice] = l(:notice_successful_create) |
|
71 | flash[:notice] = l(:notice_successful_create) | |
72 | redirect_to_settings_in_projects |
|
72 | redirect_to_settings_in_projects | |
73 | else |
|
73 | else | |
74 | render :action => 'new' |
|
74 | render :action => 'new' | |
75 | end |
|
75 | end | |
76 | end |
|
76 | end | |
77 |
|
77 | |||
78 | def edit |
|
78 | def edit | |
79 | end |
|
79 | end | |
80 |
|
80 | |||
81 | def update |
|
81 | def update | |
82 | @board.safe_attributes = params[:board] |
|
82 | @board.safe_attributes = params[:board] | |
83 | if @board.save |
|
83 | if @board.save | |
84 | redirect_to_settings_in_projects |
|
84 | redirect_to_settings_in_projects | |
85 | else |
|
85 | else | |
86 | render :action => 'edit' |
|
86 | render :action => 'edit' | |
87 | end |
|
87 | end | |
88 | end |
|
88 | end | |
89 |
|
89 | |||
90 | def destroy |
|
90 | def destroy | |
91 | @board.destroy |
|
91 | @board.destroy | |
92 | redirect_to_settings_in_projects |
|
92 | redirect_to_settings_in_projects | |
93 | end |
|
93 | end | |
94 |
|
94 | |||
95 | private |
|
95 | private | |
96 | def redirect_to_settings_in_projects |
|
96 | def redirect_to_settings_in_projects | |
97 | redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards' |
|
97 | redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards' | |
98 | end |
|
98 | end | |
99 |
|
99 | |||
100 | def find_board_if_available |
|
100 | def find_board_if_available | |
101 | @board = @project.boards.find(params[:id]) if params[:id] |
|
101 | @board = @project.boards.find(params[:id]) if params[:id] | |
102 | rescue ActiveRecord::RecordNotFound |
|
102 | rescue ActiveRecord::RecordNotFound | |
103 | render_404 |
|
103 | render_404 | |
104 | end |
|
104 | end | |
105 | end |
|
105 | end |
General Comments 0
You need to be logged in to leave comments.
Login now