move (almost) everything over to acts_as_journalized
This commit is contained in:
parent
4b0bd11f6d
commit
2d282f8deb
@ -23,20 +23,18 @@ class Changeset < ActiveRecord::Base
|
|||||||
has_many :changes, :dependent => :delete_all
|
has_many :changes, :dependent => :delete_all
|
||||||
has_and_belongs_to_many :issues
|
has_and_belongs_to_many :issues
|
||||||
|
|
||||||
acts_as_event :title => Proc.new {|o| "#{l(:label_revision)} #{o.revision}" + (o.short_comments.blank? ? '' : (': ' + o.short_comments))},
|
acts_as_journalized :event_title => Proc.new {|o| "#{l(:label_revision)} #{o.revision}" + (o.short_comments.blank? ? '' : (': ' + o.short_comments))},
|
||||||
:description => :long_comments,
|
:event_description => :long_comments,
|
||||||
:datetime => :committed_on,
|
:event_datetime => :committed_on,
|
||||||
:url => Proc.new {|o| {:controller => 'repositories', :action => 'revision', :id => o.repository.project, :rev => o.revision}}
|
:event_url => Proc.new {|o| {:controller => 'repositories', :action => 'revision', :id => o.repository.project, :rev => o.revision}},
|
||||||
|
:activity_timestamp => "#{table_name}.committed_on",
|
||||||
|
:activity_author_key => :user_id
|
||||||
|
|
||||||
acts_as_searchable :columns => 'comments',
|
acts_as_searchable :columns => 'comments',
|
||||||
:include => {:repository => :project},
|
:include => {:repository => :project},
|
||||||
:project_key => "#{Repository.table_name}.project_id",
|
:project_key => "#{Repository.table_name}.project_id",
|
||||||
:date_column => 'committed_on'
|
:date_column => 'committed_on'
|
||||||
|
|
||||||
acts_as_activity_provider :timestamp => "#{table_name}.committed_on",
|
|
||||||
:author_key => :user_id,
|
|
||||||
:find_options => {:include => [:user, {:repository => :project}]}
|
|
||||||
|
|
||||||
validates_presence_of :repository_id, :revision, :committed_on, :commit_date
|
validates_presence_of :repository_id, :revision, :committed_on, :commit_date
|
||||||
validates_uniqueness_of :revision, :scope => :repository_id
|
validates_uniqueness_of :revision, :scope => :repository_id
|
||||||
validates_uniqueness_of :scmid, :scope => :repository_id, :allow_nil => true
|
validates_uniqueness_of :scmid, :scope => :repository_id, :allow_nil => true
|
||||||
|
@ -20,11 +20,14 @@ class Document < ActiveRecord::Base
|
|||||||
belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id"
|
belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id"
|
||||||
acts_as_attachable :delete_permission => :manage_documents
|
acts_as_attachable :delete_permission => :manage_documents
|
||||||
|
|
||||||
|
acts_as_journalized :event_title => Proc.new {|o| "#{l(:label_document)}: #{o.title}"},
|
||||||
|
:event_url => Proc.new {|o| {:controller => 'documents', :action => 'show', :id => o.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
|
acts_as_searchable :columns => ['title', "#{table_name}.description"], :include => :project
|
||||||
acts_as_event :title => Proc.new {|o| "#{l(:label_document)}: #{o.title}"},
|
|
||||||
:author => Proc.new {|o| (a = o.attachments.find(:first, :order => "#{Attachment.table_name}.created_on ASC")) ? a.author : nil },
|
|
||||||
:url => Proc.new {|o| {:controller => 'documents', :action => 'show', :id => o.id}}
|
|
||||||
acts_as_activity_provider :find_options => {:include => :project}
|
|
||||||
|
|
||||||
validates_presence_of :project, :title, :category
|
validates_presence_of :project, :title, :category
|
||||||
validates_length_of :title, :maximum => 60
|
validates_length_of :title, :maximum => 60
|
||||||
|
@ -197,8 +197,8 @@ class MailHandler < ActionMailer::Base
|
|||||||
# Reply will be added to the issue
|
# Reply will be added to the issue
|
||||||
def receive_journal_reply(journal_id)
|
def receive_journal_reply(journal_id)
|
||||||
journal = Journal.find_by_id(journal_id)
|
journal = Journal.find_by_id(journal_id)
|
||||||
if journal && journal.journalized_type == 'Issue'
|
if journal && journal.versioned_type == 'Issue'
|
||||||
receive_issue_reply(journal.journalized_id)
|
receive_issue_reply(journal.versioned_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class Mailer < ActionMailer::Base
|
|||||||
# issue_edit(journal) => tmail object
|
# issue_edit(journal) => tmail object
|
||||||
# Mailer.deliver_issue_edit(journal) => sends an email to issue recipients
|
# Mailer.deliver_issue_edit(journal) => sends an email to issue recipients
|
||||||
def issue_edit(journal)
|
def issue_edit(journal)
|
||||||
issue = journal.journalized.reload
|
issue = journal.versioned.reload
|
||||||
redmine_headers 'Project' => issue.project.identifier,
|
redmine_headers 'Project' => issue.project.identifier,
|
||||||
'Issue-Id' => issue.id,
|
'Issue-Id' => issue.id,
|
||||||
'Issue-Author' => issue.author.login
|
'Issue-Author' => issue.author.login
|
||||||
|
@ -22,18 +22,22 @@ class Message < ActiveRecord::Base
|
|||||||
acts_as_attachable
|
acts_as_attachable
|
||||||
belongs_to :last_reply, :class_name => 'Message', :foreign_key => 'last_reply_id'
|
belongs_to :last_reply, :class_name => 'Message', :foreign_key => 'last_reply_id'
|
||||||
|
|
||||||
|
acts_as_journalized :event_title => Proc.new {|o| "#{o.board.name}: #{o.subject}"},
|
||||||
|
:event_description => :content,
|
||||||
|
:event_type => Proc.new {|o| o.parent_id.nil? ? 'message' : 'reply'},
|
||||||
|
:event_url => (Proc.new do |o|
|
||||||
|
if o.parent_id.nil?
|
||||||
|
{:id => o.id}
|
||||||
|
else
|
||||||
|
{:id => o.parent_id, :r => o.id, :anchor => "message-#{o.id}"}
|
||||||
|
end.reverse_merge :controller => 'messages', :action => 'show', :board_id => o.board_id
|
||||||
|
end)
|
||||||
|
|
||||||
acts_as_searchable :columns => ['subject', 'content'],
|
acts_as_searchable :columns => ['subject', 'content'],
|
||||||
:include => {:board => :project},
|
:include => {:board => :project},
|
||||||
:project_key => 'project_id',
|
:project_key => 'project_id',
|
||||||
:date_column => "#{table_name}.created_on"
|
:date_column => "#{table_name}.created_on"
|
||||||
acts_as_event :title => Proc.new {|o| "#{o.board.name}: #{o.subject}"},
|
|
||||||
:description => :content,
|
|
||||||
:type => Proc.new {|o| o.parent_id.nil? ? 'message' : 'reply'},
|
|
||||||
:url => Proc.new {|o| {:controller => 'messages', :action => 'show', :board_id => o.board_id}.merge(o.parent_id.nil? ? {:id => o.id} :
|
|
||||||
{:id => o.parent_id, :r => o.id, :anchor => "message-#{o.id}"})}
|
|
||||||
|
|
||||||
acts_as_activity_provider :find_options => {:include => [{:board => :project}, :author]},
|
|
||||||
:author_key => :author_id
|
|
||||||
acts_as_watchable
|
acts_as_watchable
|
||||||
|
|
||||||
attr_protected :locked, :sticky
|
attr_protected :locked, :sticky
|
||||||
|
@ -24,10 +24,8 @@ class News < ActiveRecord::Base
|
|||||||
validates_length_of :title, :maximum => 60
|
validates_length_of :title, :maximum => 60
|
||||||
validates_length_of :summary, :maximum => 255
|
validates_length_of :summary, :maximum => 255
|
||||||
|
|
||||||
|
acts_as_journalized :event_url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.id} }
|
||||||
acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"], :include => :project
|
acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"], :include => :project
|
||||||
acts_as_event :url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.id}}
|
|
||||||
acts_as_activity_provider :find_options => {:include => [:project, :author]},
|
|
||||||
:author_key => :author_id
|
|
||||||
|
|
||||||
def visible?(user=User.current)
|
def visible?(user=User.current)
|
||||||
!user.nil? && user.allowed_to?(:view_news, project)
|
!user.nil? && user.allowed_to?(:view_news, project)
|
||||||
|
@ -26,14 +26,11 @@ class TimeEntry < ActiveRecord::Base
|
|||||||
attr_protected :project_id, :user_id, :tyear, :tmonth, :tweek
|
attr_protected :project_id, :user_id, :tyear, :tmonth, :tweek
|
||||||
|
|
||||||
acts_as_customizable
|
acts_as_customizable
|
||||||
acts_as_event :title => Proc.new {|o| "#{l_hours(o.hours)} (#{(o.issue || o.project).event_title})"},
|
acts_as_journalized :event_title => Proc.new {|o| "#{l_hours(o.hours)} (#{(o.issue || o.project).event_title})"},
|
||||||
:url => Proc.new {|o| {:controller => 'timelog', :action => 'details', :project_id => o.project, :issue_id => o.issue}},
|
:event_url => Proc.new {|o| {:controller => 'timelog', :action => 'details', :project_id => o.project, :issue_id => o.issue}},
|
||||||
:author => :user,
|
:event_author => :user,
|
||||||
:description => :comments
|
:event_description => :comments,
|
||||||
|
:activity_timestamp => "#{table_name}.created_on"
|
||||||
acts_as_activity_provider :timestamp => "#{table_name}.created_on",
|
|
||||||
:author_key => :user_id,
|
|
||||||
:find_options => {:include => :project}
|
|
||||||
|
|
||||||
validates_presence_of :user_id, :activity_id, :project_id, :hours, :spent_on
|
validates_presence_of :user_id, :activity_id, :project_id, :hours, :spent_on
|
||||||
validates_numericality_of :hours, :allow_nil => true, :message => :invalid
|
validates_numericality_of :hours, :allow_nil => true, :message => :invalid
|
||||||
|
@ -36,7 +36,7 @@ Rails::Initializer.run do |config|
|
|||||||
|
|
||||||
# Activate observers that should always be running
|
# Activate observers that should always be running
|
||||||
# config.active_record.observers = :cacher, :garbage_collector
|
# config.active_record.observers = :cacher, :garbage_collector
|
||||||
config.active_record.observers = :message_observer, :issue_observer, :news_observer, :document_observer, :wiki_content_observer
|
config.active_record.observers = :journal_observer, :message_observer, :issue_observer, :news_observer, :document_observer, :wiki_content_observer
|
||||||
|
|
||||||
# Make Active Record use UTC-base instead of local time
|
# Make Active Record use UTC-base instead of local time
|
||||||
# config.active_record.default_timezone = :utc
|
# config.active_record.default_timezone = :utc
|
||||||
|
@ -68,7 +68,6 @@ module Redmine
|
|||||||
# Returns an array of events for the given date range
|
# Returns an array of events for the given date range
|
||||||
# sorted in reverse chronological order
|
# sorted in reverse chronological order
|
||||||
def events(from = nil, to = nil, options={})
|
def events(from = nil, to = nil, options={})
|
||||||
require 'ruby-debug'; debugger
|
|
||||||
e = []
|
e = []
|
||||||
@options[:limit] = options[:limit]
|
@options[:limit] = options[:limit]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user