Adds document journalization

pull/312/head
Hagen Schink 11 years ago
parent da823f4899
commit 614cc63d49
  1. 10
      app/models/document.rb
  2. 26
      app/models/journal/document_journal.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

@ -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
Loading…
Cancel
Save