@@ -1,93 +1,97 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 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, :authorize |
|
20 | before_filter :find_project, :authorize | |
21 |
|
21 | |||
22 | helper :messages |
|
22 | helper :messages | |
23 | include MessagesHelper |
|
23 | include MessagesHelper | |
24 | helper :sort |
|
24 | helper :sort | |
25 | include SortHelper |
|
25 | include SortHelper | |
26 | helper :watchers |
|
26 | helper :watchers | |
27 | include WatchersHelper |
|
27 | include WatchersHelper | |
28 |
|
28 | |||
29 | def index |
|
29 | def index | |
30 | @boards = @project.boards |
|
30 | @boards = @project.boards | |
31 | # show the board if there is only one |
|
31 | # show the board if there is only one | |
32 | if @boards.size == 1 |
|
32 | if @boards.size == 1 | |
33 | @board = @boards.first |
|
33 | @board = @boards.first | |
34 | show |
|
34 | show | |
35 | end |
|
35 | end | |
36 | end |
|
36 | end | |
37 |
|
37 | |||
38 | def show |
|
38 | def show | |
39 | respond_to do |format| |
|
39 | respond_to do |format| | |
40 | format.html { |
|
40 | format.html { | |
41 | sort_init 'updated_on', 'desc' |
|
41 | sort_init 'updated_on', 'desc' | |
42 | sort_update 'created_on' => "#{Message.table_name}.created_on", |
|
42 | sort_update 'created_on' => "#{Message.table_name}.created_on", | |
43 | 'replies' => "#{Message.table_name}.replies_count", |
|
43 | 'replies' => "#{Message.table_name}.replies_count", | |
44 | 'updated_on' => "#{Message.table_name}.updated_on" |
|
44 | 'updated_on' => "#{Message.table_name}.updated_on" | |
45 |
|
45 | |||
46 | @topic_count = @board.topics.count |
|
46 | @topic_count = @board.topics.count | |
47 | @topic_pages = Paginator.new self, @topic_count, per_page_option, params['page'] |
|
47 | @topic_pages = Paginator.new self, @topic_count, per_page_option, params['page'] | |
48 | @topics = @board.topics.find :all, :order => ["#{Message.table_name}.sticky DESC", sort_clause].compact.join(', '), |
|
48 | @topics = @board.topics.find :all, :order => ["#{Message.table_name}.sticky DESC", sort_clause].compact.join(', '), | |
49 | :include => [:author, {:last_reply => :author}], |
|
49 | :include => [:author, {:last_reply => :author}], | |
50 | :limit => @topic_pages.items_per_page, |
|
50 | :limit => @topic_pages.items_per_page, | |
51 | :offset => @topic_pages.current.offset |
|
51 | :offset => @topic_pages.current.offset | |
52 | @message = Message.new |
|
52 | @message = Message.new | |
53 | render :action => 'show', :layout => !request.xhr? |
|
53 | render :action => 'show', :layout => !request.xhr? | |
54 | } |
|
54 | } | |
55 | format.atom { |
|
55 | format.atom { | |
56 | @messages = @board.messages.find :all, :order => 'created_on DESC', |
|
56 | @messages = @board.messages.find :all, :order => 'created_on DESC', | |
57 | :include => [:author, :board], |
|
57 | :include => [:author, :board], | |
58 | :limit => Setting.feeds_limit.to_i |
|
58 | :limit => Setting.feeds_limit.to_i | |
59 | render_feed(@messages, :title => "#{@project}: #{@board}") |
|
59 | render_feed(@messages, :title => "#{@project}: #{@board}") | |
60 | } |
|
60 | } | |
61 | end |
|
61 | end | |
62 | end |
|
62 | end | |
63 |
|
63 | |||
64 | verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :index } |
|
64 | verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :index } | |
65 |
|
65 | |||
66 | def new |
|
66 | def new | |
67 | @board = Board.new(params[:board]) |
|
67 | @board = Board.new(params[:board]) | |
68 | @board.project = @project |
|
68 | @board.project = @project | |
69 | if request.post? && @board.save |
|
69 | if request.post? && @board.save | |
70 | flash[:notice] = l(:notice_successful_create) |
|
70 | flash[:notice] = l(:notice_successful_create) | |
71 | redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards' |
|
71 | redirect_to_settings_in_projects | |
72 | end |
|
72 | end | |
73 | end |
|
73 | end | |
74 |
|
74 | |||
75 | def edit |
|
75 | def edit | |
76 | if request.post? && @board.update_attributes(params[:board]) |
|
76 | if request.post? && @board.update_attributes(params[:board]) | |
77 | redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards' |
|
77 | redirect_to_settings_in_projects | |
78 | end |
|
78 | end | |
79 | end |
|
79 | end | |
80 |
|
80 | |||
81 | def destroy |
|
81 | def destroy | |
82 | @board.destroy |
|
82 | @board.destroy | |
83 | redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards' |
|
83 | redirect_to_settings_in_projects | |
84 | end |
|
84 | end | |
85 |
|
85 | |||
86 | private |
|
86 | private | |
|
87 | def redirect_to_settings_in_projects | |||
|
88 | redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards' | |||
|
89 | end | |||
|
90 | ||||
87 | def find_project |
|
91 | def find_project | |
88 | @project = Project.find(params[:project_id]) |
|
92 | @project = Project.find(params[:project_id]) | |
89 | @board = @project.boards.find(params[:id]) if params[:id] |
|
93 | @board = @project.boards.find(params[:id]) if params[:id] | |
90 | rescue ActiveRecord::RecordNotFound |
|
94 | rescue ActiveRecord::RecordNotFound | |
91 | render_404 |
|
95 | render_404 | |
92 | end |
|
96 | end | |
93 | end |
|
97 | end |
General Comments 0
You need to be logged in to leave comments.
Login now