Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
OHR Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
97
Issues
97
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
OHR Support
Commits
2d282f8d
Commit
2d282f8d
authored
Jul 15, 2010
by
Tim Felgentreff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move (almost) everything over to acts_as_journalized
parent
4b0bd11f
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
45 additions
and
46 deletions
+45
-46
changeset.rb
app/models/changeset.rb
+8
-10
document.rb
app/models/document.rb
+9
-6
mail_handler.rb
app/models/mail_handler.rb
+3
-3
mailer.rb
app/models/mailer.rb
+1
-1
message.rb
app/models/message.rb
+13
-9
news.rb
app/models/news.rb
+2
-4
time_entry.rb
app/models/time_entry.rb
+6
-9
environment.rb
config/environment.rb
+1
-1
fetcher.rb
lib/redmine/activity/fetcher.rb
+1
-2
acts_as_activity_provider.rb
...cts_as_activity_provider/lib/acts_as_activity_provider.rb
+1
-1
No files found.
app/models/changeset.rb
View file @
2d282f8d
...
...
@@ -23,20 +23,18 @@ class Changeset < ActiveRecord::Base
has_many
:changes
,
:dependent
=>
:delete_all
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
))},
:description
=>
:long_comments
,
:datetime
=>
:committed_on
,
:url
=>
Proc
.
new
{
|
o
|
{
:controller
=>
'repositories'
,
:action
=>
'revision'
,
:id
=>
o
.
repository
.
project
,
:rev
=>
o
.
revision
}}
acts_as_journalized
:event_title
=>
Proc
.
new
{
|
o
|
"
#{
l
(
:label_revision
)
}
#{
o
.
revision
}
"
+
(
o
.
short_comments
.
blank?
?
''
:
(
': '
+
o
.
short_comments
))},
:event_description
=>
:long_comments
,
:event_datetime
=>
:committed_on
,
: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'
,
:include
=>
{
:repository
=>
:project
},
:project_key
=>
"
#{
Repository
.
table_name
}
.project_id"
,
: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_uniqueness_of
:revision
,
:scope
=>
:repository_id
validates_uniqueness_of
:scmid
,
:scope
=>
:repository_id
,
:allow_nil
=>
true
...
...
app/models/document.rb
View file @
2d282f8d
...
...
@@ -20,15 +20,18 @@ 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
|
"
#{
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_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_length_of
:title
,
:maximum
=>
60
def
visible?
(
user
=
User
.
current
)
!
user
.
nil?
&&
user
.
allowed_to?
(
:view_documents
,
project
)
end
...
...
app/models/mail_handler.rb
View file @
2d282f8d
...
...
@@ -197,11 +197,11 @@ class MailHandler < ActionMailer::Base
# Reply will be added to the issue
def
receive_journal_reply
(
journal_id
)
journal
=
Journal
.
find_by_id
(
journal_id
)
if
journal
&&
journal
.
journaliz
ed_type
==
'Issue'
receive_issue_reply
(
journal
.
journaliz
ed_id
)
if
journal
&&
journal
.
version
ed_type
==
'Issue'
receive_issue_reply
(
journal
.
version
ed_id
)
end
end
# Receives a reply to a forum message
def
receive_message_reply
(
message_id
)
message
=
Message
.
find_by_id
(
message_id
)
...
...
app/models/mailer.rb
View file @
2d282f8d
...
...
@@ -55,7 +55,7 @@ class Mailer < ActionMailer::Base
# issue_edit(journal) => tmail object
# Mailer.deliver_issue_edit(journal) => sends an email to issue recipients
def
issue_edit
(
journal
)
issue
=
journal
.
journaliz
ed
.
reload
issue
=
journal
.
version
ed
.
reload
redmine_headers
'Project'
=>
issue
.
project
.
identifier
,
'Issue-Id'
=>
issue
.
id
,
'Issue-Author'
=>
issue
.
author
.
login
...
...
app/models/message.rb
View file @
2d282f8d
...
...
@@ -21,21 +21,25 @@ class Message < ActiveRecord::Base
acts_as_tree
:counter_cache
=>
:replies_count
,
:order
=>
"
#{
Message
.
table_name
}
.created_on ASC"
acts_as_attachable
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'
],
:include
=>
{
:board
=>
:project
},
:project_key
=>
'project_id'
,
: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
attr_protected
:locked
,
:sticky
validates_presence_of
:board
,
:subject
,
:content
validates_length_of
:subject
,
:maximum
=>
255
...
...
app/models/news.rb
View file @
2d282f8d
...
...
@@ -24,11 +24,9 @@ class News < ActiveRecord::Base
validates_length_of
:title
,
:maximum
=>
60
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_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
)
!
user
.
nil?
&&
user
.
allowed_to?
(
:view_news
,
project
)
end
...
...
app/models/time_entry.rb
View file @
2d282f8d
...
...
@@ -22,18 +22,15 @@ class TimeEntry < ActiveRecord::Base
belongs_to
:issue
belongs_to
:user
belongs_to
:activity
,
:class_name
=>
'TimeEntryActivity'
,
:foreign_key
=>
'activity_id'
attr_protected
:project_id
,
:user_id
,
:tyear
,
:tmonth
,
:tweek
acts_as_customizable
acts_as_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
}},
:author
=>
:user
,
:description
=>
:comments
acts_as_activity_provider
:timestamp
=>
"
#{
table_name
}
.created_on"
,
:author_key
=>
:user_id
,
:find_options
=>
{
:include
=>
:project
}
acts_as_journalized
:event_title
=>
Proc
.
new
{
|
o
|
"
#{
l_hours
(
o
.
hours
)
}
(
#{
(
o
.
issue
||
o
.
project
).
event_title
}
)"
},
:event_url
=>
Proc
.
new
{
|
o
|
{
:controller
=>
'timelog'
,
:action
=>
'details'
,
:project_id
=>
o
.
project
,
:issue_id
=>
o
.
issue
}},
:event_author
=>
:user
,
:event_description
=>
:comments
,
:activity_timestamp
=>
"
#{
table_name
}
.created_on"
validates_presence_of
:user_id
,
:activity_id
,
:project_id
,
:hours
,
:spent_on
validates_numericality_of
:hours
,
:allow_nil
=>
true
,
:message
=>
:invalid
...
...
config/environment.rb
View file @
2d282f8d
...
...
@@ -36,7 +36,7 @@ Rails::Initializer.run do |config|
# Activate observers that should always be running
# 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
# config.active_record.default_timezone = :utc
...
...
lib/redmine/activity/fetcher.rb
View file @
2d282f8d
...
...
@@ -68,10 +68,9 @@ module Redmine
# Returns an array of events for the given date range
# sorted in reverse chronological order
def
events
(
from
=
nil
,
to
=
nil
,
options
=
{})
require
'ruby-debug'
;
debugger
e
=
[]
@options
[
:limit
]
=
options
[
:limit
]
@scope
.
each
do
|
event_type
|
constantized_providers
(
event_type
).
each
do
|
provider
|
e
+=
provider
.
find_events
(
event_type
,
@user
,
from
,
to
,
@options
)
...
...
vendor/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb
View file @
2d282f8d
...
...
@@ -54,7 +54,7 @@ module Redmine
def
find_events
(
event_type
,
user
,
from
,
to
,
options
)
provider_options
=
activity_provider_options
[
event_type
]
raise
"
#{
self
.
name
}
can not provide
#{
event_type
}
events."
if
provider_options
.
nil?
scope_options
=
{}
cond
=
ARCondition
.
new
if
from
&&
to
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment