Changed the Timelogs to use both the Systemwide and Project specific TimeEntryActivities
* Added Project#activities to return all the Systemwide and Project specific activities, excluding Systemwide ones that are overridden. * Added some tests for TimelogHelper. #4077 git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2948 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
1 parent
29301c8a38
commit
e615266e9a
5 files changed
+133
-4
No files matched your search
@@ -62,7 +62,7 @@ class Enumeration < ActiveRecord::Base
|
||||
|
||||
named_scope :active, lambda {
|
||||
{
|
||||
:conditions => {:active => true},
|
||||
:conditions => {:active => true, :project_id => nil},
|
||||
:order => 'position'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ class Project < ActiveRecord::Base
|
||||
STATUS_ACTIVE = 1
|
||||
STATUS_ARCHIVED = 9
|
||||
|
||||
has_many :time_entry_activities, :conditions => {:active => true } # Specific overidden Activities
|
||||
has_many :members, :include => :user, :conditions => "#{User.table_name}.type='User' AND #{User.table_name}.status=#{User::STATUS_ACTIVE}"
|
||||
has_many :member_principals, :class_name => 'Member',
|
||||
:include => :principal,
|
||||
@@ -155,6 +156,17 @@ class Project < ActiveRecord::Base
|
||||
statements.empty? ? base_statement : "((#{base_statement}) AND (#{statements.join(' OR ')}))"
|
||||
end
|
||||
|
||||
# Returns all the Systemwide and project specific activities
|
||||
def activities
|
||||
overridden_activity_ids = self.time_entry_activities.collect(&:parent_id)
|
||||
|
||||
if overridden_activity_ids.empty?
|
||||
return TimeEntryActivity.active
|
||||
else
|
||||
return system_activities_and_project_overrides
|
||||
end
|
||||
end
|
||||
|
||||
# Returns a :conditions SQL string that can be used to find the issues associated with this project.
|
||||
#
|
||||
# Examples:
|
||||
@@ -446,4 +458,12 @@ private
|
||||
def allowed_actions
|
||||
@actions_allowed ||= allowed_permissions.inject([]) { |actions, permission| actions += Redmine::AccessControl.allowed_actions(permission) }.flatten
|
||||
end
|
||||
|
||||
# Returns the systemwide activities merged with the project specific overrides
|
||||
def system_activities_and_project_overrides
|
||||
return TimeEntryActivity.active.
|
||||
find(:all,
|
||||
:conditions => ["id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)]) +
|
||||
self.time_entry_activities
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user