Class: Journal

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/journal.rb

Overview

Redmine - project management software Copyright © 2006-2011 Jean-Philippe Lang

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#indiceObject

Returns the value of attribute indice.



26
27
28
# File 'app/models/journal.rb', line 26

def indice
  @indice
end

Instance Method Details

#attachmentsObject



70
71
72
# File 'app/models/journal.rb', line 70

def attachments
  journalized.respond_to?(:attachments) ? journalized.attachments : nil
end

#css_classesObject

Returns a string of css classes



75
76
77
78
79
80
# File 'app/models/journal.rb', line 75

def css_classes
  s = 'journal'
  s << ' has-notes' unless notes.blank?
  s << ' has-details' unless details.blank?
  s
end

#editable_by?(usr) ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
# File 'app/models/journal.rb', line 62

def editable_by?(usr)
  usr && usr.logged? && (usr.allowed_to?(:edit_issue_notes, project) || (self.user == usr && usr.allowed_to?(:edit_own_issue_notes, project)))
end

#new_statusObject

Returns the new status if the journal contains a status change, otherwise nil



52
53
54
55
# File 'app/models/journal.rb', line 52

def new_status
  c = details.detect {|detail| detail.prop_key == 'status_id'}
  (c && c.value) ? IssueStatus.find_by_id(c.value.to_i) : nil
end

#new_value_for(prop) ⇒ Object



57
58
59
60
# File 'app/models/journal.rb', line 57

def new_value_for(prop)
  c = details.detect {|detail| detail.prop_key == prop}
  c ? c.value : nil
end

#projectObject



66
67
68
# File 'app/models/journal.rb', line 66

def project
  journalized.respond_to?(:project) ? journalized.project : nil
end

#save(*args) ⇒ Object



46
47
48
49
# File 'app/models/journal.rb', line 46

def save(*args)
  # Do not save an empty journal
  (details.empty? && notes.blank?) ? false : super
end