Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/controllers/timesheet_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def report
end

def context_menu
@time_entries = TimeEntry.find(:all, :conditions => ['id IN (?)', params[:ids]])
@time_entries = TimeEntry.where(['id IN (?)', params[:ids]])
render :layout => false
end

Expand All @@ -115,14 +115,14 @@ def get_precision
end

def get_activities
@activities = TimeEntryActivity.all(:conditions => 'parent_id IS NULL')
@activities = TimeEntryActivity.where('parent_id IS NULL')
end

def allowed_projects
if User.current.admin?
return Project.find(:all, :order => 'name ASC')
return Project.all.order('name ASC')
else
return Project.find(:all, :conditions => Project.visible_condition(User.current), :order => 'name ASC')
return Project.where(Project.visible_condition(User.current)).order('name ASC')
end
end

Expand Down
55 changes: 21 additions & 34 deletions app/models/timesheet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def initialize(options = { })
self.activities = options[:activities].collect do |activity_id|
# Include project-overridden activities
activity = TimeEntryActivity.find(activity_id)
project_activities = TimeEntryActivity.all(:conditions => ['parent_id IN (?)', activity.id]) if activity.parent_id.nil?
project_activities = TimeEntryActivity.where(['parent_id IN (?)', activity.id]) if activity.parent_id.nil?
project_activities ||= []

[activity.id.to_i] + project_activities.collect(&:id)
Expand Down Expand Up @@ -279,51 +279,42 @@ def includes


def time_entries_for_all_users(project)
return project.time_entries.find(:all,
:conditions => self.conditions(self.users),
:include => self.includes,
:order => "spent_on ASC")
return project.time_entries.includes(self.includes).
where(self.conditions(self.users)).
order('spent_on ASC')
end

def time_entries_for_all_users_in_group(group)
return TimeEntry.find(:all,
:conditions => self.conditions(group.user_ids),
:include => self.includes,
:order => "spent_on ASC")
return TimeEntry.includes(self.includes).
where(self.conditions(group.user_ids)).
order('spent_on ASC')
end

def time_entries_for_current_user(project)
return project.time_entries.find(:all,
:conditions => self.conditions(User.current.id),
:include => self.includes,
:include => [:activity, :user, {:issue => [:tracker, :assigned_to, :priority]}],
:order => "spent_on ASC")
return project.time_entries.
includes(self.includes + [:activity, :user, {:issue => [:tracker, :assigned_to, :priority]}]).
where(self.conditions(User.current.id)).
order('spent_on ASC')
end

def issue_time_entries_for_all_users(issue)
return issue.time_entries.find(:all,
:conditions => self.conditions(self.users),
:include => self.includes,
:include => [:activity, :user],
:order => "spent_on ASC")
return issue.time_entries.includes(self.includes + [:activity, :user]).
where(self.conditions(self.users)).
order('spent_on ASC')
end

def issue_time_entries_for_current_user(issue)
return issue.time_entries.find(:all,
:conditions => self.conditions(User.current.id),
:include => self.includes,
:include => [:activity, :user],
:order => "spent_on ASC")
return issue.time_entries.includes(self.includes + [:activity, :user]).
where(self.conditions(User.current.id)).
order('spent_on ASC')
end

def time_entries_for_user(user, options={})
extra_conditions = options.delete(:conditions)

return TimeEntry.find(:all,
:conditions => self.conditions([user], extra_conditions),
:include => self.includes,
:order => "spent_on ASC"
)
return TimeEntry.includes(self.includes).
where(self.conditions([user], extra_conditions)).
order('spent_on ASC')
end

def fetch_time_entries_by_project
Expand Down Expand Up @@ -463,11 +454,7 @@ def fetch_time_entries_by_date
logs = []

# extra_conditions = 'GROUP_BY spent_on'
logs=TimeEntry.find(:all,
:conditions => self.conditions(self.users),
:include => self.includes
# :group => "spent_on"
)
logs=TimeEntry.includes(self.includes).where(self.conditions(self.users))


unless logs.empty?
Expand Down
8 changes: 4 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
if Rails::VERSION::MAJOR >= 3
RedmineApp::Application.routes.draw do
match 'timesheet/index' => 'timesheet#index'
match 'timesheet/context_menu' => 'timesheet#context_menu'
match 'timesheet/report' => 'timesheet#report'
match 'timesheet/reset' => 'timesheet#reset', :via => :delete
get 'timesheet/index', :to => 'timesheet#index'
get 'timesheet/context_menu', :to => 'timesheet#context_menu'
match 'timesheet/report', :to => 'timesheet#report', :via => [:get, :post]
match 'timesheet/reset', :to => 'timesheet#reset', :via => :delete
end
else
ActionController::Routing::Routes.draw do |map|
Expand Down