@@ -90,18 +90,20 class ProjectsController < ApplicationController | |||||
90 | @subprojects = @project.active_children |
|
90 | @subprojects = @project.active_children | |
91 | @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") |
|
91 | @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") | |
92 | @trackers = @project.rolled_up_trackers |
|
92 | @trackers = @project.rolled_up_trackers | |
|
93 | ||||
|
94 | cond = @project.project_condition(Setting.display_subprojects_issues?) | |||
93 | Issue.visible_by(User.current) do |
|
95 | Issue.visible_by(User.current) do | |
94 | @open_issues_by_tracker = Issue.count(:group => :tracker, |
|
96 | @open_issues_by_tracker = Issue.count(:group => :tracker, | |
95 | :include => [:project, :status, :tracker], |
|
97 | :include => [:project, :status, :tracker], | |
96 |
:conditions => ["(#{ |
|
98 | :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false]) | |
97 | @total_issues_by_tracker = Issue.count(:group => :tracker, |
|
99 | @total_issues_by_tracker = Issue.count(:group => :tracker, | |
98 | :include => [:project, :status, :tracker], |
|
100 | :include => [:project, :status, :tracker], | |
99 | :conditions => ["#{Project.table_name}.id=? OR #{Project.table_name}.parent_id=?", @project.id, @project.id]) |
|
101 | :conditions => cond) | |
100 | end |
|
102 | end | |
101 | TimeEntry.visible_by(User.current) do |
|
103 | TimeEntry.visible_by(User.current) do | |
102 | @total_hours = TimeEntry.sum(:hours, |
|
104 | @total_hours = TimeEntry.sum(:hours, | |
103 | :include => :project, |
|
105 | :include => :project, | |
104 | :conditions => ["(#{Project.table_name}.id = ? OR #{Project.table_name}.parent_id = ?)", @project.id, @project.id]).to_f |
|
106 | :conditions => cond).to_f | |
105 | end |
|
107 | end | |
106 | @key = User.current.rss_key |
|
108 | @key = User.current.rss_key | |
107 | end |
|
109 | end |
@@ -72,7 +72,7 class TimelogController < ApplicationController | |||||
72 | sql << " FROM #{TimeEntry.table_name}" |
|
72 | sql << " FROM #{TimeEntry.table_name}" | |
73 | sql << " LEFT JOIN #{Issue.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id" |
|
73 | sql << " LEFT JOIN #{Issue.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id" | |
74 | sql << " LEFT JOIN #{Project.table_name} ON #{TimeEntry.table_name}.project_id = #{Project.table_name}.id" |
|
74 | sql << " LEFT JOIN #{Project.table_name} ON #{TimeEntry.table_name}.project_id = #{Project.table_name}.id" | |
75 | sql << " WHERE (#{Project.table_name}.id = %s OR #{Project.table_name}.parent_id = %s)" % [@project.id, @project.id] |
|
75 | sql << " WHERE (%s)" % @project.project_condition(Setting.display_subprojects_issues?) | |
76 | sql << " AND (%s)" % Project.allowed_to_condition(User.current, :view_time_entries) |
|
76 | sql << " AND (%s)" % Project.allowed_to_condition(User.current, :view_time_entries) | |
77 | sql << " AND spent_on BETWEEN '%s' AND '%s'" % [ActiveRecord::Base.connection.quoted_date(@date_from.to_time), ActiveRecord::Base.connection.quoted_date(@date_to.to_time)] |
|
77 | sql << " AND spent_on BETWEEN '%s' AND '%s'" % [ActiveRecord::Base.connection.quoted_date(@date_from.to_time), ActiveRecord::Base.connection.quoted_date(@date_to.to_time)] | |
78 | sql << " GROUP BY #{sql_group_by}, tyear, tmonth, tweek" |
|
78 | sql << " GROUP BY #{sql_group_by}, tyear, tmonth, tweek" | |
@@ -159,7 +159,7 class TimelogController < ApplicationController | |||||
159 | @from, @to = @to, @from if @from && @to && @from > @to |
|
159 | @from, @to = @to, @from if @from && @to && @from > @to | |
160 |
|
160 | |||
161 | cond = ARCondition.new |
|
161 | cond = ARCondition.new | |
162 | cond << (@issue.nil? ? ["(#{Project.table_name}.id = ? OR #{Project.table_name}.parent_id = ?)", @project.id, @project.id] : |
|
162 | cond << (@issue.nil? ? @project.project_condition(Setting.display_subprojects_issues?) : | |
163 | ["#{TimeEntry.table_name}.issue_id = ?", @issue.id]) |
|
163 | ["#{TimeEntry.table_name}.issue_id = ?", @issue.id]) | |
164 |
|
164 | |||
165 | if @from |
|
165 | if @from |
@@ -124,6 +124,12 class Project < ActiveRecord::Base | |||||
124 | statements.empty? ? base_statement : "((#{base_statement}) AND (#{statements.join(' OR ')}))" |
|
124 | statements.empty? ? base_statement : "((#{base_statement}) AND (#{statements.join(' OR ')}))" | |
125 | end |
|
125 | end | |
126 |
|
126 | |||
|
127 | def project_condition(with_subprojects) | |||
|
128 | cond = "#{Project.table_name}.id = #{id}" | |||
|
129 | cond = "(#{cond} OR #{Project.table_name}.parent_id = #{id})" if with_subprojects | |||
|
130 | cond | |||
|
131 | end | |||
|
132 | ||||
127 | def self.find(*args) |
|
133 | def self.find(*args) | |
128 | if args.first && args.first.is_a?(String) && !args.first.match(/^\d*$/) |
|
134 | if args.first && args.first.is_a?(String) && !args.first.match(/^\d*$/) | |
129 | project = find_by_identifier(*args) |
|
135 | project = find_by_identifier(*args) |
General Comments 0
You need to be logged in to leave comments.
Login now