@@ -1,103 +1,103 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 |
# |
|
|
8 | # | |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 |
# |
|
|
13 | # | |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class BoardsController < ApplicationController |
|
19 | 19 | default_search_scope :messages |
|
20 | 20 | before_filter :find_project, :find_board_if_available, :authorize |
|
21 | 21 | accept_rss_auth :index, :show |
|
22 | 22 | |
|
23 | 23 | helper :messages |
|
24 | 24 | include MessagesHelper |
|
25 | 25 | helper :sort |
|
26 | 26 | include SortHelper |
|
27 | 27 | helper :watchers |
|
28 | 28 | include WatchersHelper |
|
29 | ||
|
29 | ||
|
30 | 30 | def index |
|
31 | 31 | @boards = @project.boards |
|
32 | 32 | # show the board if there is only one |
|
33 | 33 | if @boards.size == 1 |
|
34 | 34 | @board = @boards.first |
|
35 | 35 | show |
|
36 | 36 | end |
|
37 | 37 | end |
|
38 | 38 | |
|
39 | 39 | def show |
|
40 | 40 | respond_to do |format| |
|
41 | 41 | format.html { |
|
42 | 42 | sort_init 'updated_on', 'desc' |
|
43 | 43 | sort_update 'created_on' => "#{Message.table_name}.created_on", |
|
44 | 44 | 'replies' => "#{Message.table_name}.replies_count", |
|
45 | 45 | 'updated_on' => "#{Message.table_name}.updated_on" |
|
46 | ||
|
46 | ||
|
47 | 47 | @topic_count = @board.topics.count |
|
48 | 48 | @topic_pages = Paginator.new self, @topic_count, per_page_option, params['page'] |
|
49 | 49 | @topics = @board.topics.find :all, :order => ["#{Message.table_name}.sticky DESC", sort_clause].compact.join(', '), |
|
50 | 50 | :include => [:author, {:last_reply => :author}], |
|
51 | 51 | :limit => @topic_pages.items_per_page, |
|
52 | 52 | :offset => @topic_pages.current.offset |
|
53 | 53 | @message = Message.new |
|
54 | 54 | render :action => 'show', :layout => !request.xhr? |
|
55 | 55 | } |
|
56 | 56 | format.atom { |
|
57 | 57 | @messages = @board.messages.find :all, :order => 'created_on DESC', |
|
58 | 58 | :include => [:author, :board], |
|
59 | 59 | :limit => Setting.feeds_limit.to_i |
|
60 | 60 | render_feed(@messages, :title => "#{@project}: #{@board}") |
|
61 | 61 | } |
|
62 | 62 | end |
|
63 | 63 | end |
|
64 | ||
|
64 | ||
|
65 | 65 | verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :index } |
|
66 | 66 | |
|
67 | 67 | def new |
|
68 | 68 | @board = Board.new(params[:board]) |
|
69 | 69 | @board.project = @project |
|
70 | 70 | if request.post? && @board.save |
|
71 | 71 | flash[:notice] = l(:notice_successful_create) |
|
72 | 72 | redirect_to_settings_in_projects |
|
73 | 73 | end |
|
74 | 74 | end |
|
75 | 75 | |
|
76 | 76 | def edit |
|
77 | 77 | if request.post? && @board.update_attributes(params[:board]) |
|
78 | 78 | redirect_to_settings_in_projects |
|
79 | 79 | end |
|
80 | 80 | end |
|
81 | 81 | |
|
82 | 82 | def destroy |
|
83 | 83 | @board.destroy |
|
84 | 84 | redirect_to_settings_in_projects |
|
85 | 85 | end |
|
86 | ||
|
86 | ||
|
87 | 87 | private |
|
88 | 88 | def redirect_to_settings_in_projects |
|
89 | 89 | redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards' |
|
90 | 90 | end |
|
91 | 91 | |
|
92 | 92 | def find_project |
|
93 | 93 | @project = Project.find(params[:project_id]) |
|
94 | 94 | rescue ActiveRecord::RecordNotFound |
|
95 | 95 | render_404 |
|
96 | 96 | end |
|
97 | 97 | |
|
98 | 98 | def find_board_if_available |
|
99 | 99 | @board = @project.boards.find(params[:id]) if params[:id] |
|
100 | 100 | rescue ActiveRecord::RecordNotFound |
|
101 | 101 | render_404 |
|
102 | 102 | end |
|
103 | 103 | end |
General Comments 0
You need to be logged in to leave comments.
Login now