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
aecb868b
Commit
aecb868b
authored
Jul 14, 2010
by
Tim Felgentreff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove more journal specific functionality
parent
d7768ce6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
149 deletions
+25
-149
issues_controller.rb
app/controllers/issues_controller.rb
+5
-5
issues_helper.rb
app/helpers/issues_helper.rb
+0
-76
issue.rb
app/models/issue.rb
+11
-60
_history.rhtml
app/views/issues/_history.rhtml
+4
-4
fetcher.rb
lib/redmine/activity/fetcher.rb
+4
-3
pdf.rb
lib/redmine/export/pdf.rb
+1
-1
No files found.
app/controllers/issues_controller.rb
View file @
aecb868b
...
...
@@ -111,8 +111,8 @@ class IssuesController < ApplicationController
end
def
show
@journals
=
@issue
.
journals
.
find
(
:all
,
:include
=>
[
:user
,
:details
],
:order
=>
"
#{
Journal
.
table_name
}
.created_on
ASC"
)
@journals
.
each_with_index
{
|
j
,
i
|
j
.
indice
=
i
+
1
}
@journals
=
@issue
.
journals
.
find
(
:all
,
:include
=>
[
:user
],
:order
=>
"
#{
Journal
.
table_name
}
.created_at
ASC"
)
@journals
.
each_with_index
{
|
j
,
i
|
j
.
number
=
i
+
1
}
@journals
.
reverse!
if
User
.
current
.
wants_comments_in_reverse_order?
@changesets
=
@issue
.
changesets
.
visible
.
all
@changesets
.
reverse!
if
User
.
current
.
wants_comments_in_reverse_order?
...
...
@@ -234,7 +234,7 @@ class IssuesController < ApplicationController
unsaved_issue_ids
=
[]
@issues
.
each
do
|
issue
|
issue
.
reload
journal
=
issue
.
init_journal
(
User
.
current
,
params
[
:notes
])
journal
=
issue
.
init_journal
(
params
[
:notes
])
issue
.
safe_attributes
=
attributes
call_hook
(
:controller_issues_bulk_edit_before_save
,
{
:params
=>
params
,
:issue
=>
issue
})
unless
issue
.
save
...
...
@@ -270,7 +270,7 @@ class IssuesController < ApplicationController
changed_attributes
[
valid_attribute
]
=
(
params
[
valid_attribute
]
==
'none'
?
nil
:
params
[
valid_attribute
])
end
end
issue
.
init_journal
(
User
.
current
)
issue
.
init_journal
call_hook
(
:controller_issues_move_before_save
,
{
:params
=>
params
,
:issue
=>
issue
,
:target_project
=>
@target_project
,
:copy
=>
!!
@copy
})
if
r
=
issue
.
move_to_project
(
@target_project
,
new_tracker
,
{
:copy
=>
@copy
,
:attributes
=>
changed_attributes
})
moved_issues
<<
r
...
...
@@ -436,7 +436,7 @@ private
@time_entry
=
TimeEntry
.
new
@notes
=
params
[
:notes
]
@issue
.
init_journal
(
User
.
current
,
@notes
)
@issue
.
init_journal
(
@notes
)
# User can change issue attributes only if he has :edit permission or if a workflow transition is allowed
if
(
@edit_allowed
||
!
@allowed_statuses
.
empty?
)
&&
params
[
:issue
]
attrs
=
params
[
:issue
].
dup
...
...
app/helpers/issues_helper.rb
View file @
aecb868b
...
...
@@ -100,82 +100,6 @@ module IssuesHelper
@sidebar_queries
end
def
show_detail
(
detail
,
no_html
=
false
)
case
detail
.
property
when
'attr'
field
=
detail
.
prop_key
.
to_s
.
gsub
(
/\_id$/
,
""
)
label
=
l
((
"field_"
+
field
).
to_sym
)
case
when
[
'due_date'
,
'start_date'
].
include?
(
detail
.
prop_key
)
value
=
format_date
(
detail
.
value
.
to_date
)
if
detail
.
value
old_value
=
format_date
(
detail
.
old_value
.
to_date
)
if
detail
.
old_value
when
[
'project_id'
,
'status_id'
,
'tracker_id'
,
'assigned_to_id'
,
'priority_id'
,
'category_id'
,
'fixed_version_id'
].
include?
(
detail
.
prop_key
)
value
=
find_name_by_reflection
(
field
,
detail
.
value
)
old_value
=
find_name_by_reflection
(
field
,
detail
.
old_value
)
when
detail
.
prop_key
==
'estimated_hours'
value
=
"%0.02f"
%
detail
.
value
.
to_f
unless
detail
.
value
.
blank?
old_value
=
"%0.02f"
%
detail
.
old_value
.
to_f
unless
detail
.
old_value
.
blank?
when
detail
.
prop_key
==
'parent_id'
label
=
l
(
:field_parent_issue
)
value
=
"#
#{
detail
.
value
}
"
unless
detail
.
value
.
blank?
old_value
=
"#
#{
detail
.
old_value
}
"
unless
detail
.
old_value
.
blank?
end
when
'cf'
custom_field
=
CustomField
.
find_by_id
(
detail
.
prop_key
)
if
custom_field
label
=
custom_field
.
name
value
=
format_value
(
detail
.
value
,
custom_field
.
field_format
)
if
detail
.
value
old_value
=
format_value
(
detail
.
old_value
,
custom_field
.
field_format
)
if
detail
.
old_value
end
when
'attachment'
label
=
l
(
:label_attachment
)
end
call_hook
(
:helper_issues_show_detail_after_setting
,
{
:detail
=>
detail
,
:label
=>
label
,
:value
=>
value
,
:old_value
=>
old_value
})
label
||=
detail
.
prop_key
value
||=
detail
.
value
old_value
||=
detail
.
old_value
unless
no_html
label
=
content_tag
(
'strong'
,
label
)
old_value
=
content_tag
(
"i"
,
h
(
old_value
))
if
detail
.
old_value
old_value
=
content_tag
(
"strike"
,
old_value
)
if
detail
.
old_value
and
(
!
detail
.
value
or
detail
.
value
.
empty?
)
if
detail
.
property
==
'attachment'
&&
!
value
.
blank?
&&
a
=
Attachment
.
find_by_id
(
detail
.
prop_key
)
# Link to the attachment if it has not been removed
value
=
link_to_attachment
(
a
)
else
value
=
content_tag
(
"i"
,
h
(
value
))
if
value
end
end
if
!
detail
.
value
.
blank?
case
detail
.
property
when
'attr'
,
'cf'
if
!
detail
.
old_value
.
blank?
l
(
:text_journal_changed
,
:label
=>
label
,
:old
=>
old_value
,
:new
=>
value
)
else
l
(
:text_journal_set_to
,
:label
=>
label
,
:value
=>
value
)
end
when
'attachment'
l
(
:text_journal_added
,
:label
=>
label
,
:value
=>
value
)
end
else
l
(
:text_journal_deleted
,
:label
=>
label
,
:old
=>
old_value
)
end
end
# Find the name of an associated record stored in the field attribute
def
find_name_by_reflection
(
field
,
id
)
association
=
Issue
.
reflect_on_association
(
field
.
to_sym
)
if
association
record
=
association
.
class_name
.
constantize
.
find_by_id
(
id
)
return
record
.
name
if
record
end
end
def
issues_to_csv
(
issues
,
project
=
nil
)
ic
=
Iconv
.
new
(
l
(
:general_csv_encoding
),
'UTF-8'
)
decimal_separator
=
l
(
:general_csv_decimal_separator
)
...
...
app/models/issue.rb
View file @
aecb868b
...
...
@@ -38,17 +38,16 @@ class Issue < ActiveRecord::Base
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
]}
:activity_find_options
=>
{
:include
=>
[
:project
,
:author
,
:tracker
]},
:activity_author_key
=>
:author_id
acts_as_searchable
:columns
=>
[
'subject'
,
"
#{
table_name
}
.description"
,
"
#{
Journal
.
table_name
}
.notes"
],
:include
=>
[
:project
,
:
change
s
],
:include
=>
[
:project
,
:
journal
s
],
# sort by id so that limited eager loading doesn't break with postgresql
:order_column
=>
"
#{
table_name
}
.id"
DONE_RATIO_OPTIONS
=
%w(issue_field issue_status)
attr_reader
:current_journal
validates_presence_of
:subject
,
:priority
,
:project
,
:tracker
,
:author
,
:status
validates_length_of
:subject
,
:maximum
=>
255
...
...
@@ -67,7 +66,7 @@ class Issue < ActiveRecord::Base
before_create
:default_assign
before_save
:reschedule_following_issues
,
:close_duplicates
,
:update_done_ratio_from_issue_status
after_save
:update_nested_set_attributes
,
:update_parent_attributes
,
:create_journal
after_save
:update_nested_set_attributes
,
:update_parent_attributes
after_destroy
:destroy_children
after_destroy
:update_parent_attributes
...
...
@@ -310,18 +309,7 @@ class Issue < ActiveRecord::Base
self
.
done_ratio
=
status
.
default_done_ratio
end
end
def
init_journal
(
user
,
notes
=
""
)
@current_journal
||=
Journal
.
new
(
:journalized
=>
self
,
:user
=>
user
,
:notes
=>
notes
)
@issue_before_change
=
self
.
clone
@issue_before_change
.
status
=
self
.
status
@custom_values_before_change
=
{}
self
.
custom_values
.
each
{
|
c
|
@custom_values_before_change
.
store
c
.
custom_field_id
,
c
.
value
}
# Make sure updated_on is updated when adding a note.
updated_on_will_change!
@current_journal
end
# Return true if the issue is closed, otherwise false
def
closed?
self
.
status
.
is_closed?
...
...
@@ -496,13 +484,12 @@ class Issue < ActiveRecord::Base
if
valid?
attachments
=
Attachment
.
attach_files
(
self
,
params
[
:attachments
])
attachments
[
:files
].
each
{
|
a
|
@current_journal
.
details
<<
JournalDetail
.
new
(
:property
=>
'attachment'
,
:prop_key
=>
a
.
id
,
:value
=>
a
.
filename
)}
# TODO: Rename hook
Redmine
::
Hook
.
call_hook
(
:controller_issues_edit_before_save
,
{
:params
=>
params
,
:issue
=>
self
,
:time_entry
=>
@time_entry
,
:journal
=>
@
current_journal
})
Redmine
::
Hook
.
call_hook
(
:controller_issues_edit_before_save
,
{
:params
=>
params
,
:issue
=>
self
,
:time_entry
=>
@time_entry
,
:journal
=>
current_journal
})
begin
if
save
# TODO: Rename hook
Redmine
::
Hook
.
call_hook
(
:controller_issues_edit_after_save
,
{
:params
=>
params
,
:issue
=>
self
,
:time_entry
=>
@time_entry
,
:journal
=>
@
current_journal
})
Redmine
::
Hook
.
call_hook
(
:controller_issues_edit_after_save
,
{
:params
=>
params
,
:issue
=>
self
,
:time_entry
=>
@time_entry
,
:journal
=>
current_journal
})
else
raise
ActiveRecord
::
Rollback
end
...
...
@@ -718,22 +705,12 @@ class Issue < ActiveRecord::Base
).
each
do
|
issue
|
next
if
issue
.
project
.
nil?
||
issue
.
fixed_version
.
nil?
unless
issue
.
project
.
shared_versions
.
include?
(
issue
.
fixed_version
)
issue
.
init_journal
(
User
.
current
)
issue
.
fixed_version
=
nil
issue
.
save
end
end
end
# Callback on attachment deletion
def
attachment_removed
(
obj
)
journal
=
init_journal
(
User
.
current
)
journal
.
details
<<
JournalDetail
.
new
(
:property
=>
'attachment'
,
:prop_key
=>
obj
.
id
,
:old_value
=>
obj
.
filename
)
journal
.
save
end
# Default assignment based on category
def
default_assign
if
assigned_to
.
nil?
&&
category
&&
category
.
assigned_to
...
...
@@ -758,40 +735,14 @@ class Issue < ActiveRecord::Base
duplicate
.
reload
# Don't re-close it if it's already closed
next
if
duplicate
.
closed?
# Same user and notes
if
@current_journal
duplicate
.
init_journal
(
@current_journal
.
user
,
@current_journal
.
notes
)
end
# Implicitely creates a new journal
duplicate
.
update_attribute
:status
,
self
.
status
# Same user and notes
duplicate
.
versions
.
last
.
user
=
current_journal
.
user
duplicate
.
versions
.
last
.
notes
=
current_journal
.
notes
end
end
end
# Saves the changes in a Journal
# Called after_save
def
create_journal
if
@current_journal
# attributes changes
(
Issue
.
column_names
-
%w(id description root_id lft rgt lock_version created_on updated_on)
).
each
{
|
c
|
@current_journal
.
details
<<
JournalDetail
.
new
(
:property
=>
'attr'
,
:prop_key
=>
c
,
:old_value
=>
@issue_before_change
.
send
(
c
),
:value
=>
send
(
c
))
unless
send
(
c
)
==
@issue_before_change
.
send
(
c
)
}
# custom fields changes
custom_values
.
each
{
|
c
|
next
if
(
@custom_values_before_change
[
c
.
custom_field_id
]
==
c
.
value
||
(
@custom_values_before_change
[
c
.
custom_field_id
].
blank?
&&
c
.
value
.
blank?
))
@current_journal
.
details
<<
JournalDetail
.
new
(
:property
=>
'cf'
,
:prop_key
=>
c
.
custom_field_id
,
:old_value
=>
@custom_values_before_change
[
c
.
custom_field_id
],
:value
=>
c
.
value
)
}
@current_journal
.
save
# reset current journal
init_journal
@current_journal
.
user
,
@current_journal
.
notes
end
end
# Query generator for selecting groups of issue counts for a project
# based on specific criteria
...
...
app/views/issues/_history.rhtml
View file @
aecb868b
<%
reply_links
=
authorize_for
(
'issues'
,
'edit'
)
-%>
<%
for
journal
in
journals
%>
<div
id=
"change-
<%=
journal
.
id
%>
"
class=
"journal"
>
<h4><div
style=
"float:right;"
>
<%=
link_to
"#
#{
journal
.
indice
}
"
,
:anchor
=>
"note-
#{
journal
.
indice
}
"
%>
</div>
<h4><div
style=
"float:right;"
>
<%=
link_to
"#
#{
journal
.
number
}
"
,
:anchor
=>
"note-
#{
journal
.
number
}
"
%>
</div>
<%=
avatar
(
journal
.
user
,
:size
=>
"24"
)
%>
<%=
content_tag
(
'a'
,
''
,
:name
=>
"note-
#{
journal
.
indice
}
"
)
%>
<%=
authoring
journal
.
created_
on
,
journal
.
user
,
:label
=>
:label_updated_time_by
%>
</h4>
<%=
content_tag
(
'a'
,
''
,
:name
=>
"note-
#{
journal
.
number
}
"
)
%>
<%=
authoring
journal
.
created_
at
,
journal
.
user
,
:label
=>
:label_updated_time_by
%>
</h4>
<%
if
journal
.
details
.
any?
%>
<ul
class=
"details"
>
<%
for
detail
in
journal
.
details
%>
<li>
<%=
show_detail
(
detail
)
%>
</li>
<li>
<%=
journal
.
show_detail
(
detail
)
%>
</li>
<%
end
%>
</ul>
<%
end
%>
...
...
lib/redmine/activity/fetcher.rb
View file @
aecb868b
...
...
@@ -68,6 +68,7 @@ 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
]
...
...
@@ -76,15 +77,15 @@ module Redmine
e
+=
provider
.
find_events
(
event_type
,
@user
,
from
,
to
,
@options
)
end
end
e
.
sort!
{
|
a
,
b
|
b
.
event_datetime
<=>
a
.
event_datetime
}
if
options
[
:limit
]
e
=
e
.
slice
(
0
,
options
[
:limit
])
end
e
end
private
def
constantized_providers
(
event_type
)
...
...
lib/redmine/export/pdf.rb
View file @
aecb868b
...
...
@@ -282,7 +282,7 @@ module Redmine
pdf
.
Ln
for
journal
in
issue
.
journals
.
find
(
:all
,
:include
=>
[
:user
,
:details
],
:order
=>
"
#{
Journal
.
table_name
}
.created_on ASC"
)
pdf
.
SetFontStyle
(
'B'
,
8
)
pdf
.
Cell
(
190
,
5
,
format_time
(
journal
.
created_
on
)
+
" - "
+
journal
.
user
.
name
)
pdf
.
Cell
(
190
,
5
,
format_time
(
journal
.
created_
at
)
+
" - "
+
journal
.
user
.
name
)
pdf
.
Ln
pdf
.
SetFontStyle
(
'I'
,
8
)
for
detail
in
journal
.
details
...
...
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