diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-03-16 17:29:30 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-03-16 17:29:30 +0000 |
commit | 0786b9ef99b0797f06a72201b1581d7384efc624 (patch) | |
tree | fd4abfc5b9476450092ff90a378e3f443b7b1505 /app/controllers/timelog_controller.rb | |
parent | 7ffdd961e9f92a2f1eb86f1d38ce056e1507e2b3 (diff) | |
download | redmine-0786b9ef99b0797f06a72201b1581d7384efc624.tar.gz redmine-0786b9ef99b0797f06a72201b1581d7384efc624.zip |
Replaces TimeEntry.visible_by with a visible scope.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5149 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/timelog_controller.rb')
-rw-r--r-- | app/controllers/timelog_controller.rb | 90 |
1 files changed, 43 insertions, 47 deletions
diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb index f75d5833e..604a8f244 100644 --- a/app/controllers/timelog_controller.rb +++ b/app/controllers/timelog_controller.rb @@ -40,60 +40,56 @@ class TimelogController < ApplicationController 'hours' => 'hours' cond = ARCondition.new - if @project.nil? - cond << Project.allowed_to_condition(User.current, :view_time_entries) - elsif @issue.nil? - cond << @project.project_condition(Setting.display_subprojects_issues?) - else + if @issue cond << "#{Issue.table_name}.root_id = #{@issue.root_id} AND #{Issue.table_name}.lft >= #{@issue.lft} AND #{Issue.table_name}.rgt <= #{@issue.rgt}" + elsif @project + cond << @project.project_condition(Setting.display_subprojects_issues?) end retrieve_date_range cond << ['spent_on BETWEEN ? AND ?', @from, @to] - TimeEntry.visible_by(User.current) do - respond_to do |format| - format.html { - # Paginate results - @entry_count = TimeEntry.count(:include => [:project, :issue], :conditions => cond.conditions) - @entry_pages = Paginator.new self, @entry_count, per_page_option, params['page'] - @entries = TimeEntry.find(:all, - :include => [:project, :activity, :user, {:issue => :tracker}], - :conditions => cond.conditions, - :order => sort_clause, - :limit => @entry_pages.items_per_page, - :offset => @entry_pages.current.offset) - @total_hours = TimeEntry.sum(:hours, :include => [:project, :issue], :conditions => cond.conditions).to_f + respond_to do |format| + format.html { + # Paginate results + @entry_count = TimeEntry.visible.count(:include => [:project, :issue], :conditions => cond.conditions) + @entry_pages = Paginator.new self, @entry_count, per_page_option, params['page'] + @entries = TimeEntry.visible.find(:all, + :include => [:project, :activity, :user, {:issue => :tracker}], + :conditions => cond.conditions, + :order => sort_clause, + :limit => @entry_pages.items_per_page, + :offset => @entry_pages.current.offset) + @total_hours = TimeEntry.visible.sum(:hours, :include => [:project, :issue], :conditions => cond.conditions).to_f - render :layout => !request.xhr? - } - format.api { - @entry_count = TimeEntry.count(:include => [:project, :issue], :conditions => cond.conditions) - @entry_pages = Paginator.new self, @entry_count, per_page_option, params['page'] - @entries = TimeEntry.find(:all, - :include => [:project, :activity, :user, {:issue => :tracker}], - :conditions => cond.conditions, - :order => sort_clause, - :limit => @entry_pages.items_per_page, - :offset => @entry_pages.current.offset) - } - format.atom { - entries = TimeEntry.find(:all, - :include => [:project, :activity, :user, {:issue => :tracker}], - :conditions => cond.conditions, - :order => "#{TimeEntry.table_name}.created_on DESC", - :limit => Setting.feeds_limit.to_i) - render_feed(entries, :title => l(:label_spent_time)) - } - format.csv { - # Export all entries - @entries = TimeEntry.find(:all, - :include => [:project, :activity, :user, {:issue => [:tracker, :assigned_to, :priority]}], - :conditions => cond.conditions, - :order => sort_clause) - send_data(entries_to_csv(@entries), :type => 'text/csv; header=present', :filename => 'timelog.csv') - } - end + render :layout => !request.xhr? + } + format.api { + @entry_count = TimeEntry.visible.count(:include => [:project, :issue], :conditions => cond.conditions) + @entry_pages = Paginator.new self, @entry_count, per_page_option, params['page'] + @entries = TimeEntry.visible.find(:all, + :include => [:project, :activity, :user, {:issue => :tracker}], + :conditions => cond.conditions, + :order => sort_clause, + :limit => @entry_pages.items_per_page, + :offset => @entry_pages.current.offset) + } + format.atom { + entries = TimeEntry.visible.find(:all, + :include => [:project, :activity, :user, {:issue => :tracker}], + :conditions => cond.conditions, + :order => "#{TimeEntry.table_name}.created_on DESC", + :limit => Setting.feeds_limit.to_i) + render_feed(entries, :title => l(:label_spent_time)) + } + format.csv { + # Export all entries + @entries = TimeEntry.visible.find(:all, + :include => [:project, :activity, :user, {:issue => [:tracker, :assigned_to, :priority]}], + :conditions => cond.conditions, + :order => sort_clause) + send_data(entries_to_csv(@entries), :type => 'text/csv; header=present', :filename => 'timelog.csv') + } end end |