@@ -5,12 +5,12 | |||||
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 |
# |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 |
# |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
@@ -20,11 +20,11 class Journal < ActiveRecord::Base | |||||
20 | # added as a quick fix to allow eager loading of the polymorphic association |
|
20 | # added as a quick fix to allow eager loading of the polymorphic association | |
21 | # since always associated to an issue, for now |
|
21 | # since always associated to an issue, for now | |
22 | belongs_to :issue, :foreign_key => :journalized_id |
|
22 | belongs_to :issue, :foreign_key => :journalized_id | |
23 |
|
23 | |||
24 | belongs_to :user |
|
24 | belongs_to :user | |
25 | has_many :details, :class_name => "JournalDetail", :dependent => :delete_all |
|
25 | has_many :details, :class_name => "JournalDetail", :dependent => :delete_all | |
26 | attr_accessor :indice |
|
26 | attr_accessor :indice | |
27 |
|
27 | |||
28 | acts_as_event :title => Proc.new {|o| status = ((s = o.new_status) ? " (#{s})" : nil); "#{o.issue.tracker} ##{o.issue.id}#{status}: #{o.issue.subject}" }, |
|
28 | acts_as_event :title => Proc.new {|o| status = ((s = o.new_status) ? " (#{s})" : nil); "#{o.issue.tracker} ##{o.issue.id}#{status}: #{o.issue.subject}" }, | |
29 | :description => :notes, |
|
29 | :description => :notes, | |
30 | :author => :user, |
|
30 | :author => :user, | |
@@ -36,36 +36,36 class Journal < ActiveRecord::Base | |||||
36 | :find_options => {:include => [{:issue => :project}, :details, :user], |
|
36 | :find_options => {:include => [{:issue => :project}, :details, :user], | |
37 | :conditions => "#{Journal.table_name}.journalized_type = 'Issue' AND" + |
|
37 | :conditions => "#{Journal.table_name}.journalized_type = 'Issue' AND" + | |
38 | " (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')"} |
|
38 | " (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')"} | |
39 |
|
39 | |||
40 | named_scope :visible, lambda {|*args| { |
|
40 | named_scope :visible, lambda {|*args| { | |
41 | :include => {:issue => :project}, |
|
41 | :include => {:issue => :project}, | |
42 | :conditions => Issue.visible_condition(args.shift || User.current, *args) |
|
42 | :conditions => Issue.visible_condition(args.shift || User.current, *args) | |
43 | }} |
|
43 | }} | |
44 |
|
44 | |||
45 | def save(*args) |
|
45 | def save(*args) | |
46 | # Do not save an empty journal |
|
46 | # Do not save an empty journal | |
47 | (details.empty? && notes.blank?) ? false : super |
|
47 | (details.empty? && notes.blank?) ? false : super | |
48 | end |
|
48 | end | |
49 |
|
49 | |||
50 | # Returns the new status if the journal contains a status change, otherwise nil |
|
50 | # Returns the new status if the journal contains a status change, otherwise nil | |
51 | def new_status |
|
51 | def new_status | |
52 | c = details.detect {|detail| detail.prop_key == 'status_id'} |
|
52 | c = details.detect {|detail| detail.prop_key == 'status_id'} | |
53 | (c && c.value) ? IssueStatus.find_by_id(c.value.to_i) : nil |
|
53 | (c && c.value) ? IssueStatus.find_by_id(c.value.to_i) : nil | |
54 | end |
|
54 | end | |
55 |
|
55 | |||
56 | def new_value_for(prop) |
|
56 | def new_value_for(prop) | |
57 | c = details.detect {|detail| detail.prop_key == prop} |
|
57 | c = details.detect {|detail| detail.prop_key == prop} | |
58 | c ? c.value : nil |
|
58 | c ? c.value : nil | |
59 | end |
|
59 | end | |
60 |
|
60 | |||
61 | def editable_by?(usr) |
|
61 | def editable_by?(usr) | |
62 | usr && usr.logged? && (usr.allowed_to?(:edit_issue_notes, project) || (self.user == usr && usr.allowed_to?(:edit_own_issue_notes, project))) |
|
62 | usr && usr.logged? && (usr.allowed_to?(:edit_issue_notes, project) || (self.user == usr && usr.allowed_to?(:edit_own_issue_notes, project))) | |
63 | end |
|
63 | end | |
64 |
|
64 | |||
65 | def project |
|
65 | def project | |
66 | journalized.respond_to?(:project) ? journalized.project : nil |
|
66 | journalized.respond_to?(:project) ? journalized.project : nil | |
67 | end |
|
67 | end | |
68 |
|
68 | |||
69 | def attachments |
|
69 | def attachments | |
70 | journalized.respond_to?(:attachments) ? journalized.attachments : nil |
|
70 | journalized.respond_to?(:attachments) ? journalized.attachments : nil | |
71 | end |
|
71 | end | |
@@ -77,11 +77,11 class Journal < ActiveRecord::Base | |||||
77 | s << ' has-details' unless details.blank? |
|
77 | s << ' has-details' unless details.blank? | |
78 | s |
|
78 | s | |
79 | end |
|
79 | end | |
80 |
|
80 | |||
81 | def notify? |
|
81 | def notify? | |
82 | @notify != false |
|
82 | @notify != false | |
83 | end |
|
83 | end | |
84 |
|
84 | |||
85 | def notify=(arg) |
|
85 | def notify=(arg) | |
86 | @notify = arg |
|
86 | @notify = arg | |
87 | end |
|
87 | end |
General Comments 0
You need to be logged in to leave comments.
Login now