Set activity/event options for acts_as_journalized.

pull/6827/head
Christian Rijke 11 years ago
parent 86cda01fc1
commit 586afeee5a
  1. 17
      app/models/cost_object.rb
  2. 10
      app/models/journal/cost_object_journal.rb
  3. 11
      app/models/variable_cost_object.rb

@ -14,15 +14,14 @@ class CostObject < ActiveRecord::Base
acts_as_attachable :after_remove => :attachment_removed
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",
:author_key => :author_id
end
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
validates_presence_of :subject, :project, :author, :kind
validates_length_of :subject, :maximum => 255

@ -20,16 +20,6 @@ class Journal::CostObjectJournal < ActiveRecord::Base
# 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,

@ -16,17 +16,6 @@ class VariableCostObject < CostObject
after_update :save_material_budget_items
after_update :save_labor_budget_items
if respond_to? :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
end
# override acts_as_journalized method
def activity_type

Loading…
Cancel
Save