##// END OF EJS Templates
Fixed: error when using a custom query feed with custom field filter....
Jean-Philippe Lang -
r454:5097f6394de9
parent child
Show More
@@ -1,96 +1,96
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 FeedsController < ApplicationController
18 class FeedsController < ApplicationController
19 before_filter :find_scope
19 before_filter :find_scope
20 session :off
20 session :off
21
21
22 helper :issues
22 helper :issues
23 include IssuesHelper
23 include IssuesHelper
24 helper :custom_fields
24 helper :custom_fields
25 include CustomFieldsHelper
25 include CustomFieldsHelper
26
26
27 # news feeds
27 # news feeds
28 def news
28 def news
29 News.with_scope(:find => @find_options) do
29 News.with_scope(:find => @find_options) do
30 @news = News.find :all, :order => "#{News.table_name}.created_on DESC", :include => [ :author, :project ]
30 @news = News.find :all, :order => "#{News.table_name}.created_on DESC", :include => [ :author, :project ]
31 end
31 end
32 headers["Content-Type"] = "application/rss+xml"
32 headers["Content-Type"] = "application/rss+xml"
33 render :action => 'news_atom' if 'atom' == params[:format]
33 render :action => 'news_atom' if 'atom' == params[:format]
34 end
34 end
35
35
36 # issue feeds
36 # issue feeds
37 def issues
37 def issues
38 if @project && params[:query_id]
38 if @project && params[:query_id]
39 query = Query.find(params[:query_id])
39 query = Query.find(params[:query_id])
40 # ignore query if it's not valid
40 # ignore query if it's not valid
41 query = nil unless query.valid?
41 query = nil unless query.valid?
42 # override with query conditions
42 # override with query conditions
43 @find_options[:conditions] = query.statement if query.valid? and @project == query.project
43 @find_options[:conditions] = query.statement if query.valid? and @project == query.project
44 end
44 end
45
45
46 Issue.with_scope(:find => @find_options) do
46 Issue.with_scope(:find => @find_options) do
47 @issues = Issue.find :all, :include => [:project, :author, :tracker, :status],
47 @issues = Issue.find :all, :include => [:project, :author, :tracker, :status, :custom_values],
48 :order => "#{Issue.table_name}.created_on DESC"
48 :order => "#{Issue.table_name}.created_on DESC"
49 end
49 end
50 @title = (@project ? @project.name : Setting.app_title) + ": " + (query ? query.name : l(:label_reported_issues))
50 @title = (@project ? @project.name : Setting.app_title) + ": " + (query ? query.name : l(:label_reported_issues))
51 headers["Content-Type"] = "application/rss+xml"
51 headers["Content-Type"] = "application/rss+xml"
52 render :action => 'issues_atom' if 'atom' == params[:format]
52 render :action => 'issues_atom' if 'atom' == params[:format]
53 end
53 end
54
54
55 # issue changes feeds
55 # issue changes feeds
56 def history
56 def history
57 if @project && params[:query_id]
57 if @project && params[:query_id]
58 query = Query.find(params[:query_id])
58 query = Query.find(params[:query_id])
59 # ignore query if it's not valid
59 # ignore query if it's not valid
60 query = nil unless query.valid?
60 query = nil unless query.valid?
61 # override with query conditions
61 # override with query conditions
62 @find_options[:conditions] = query.statement if query.valid? and @project == query.project
62 @find_options[:conditions] = query.statement if query.valid? and @project == query.project
63 end
63 end
64
64
65 Journal.with_scope(:find => @find_options) do
65 Journal.with_scope(:find => @find_options) do
66 @journals = Journal.find :all, :include => [ :details, :user, {:issue => [:project, :author, :tracker, :status]} ],
66 @journals = Journal.find :all, :include => [ :details, :user, {:issue => [:project, :author, :tracker, :status, :custom_values]} ],
67 :order => "#{Journal.table_name}.created_on DESC"
67 :order => "#{Journal.table_name}.created_on DESC"
68 end
68 end
69
69
70 @title = (@project ? @project.name : Setting.app_title) + ": " + (query ? query.name : l(:label_reported_issues))
70 @title = (@project ? @project.name : Setting.app_title) + ": " + (query ? query.name : l(:label_reported_issues))
71 headers["Content-Type"] = "application/rss+xml"
71 headers["Content-Type"] = "application/rss+xml"
72 render :action => 'history_atom' if 'atom' == params[:format]
72 render :action => 'history_atom' if 'atom' == params[:format]
73 end
73 end
74
74
75 private
75 private
76 # override for feeds specific authentication
76 # override for feeds specific authentication
77 def check_if_login_required
77 def check_if_login_required
78 @user = User.find_by_rss_key(params[:key])
78 @user = User.find_by_rss_key(params[:key])
79 render(:nothing => true, :status => 403) and return false if !@user && Setting.login_required?
79 render(:nothing => true, :status => 403) and return false if !@user && Setting.login_required?
80 end
80 end
81
81
82 def find_scope
82 def find_scope
83 if params[:project_id]
83 if params[:project_id]
84 # project feed
84 # project feed
85 # check if project is public or if the user is a member
85 # check if project is public or if the user is a member
86 @project = Project.find(params[:project_id])
86 @project = Project.find(params[:project_id])
87 render(:nothing => true, :status => 403) and return false unless @project.is_public? || (@user && @user.role_for_project(@project))
87 render(:nothing => true, :status => 403) and return false unless @project.is_public? || (@user && @user.role_for_project(@project))
88 scope = ["#{Project.table_name}.id=?", params[:project_id].to_i]
88 scope = ["#{Project.table_name}.id=?", params[:project_id].to_i]
89 else
89 else
90 # global feed
90 # global feed
91 scope = ["#{Project.table_name}.is_public=?", true]
91 scope = ["#{Project.table_name}.is_public=?", true]
92 end
92 end
93 @find_options = {:conditions => scope, :limit => Setting.feeds_limit}
93 @find_options = {:conditions => scope, :limit => Setting.feeds_limit}
94 return true
94 return true
95 end
95 end
96 end
96 end
General Comments 0
You need to be logged in to leave comments. Login now