@@ -1,5 +1,5 | |||
|
1 | 1 | # Redmine - project management software |
|
2 |
# Copyright (C) 2006-20 |
|
|
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 |
@@ -156,11 +156,10 class ProjectsController < ApplicationController | |||
|
156 | 156 | :include => [:project, :status, :tracker], |
|
157 | 157 | :conditions => cond) |
|
158 | 158 | |
|
159 | TimeEntry.visible_by(User.current) do | |
|
160 | @total_hours = TimeEntry.sum(:hours, | |
|
161 | :include => :project, | |
|
162 | :conditions => cond).to_f | |
|
159 | if User.current.allowed_to?(:view_time_entries, @project) | |
|
160 | @total_hours = TimeEntry.visible.sum(:hours, :include => :project, :conditions => cond).to_f | |
|
163 | 161 | end |
|
162 | ||
|
164 | 163 | @key = User.current.rss_key |
|
165 | 164 | |
|
166 | 165 | respond_to do |format| |
@@ -40,37 +40,34 class TimelogController < ApplicationController | |||
|
40 | 40 | 'hours' => 'hours' |
|
41 | 41 | |
|
42 | 42 | cond = ARCondition.new |
|
43 | if @project.nil? | |
|
44 | cond << Project.allowed_to_condition(User.current, :view_time_entries) | |
|
45 | elsif @issue.nil? | |
|
46 | cond << @project.project_condition(Setting.display_subprojects_issues?) | |
|
47 | else | |
|
43 | if @issue | |
|
48 | 44 | cond << "#{Issue.table_name}.root_id = #{@issue.root_id} AND #{Issue.table_name}.lft >= #{@issue.lft} AND #{Issue.table_name}.rgt <= #{@issue.rgt}" |
|
45 | elsif @project | |
|
46 | cond << @project.project_condition(Setting.display_subprojects_issues?) | |
|
49 | 47 | end |
|
50 | 48 | |
|
51 | 49 | retrieve_date_range |
|
52 | 50 | cond << ['spent_on BETWEEN ? AND ?', @from, @to] |
|
53 | 51 | |
|
54 | TimeEntry.visible_by(User.current) do | |
|
55 | 52 |
|
|
56 | 53 |
|
|
57 | 54 |
|
|
58 |
|
|
|
55 | @entry_count = TimeEntry.visible.count(:include => [:project, :issue], :conditions => cond.conditions) | |
|
59 | 56 |
|
|
60 |
|
|
|
57 | @entries = TimeEntry.visible.find(:all, | |
|
61 | 58 |
|
|
62 | 59 |
|
|
63 | 60 |
|
|
64 | 61 |
|
|
65 | 62 |
|
|
66 |
|
|
|
63 | @total_hours = TimeEntry.visible.sum(:hours, :include => [:project, :issue], :conditions => cond.conditions).to_f | |
|
67 | 64 | |
|
68 | 65 |
|
|
69 | 66 |
|
|
70 | 67 |
|
|
71 |
|
|
|
68 | @entry_count = TimeEntry.visible.count(:include => [:project, :issue], :conditions => cond.conditions) | |
|
72 | 69 |
|
|
73 |
|
|
|
70 | @entries = TimeEntry.visible.find(:all, | |
|
74 | 71 |
|
|
75 | 72 |
|
|
76 | 73 |
|
@@ -78,7 +75,7 class TimelogController < ApplicationController | |||
|
78 | 75 |
|
|
79 | 76 |
|
|
80 | 77 |
|
|
81 |
|
|
|
78 | entries = TimeEntry.visible.find(:all, | |
|
82 | 79 |
|
|
83 | 80 |
|
|
84 | 81 |
|
@@ -87,7 +84,7 class TimelogController < ApplicationController | |||
|
87 | 84 |
|
|
88 | 85 |
|
|
89 | 86 |
|
|
90 |
|
|
|
87 | @entries = TimeEntry.visible.find(:all, | |
|
91 | 88 |
|
|
92 | 89 |
|
|
93 | 90 |
|
@@ -95,7 +92,6 class TimelogController < ApplicationController | |||
|
95 | 92 |
|
|
96 | 93 |
|
|
97 | 94 |
|
|
98 | end | |
|
99 | 95 | |
|
100 | 96 | def show |
|
101 | 97 | respond_to do |format| |
@@ -1,5 +1,5 | |||
|
1 |
# |
|
|
2 |
# Copyright (C) 2006-20 |
|
|
1 | # Redmine - project management software | |
|
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 |
@@ -39,6 +39,11 class TimeEntry < ActiveRecord::Base | |||
|
39 | 39 | validates_numericality_of :hours, :allow_nil => true, :message => :invalid |
|
40 | 40 | validates_length_of :comments, :maximum => 255, :allow_nil => true |
|
41 | 41 | |
|
42 | named_scope :visible, lambda {|*args| { | |
|
43 | :include => :project, | |
|
44 | :conditions => Project.allowed_to_condition(args.first || User.current, :view_time_entries) | |
|
45 | }} | |
|
46 | ||
|
42 | 47 | def after_initialize |
|
43 | 48 | if new_record? && self.activity.nil? |
|
44 | 49 | if default_activity = TimeEntryActivity.default |
@@ -79,7 +84,9 class TimeEntry < ActiveRecord::Base | |||
|
79 | 84 | (usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project) |
|
80 | 85 | end |
|
81 | 86 | |
|
87 | # TODO: remove this method in 1.3.0 | |
|
82 | 88 | def self.visible_by(usr) |
|
89 | ActiveSupport::Deprecation.warn "TimeEntry.visible_by is deprecated and will be removed in Redmine 1.3.0. Use the visible scope instead." | |
|
83 | 90 | with_scope(:find => { :conditions => Project.allowed_to_condition(usr, :view_time_entries) }) do |
|
84 | 91 | yield |
|
85 | 92 | end |
@@ -64,7 +64,7 | |||
|
64 | 64 | </div> |
|
65 | 65 | |
|
66 | 66 | <% content_for :sidebar do %> |
|
67 | <% if @total_hours && User.current.allowed_to?(:view_time_entries, @project) %> | |
|
67 | <% if @total_hours.present? %> | |
|
68 | 68 | <h3><%= l(:label_spent_time) %></h3> |
|
69 | 69 | <p><span class="icon icon-time"><%= l_hours(@total_hours) %></span></p> |
|
70 | 70 | <p><%= link_to(l(:label_details), {:controller => 'timelog', :action => 'index', :project_id => @project}) %> | |
General Comments 0
You need to be logged in to leave comments.
Login now