diff options
Diffstat (limited to 'app/models/project.rb')
-rw-r--r-- | app/models/project.rb | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 7e4f4ce50..3162676b6 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -67,8 +67,6 @@ class Project < ActiveRecord::Base :url => Proc.new {|o| {:controller => 'projects', :action => 'show', :id => o}}, :author => nil - attr_protected :status - validates_presence_of :name, :identifier validates_uniqueness_of :identifier, :if => Proc.new {|p| p.identifier_changed?} validates_length_of :name, :maximum => 255 @@ -80,9 +78,9 @@ class Project < ActiveRecord::Base validates_exclusion_of :identifier, :in => %w( new ) validate :validate_parent - after_save :update_inherited_members, :if => Proc.new {|project| project.inherit_members_changed?} - after_save :remove_inherited_member_roles, :add_inherited_member_roles, :if => Proc.new {|project| project.parent_id_changed?} - after_update :update_versions_from_hierarchy_change, :if => Proc.new {|project| project.parent_id_changed?} + after_save :update_inherited_members, :if => Proc.new {|project| project.saved_change_to_inherit_members?} + after_save :remove_inherited_member_roles, :add_inherited_member_roles, :if => Proc.new {|project| project.saved_change_to_parent_id?} + after_update :update_versions_from_hierarchy_change, :if => Proc.new {|project| project.saved_change_to_parent_id?} before_destroy :delete_all_members scope :has_module, lambda {|mod| @@ -257,6 +255,15 @@ class Project < ActiveRecord::Base scope end + # Creates or updates project time entry activities + def update_or_create_time_entry_activities(activities) + transaction do + activities.each do |id, activity| + update_or_create_time_entry_activity(id, activity) + end + end + end + # Will create a new Project specific Activity or update an existing one # # This will raise a ActiveRecord::Rollback if the TimeEntryActivity @@ -776,6 +783,10 @@ class Project < ActiveRecord::Base :if => lambda {|project, user| project.parent.nil? || project.parent.visible?(user)} def safe_attributes=(attrs, user=User.current) + if attrs.respond_to?(:to_unsafe_hash) + attrs = attrs.to_unsafe_hash + end + return unless attrs.is_a?(Hash) attrs = attrs.deep_dup @@ -872,10 +883,10 @@ class Project < ActiveRecord::Base def update_inherited_members if parent - if inherit_members? && !inherit_members_was + if inherit_members? && !inherit_members_before_last_save remove_inherited_member_roles add_inherited_member_roles - elsif !inherit_members? && inherit_members_was + elsif !inherit_members? && inherit_members_before_last_save remove_inherited_member_roles end end |