diff --git a/app/models/document.rb b/app/models/document.rb index 5fd5120871..49c3a9d002 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -16,11 +16,11 @@ class Document < ActiveRecord::Base belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id" acts_as_attachable :delete_permission => :manage_documents - #acts_as_journalized :event_title => Proc.new {|o| "#{Document.model_name.human}: #{o.title}"}, - # :event_url => Proc.new {|o| {:controller => '/documents', :action => 'show', :id => o.journaled_id}}, - # :event_author => (Proc.new do |o| - # o.attachments.find(:first, :order => "#{Attachment.table_name}.created_on ASC").try(:author) - # end) + acts_as_journalized :event_title => Proc.new {|o| "#{Document.model_name.human}: #{o.title}"}, + :event_url => Proc.new {|o| {:controller => '/documents', :action => 'show', :id => o.journaled_id}}, + :event_author => (Proc.new do |o| + o.attachments.find(:first, :order => "#{Attachment.table_name}.created_on ASC").try(:author) + end) acts_as_searchable :columns => ['title', "#{table_name}.description"], :include => :project diff --git a/app/models/journal/document_journal.rb b/app/models/journal/document_journal.rb new file mode 100644 index 0000000000..2a0fb4be03 --- /dev/null +++ b/app/models/journal/document_journal.rb @@ -0,0 +1,26 @@ +#-- 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::DocumentJournal < ActiveRecord::Base + self.table_name = "document_journals" + + @@journaled_attributes = [:project_id, + :category_id, + :title, + :description, + :created_on] + + def journaled_attributes + attributes.symbolize_keys.select{|k,_| @@journaled_attributes.include? k} + end + +end