@@ -1,110 +1,110 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2013 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_by_project_id, :find_board_if_available, :authorize |
|
21 | 21 | accept_rss_auth :index, :show |
|
22 | 22 | |
|
23 | 23 | helper :sort |
|
24 | 24 | include SortHelper |
|
25 | 25 | helper :watchers |
|
26 | 26 | |
|
27 | 27 | def index |
|
28 | 28 | @boards = @project.boards.includes(:last_message => :author).all |
|
29 | 29 | # show the board if there is only one |
|
30 | 30 | if @boards.size == 1 |
|
31 | 31 | @board = @boards.first |
|
32 | 32 | show |
|
33 | 33 | end |
|
34 | 34 | end |
|
35 | 35 | |
|
36 | 36 | def show |
|
37 | 37 | respond_to do |format| |
|
38 | 38 | format.html { |
|
39 | 39 | sort_init 'updated_on', 'desc' |
|
40 |
sort_update |
|
|
40 | sort_update 'created_on' => "#{Message.table_name}.created_on", | |
|
41 | 41 | 'replies' => "#{Message.table_name}.replies_count", |
|
42 | 42 | 'updated_on' => "#{Message.table_name}.updated_on" |
|
43 | 43 | |
|
44 | 44 | @topic_count = @board.topics.count |
|
45 | 45 | @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] |
|
46 | 46 | @topics = @board.topics. |
|
47 | 47 | reorder("#{Message.table_name}.sticky DESC"). |
|
48 | 48 | includes(:author, {:last_reply => :author}). |
|
49 | 49 | limit(@topic_pages.items_per_page). |
|
50 | 50 | offset(@topic_pages.offset). |
|
51 | 51 | order(sort_clause). |
|
52 | 52 | all |
|
53 | 53 | @message = Message.new(:board => @board) |
|
54 | 54 | render :action => 'show', :layout => !request.xhr? |
|
55 | 55 | } |
|
56 | 56 | format.atom { |
|
57 | 57 | @messages = @board.messages. |
|
58 | 58 | reorder('created_on DESC'). |
|
59 | 59 | includes(:author, :board). |
|
60 | 60 | limit(Setting.feeds_limit.to_i). |
|
61 | 61 | all |
|
62 | 62 | render_feed(@messages, :title => "#{@project}: #{@board}") |
|
63 | 63 | } |
|
64 | 64 | end |
|
65 | 65 | end |
|
66 | 66 | |
|
67 | 67 | def new |
|
68 | 68 | @board = @project.boards.build |
|
69 | 69 | @board.safe_attributes = params[:board] |
|
70 | 70 | end |
|
71 | 71 | |
|
72 | 72 | def create |
|
73 | 73 | @board = @project.boards.build |
|
74 | 74 | @board.safe_attributes = params[:board] |
|
75 | 75 | if @board.save |
|
76 | 76 | flash[:notice] = l(:notice_successful_create) |
|
77 | 77 | redirect_to_settings_in_projects |
|
78 | 78 | else |
|
79 | 79 | render :action => 'new' |
|
80 | 80 | end |
|
81 | 81 | end |
|
82 | 82 | |
|
83 | 83 | def edit |
|
84 | 84 | end |
|
85 | 85 | |
|
86 | 86 | def update |
|
87 | 87 | @board.safe_attributes = params[:board] |
|
88 | 88 | if @board.save |
|
89 | 89 | redirect_to_settings_in_projects |
|
90 | 90 | else |
|
91 | 91 | render :action => 'edit' |
|
92 | 92 | end |
|
93 | 93 | end |
|
94 | 94 | |
|
95 | 95 | def destroy |
|
96 | 96 | @board.destroy |
|
97 | 97 | redirect_to_settings_in_projects |
|
98 | 98 | end |
|
99 | 99 | |
|
100 | 100 | private |
|
101 | 101 | def redirect_to_settings_in_projects |
|
102 | 102 | redirect_to settings_project_path(@project, :tab => 'boards') |
|
103 | 103 | end |
|
104 | 104 | |
|
105 | 105 | def find_board_if_available |
|
106 | 106 | @board = @project.boards.find(params[:id]) if params[:id] |
|
107 | 107 | rescue ActiveRecord::RecordNotFound |
|
108 | 108 | render_404 |
|
109 | 109 | end |
|
110 | 110 | end |
General Comments 0
You need to be logged in to leave comments.
Login now