Add CostObject and VariableCostObject journals (model and migrations), extend WorkPackageJournal.

pull/6827/head
Christian Rijke 11 years ago
parent 9968db24b3
commit fe732cf767
  1. 1
      app/models/cost_object.rb
  2. 43
      app/models/journal/cost_object_journal.rb
  3. 34
      app/models/journal/variable_cost_object_journal.rb
  4. 40
      db/migrate/20130918084158_add_cost_object_journals.rb
  5. 5
      db/migrate/20130918084919_add_cost_object_id_to_work_package_journals.rb

@ -17,6 +17,7 @@ class CostObject < ActiveRecord::Base
unless respond_to? :acts_as_journalized
acts_as_event :title => Proc.new {|o| "#{l(:label_cost_object)} ##{o.id}: #{o.subject}"},
:url => Proc.new {|o| {:controller => '/cost_objects', :action => 'show', :id => o.id}}
acts_as_journalized
acts_as_activity_provider :find_options => {:include => [:project, :author]},
:timestamp => "#{table_name}.updated_on",

@ -0,0 +1,43 @@
#-- encoding: UTF-8
#-- 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 Journal::CostObjectJournal < ActiveRecord::Base
# include ActiveModel::ForbiddenAttributesProtection
self.table_name = "cost_object_journals"
belongs_to :journal
# attr_accessible :project_id, :author_id, :subject, :description, :fixed_date, :created_on
# acts_as_journalized
# acts_as_journalized :event_type => 'cost-object',
# :event_title => Proc.new {|o| "#{l(:label_cost_object)} ##{o.journaled.id}: #{o.subject}"},
# :event_url => Proc.new {|o| {:controller => 'cost_objects', :action => 'show', :id => o.journaled.id}},
# :activity_type => superclass.plural_name,
# :activity_find_options => {:include => [:project, :author]},
# :activity_timestamp => "#{table_name}.updated_on",
# :activity_author_key => :author_id,
# :activity_permission => :view_cost_objects
@@journaled_attributes = [:project_id,
:author_id,
:subject,
:description,
:fixed_date]
def journaled_attributes
attributes.symbolize_keys.select{|k,_| @@journaled_attributes.include? k}
end
end

@ -0,0 +1,34 @@
#-- encoding: UTF-8
#-- 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 Journal::VariableCostObjectJournal < Journal::CostObjectJournal
# include ActiveModel::ForbiddenAttributesProtection
# self.table_name = "cost_object_journals"
# belongs_to :journal
# attr_accessible :type, :id, :project_id, :author_id, :subject, :description, :fixed_date, :created_on
# @@journaled_attributes = [:project_id,
# :author_id,
# :subject,
# :description,
# :type,
# :fixed_date]
# def journaled_attributes
# attributes.symbolize_keys.select{|k,_| @@journaled_attributes.include? k}
# end
end

@ -0,0 +1,40 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2013 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
class AddCostObjectJournals < ActiveRecord::Migration
def change
create_table :cost_object_journals do |t|
t.integer :journal_id, :null => false
t.integer :project_id, :null => false
t.integer :author_id, :null => false
t.string :subject, :null => false
t.text :description, :null => false
t.date :fixed_date, :null => false
t.datetime :created_on
end
end
end

@ -0,0 +1,5 @@
class AddCostObjectIdToWorkPackageJournals < ActiveRecord::Migration
def change
add_column :work_package_journals, :cost_object_id, :integer, null: true
end
end
Loading…
Cancel
Save