OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/app/models/planning_element.rb

42 lines
1.3 KiB

#-- copyright
# OpenProject is a project management system.
#
# Copyright (C) 2012-2013 the OpenProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
class PlanningElement < WorkPackage
unloadable
include ActiveModel::ForbiddenAttributesProtection
accepts_nested_attributes_for_apis_for :parent,
:planning_element_status,
:type,
:project
scope :for_projects, lambda { |projects|
{:conditions => {:project_id => projects}}
}
validate do
if self.is_milestone?
if self.due_date and self.start_date and self.start_date != self.due_date
errors.add :due_date, :not_start_date
end
end
# TODO: reconsider self.parent.is_a?(PlanningElement)
# once any of the errors can also apply when using issues
if self.parent && self.parent.is_a?(PlanningElement)
errors.add :parent, :cannot_be_milestone if parent.is_milestone?
errors.add :parent, :cannot_be_in_another_project if parent.project != project
errors.add :parent, :cannot_be_in_recycle_bin if parent.deleted?
end
end
end