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
d7768ce6
Commit
d7768ce6
authored
Jul 14, 2010
by
Tim Felgentreff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove journals to start moving it all out to vestal_versions based plugin
parent
f2957176
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
176 deletions
+13
-176
issue.rb
app/models/issue.rb
+8
-10
journal.rb
app/models/journal.rb
+0
-23
version.rb
app/models/version.rb
+3
-0
environment.rb
config/environment.rb
+2
-2
init.rb
vendor/plugins/acts_as_journalized/init.rb
+0
-2
acts_as_journalized.rb
...or/plugins/acts_as_journalized/lib/acts_as_journalized.rb
+0
-139
No files found.
app/models/issue.rb
View file @
d7768ce6
...
...
@@ -25,7 +25,6 @@ class Issue < ActiveRecord::Base
belongs_to
:priority
,
:class_name
=>
'IssuePriority'
,
:foreign_key
=>
'priority_id'
belongs_to
:category
,
:class_name
=>
'IssueCategory'
,
:foreign_key
=>
'category_id'
has_many
:journals
,
:as
=>
:journalized
,
:dependent
=>
:destroy
has_many
:time_entries
,
:dependent
=>
:delete_all
has_and_belongs_to_many
:changesets
,
:order
=>
"
#{
Changeset
.
table_name
}
.committed_on ASC,
#{
Changeset
.
table_name
}
.id ASC"
...
...
@@ -36,16 +35,15 @@ class Issue < ActiveRecord::Base
acts_as_attachable
:after_remove
=>
:attachment_removed
acts_as_customizable
acts_as_watchable
acts_as_journalized
:event_title
=>
Proc
.
new
{
|
o
|
"
#{
o
.
tracker
.
name
}
#
#{
o
.
id
}
(
#{
o
.
status
}
):
#{
o
.
subject
}
"
},
:event_type
=>
Proc
.
new
{
|
o
|
'issue'
+
(
o
.
closed?
?
' closed'
:
''
)
},
:activity_find_options
=>
{
:include
=>
[
:project
,
:author
,
:tracker
]}
acts_as_searchable
:columns
=>
[
'subject'
,
"
#{
table_name
}
.description"
,
"
#{
Journal
.
table_name
}
.notes"
],
:include
=>
[
:project
,
:
journal
s
],
:include
=>
[
:project
,
:
change
s
],
# sort by id so that limited eager loading doesn't break with postgresql
:order_column
=>
"
#{
table_name
}
.id"
acts_as_event
:title
=>
Proc
.
new
{
|
o
|
"
#{
o
.
tracker
.
name
}
#
#{
o
.
id
}
(
#{
o
.
status
}
):
#{
o
.
subject
}
"
},
:url
=>
Proc
.
new
{
|
o
|
{
:controller
=>
'issues'
,
:action
=>
'show'
,
:id
=>
o
.
id
}},
:type
=>
Proc
.
new
{
|
o
|
'issue'
+
(
o
.
closed?
?
' closed'
:
''
)
}
acts_as_activity_provider
:find_options
=>
{
:include
=>
[
:project
,
:author
,
:tracker
]},
:author_key
=>
:author_id
DONE_RATIO_OPTIONS
=
%w(issue_field issue_status)
...
...
app/models/journal.rb
deleted
100644 → 0
View file @
f2957176
class
Journal
<
ActiveRecord
::
Base
self
.
abstract_class
=
true
belongs_to
:user
serialize
:details
attr_accessor
:indice
before_save
:check_for_empty_journal
def
check_for_empty_journal
# Do not save an empty journal
!
(
details
.
empty?
&&
notes
.
blank?
)
end
def
journalized
nil
end
def
project
journalized
.
respond_to?
(
'project'
)
?
journalized
.
project
:
nil
end
end
app/models/version.rb
View file @
d7768ce6
...
...
@@ -19,6 +19,9 @@ class Version < ActiveRecord::Base
after_update
:update_issues_from_sharing_change
belongs_to
:project
has_many
:fixed_issues
,
:class_name
=>
'Issue'
,
:foreign_key
=>
'fixed_version_id'
,
:dependent
=>
:nullify
acts_as_journalized
acts_as_customizable
acts_as_attachable
:view_permission
=>
:view_files
,
:delete_permission
=>
:manage_files
...
...
config/environment.rb
View file @
d7768ce6
...
...
@@ -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
,
:
journal_observer
,
:
news_observer
,
:document_observer
,
:wiki_content_observer
config
.
active_record
.
observers
=
: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
...
...
vendor/plugins/acts_as_journalized/init.rb
deleted
100644 → 0
View file @
f2957176
require
File
.
dirname
(
__FILE__
)
+
'/lib/acts_as_journalized'
ActiveRecord
::
Base
.
send
(
:include
,
Redmine
::
Acts
::
Journalized
)
vendor/plugins/acts_as_journalized/lib/acts_as_journalized.rb
deleted
100644 → 0
View file @
f2957176
module
Redmine
module
Acts
module
Journalized
def
self
.
included
(
base
)
base
.
extend
ClassMethods
end
module
ClassMethods
def
acts_as_journalized
(
options
=
{})
return
if
self
.
included_modules
.
include?
(
Redmine
::
Acts
::
Journalized
::
InstanceMethods
)
self
.
include
Redmine
::
Acts
::
Journalized
::
InstanceMethods
plural_name
=
self
.
name
.
underscore
.
pluralize
journal_name
=
"
#{
self
.
name
}
Journal"
extra_module
=
options
.
delete
(
:extra_module
)
event_hash
=
{
:description
=>
:notes
,
:author
=>
Proc
.
new
{
|
o
|
User
.
find_by_id
(
o
.
journal
.
user_id
)},
:url
=>
Proc
.
new
do
|
o
|
{
:controller
=>
self
.
name
.
underscore
.
pluralize
,
:action
=>
'show'
,
:id
=>
o
.
id
,
:anchor
=>
"change-
#{
o
.
id
}
"
}
end
}
activity_hash
=
{
:type
=>
plural_name
,
:permission
=>
"view_
#{
plural_name
}
"
.
to_sym
,
:author_key
=>
:user_id
,
}
options
.
each_pair
do
|
k
,
v
|
case
when
key
=
k
.
to_s
.
slice
(
/event_(.+)/
,
1
)
event_hash
[
key
.
to_sym
]
=
v
when
key
=
k
.
to_s
.
slice
(
/activity_(.+)/
,
1
)
activity_hash
[
key
.
to_sym
]
=
v
end
end
# create the new model class
journal
=
Class
.
new
(
Journal
)
journal
.
belongs_to
self
.
name
.
underscore
journal
.
acts_as_event
event_hash
journal
.
acts_as_activity_provider
activity_hash
journal
.
send
(
:include
,
extra_module
)
Object
.
const_set
(
"
#{
self
.
name
}
Journal"
,
journal
)
unless
Redmine
::
Activity
.
providers
[
plural_name
].
include?
self
.
name
Redmine
::
Activity
.
register
plural_name
.
to_sym
end
end
end
module
InstanceMethods
def
self
.
included
(
base
)
base
.
extend
ClassMethods
base
.
class_eval
do
after_save
:create_journal
has_many
:journals
,
:class_name
=>
"
#{
self
.
name
}
Journal"
,
:dependent
=>
:destroy
end
end
def
journal_class
"
#{
self
.
class
.
name
}
Journal"
.
constantize
end
def
init_journal
(
user
,
notes
=
""
)
@notes
||=
""
@current_journal
||=
journal_class
.
new
(
:journalized
=>
self
,
:user
=>
user
,
:notes
=>
notes
)
@object_before_change
=
self
.
clone
@object_before_change
.
status
=
self
.
status
if
self
.
respond_to?
:custom_values
@custom_values_before_change
=
{}
self
.
custom_values
.
each
{
|
c
|
@custom_values_before_change
[
c
.
custom_field_id
]
=
c
.
value
}
end
# Make sure updated_on is updated when adding a note.
updated_on_will_change!
@current_journal
end
# Saves the changes in a Journal
# Called after_save
def
create_journal
if
@current_journal
details
=
{
:attr
=>
{}}
if
self
.
respond_to?
:custom_values
details
[
:cf
]
=
{}
end
# attributes changes
self
.
class
.
journalized_columns
.
each
do
|
c
|
unless
send
(
c
)
==
@object_before_change
.
send
(
c
)
details
[
:attr
][
c
]
=
{
:old
=>
@object_before_change
.
send
(
c
),
:new
=>
send
(
c
)
}
end
end
if
self
.
respond_to?
:custom_values
# custom fields changes
custom_values
.
each
do
|
c
|
unless
(
@custom_values_before_change
[
c
.
custom_field_id
]
==
c
.
value
||
(
@custom_values_before_change
[
c
.
custom_field_id
].
blank?
&&
c
.
value
.
blank?
))
details
[
:cf
][
c
.
custom_field_id
]
=
{
:old
=>
@custom_values_before_change
[
c
.
custom_field_id
],
:new
=>
c
.
value
}
end
end
end
@current_journal
.
details
=
details
@current_journal
.
save
end
end
module
ClassMethods
def
journalized_columns
=
(
columns
=
[])
@journalized_columns
=
columns
end
def
journalized_columns
@journalized_columns
||=
begin
(
self
.
column_names
-
%w(id description lock_version created_on updated_on)
)
end
end
end
end
end
end
end
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