From 1ea0dd0ffc37232d27f4fa1350af6ebb3b5439f2 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 25 Oct 2012 11:59:41 +0300 Subject: App docs --- doc/app/Note.html | 777 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 777 insertions(+) create mode 100644 doc/app/Note.html (limited to 'doc/app/Note.html') diff --git a/doc/app/Note.html b/doc/app/Note.html new file mode 100644 index 00000000000..24a474b0296 --- /dev/null +++ b/doc/app/Note.html @@ -0,0 +1,777 @@ + + + + + + +class Note - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Note

+ +
+ +
+ + + + +
+ + + + + + + + +
+

Attributes

+ + +
+
+ notify[RW] +
+ +
+ + + +
+
+ +
+
+ notify_author[RW] +
+ +
+ + + +
+
+ +
+ + + + +
+

Public Class Methods

+ + +
+ +
+ create_status_change_note(noteable, author, status) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/note.rb, line 34
+def self.create_status_change_note(noteable, author, status)
+  create({
+    noteable: noteable,
+    project: noteable.project,
+    author: author,
+    note: "_Status changed to #{status}_"
+  }, without_protection: true)
+end
+
+ +
+ + + + +
+ + +
+ +
+

Public Instance Methods

+ + +
+ +
+ commit_author() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/note.rb, line 90
+def commit_author
+  @commit_author ||=
+    project.users.find_by_email(noteable.author_email) ||
+    project.users.find_by_name(noteable.author_name)
+rescue
+  nil
+end
+
+ +
+ + + + +
+ + +
+ +
+ downvote?() + click to toggle source +
+ + +
+ +

Returns true if this is a downvote note, otherwise false is returned

+ + + +
+
# File app/models/note.rb, line 106
+def downvote?
+  note.start_with?('-1') || note.start_with?(':-1:')
+end
+
+ +
+ + + + +
+ + +
+ +
+ for_commit?() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/note.rb, line 82
+def for_commit?
+  noteable_type == "Commit"
+end
+
+ +
+ + + + +
+ + +
+ +
+ for_diff_line?() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/note.rb, line 86
+def for_diff_line?
+  line_code.present?
+end
+
+ +
+ + + + +
+ + +
+ +
+ noteable() + click to toggle source +
+ + +
+ +

override to return commits, which are not active record

+ + + +
+
# File app/models/note.rb, line 52
+def noteable
+  if for_commit?
+    project.commit(noteable_id)
+  else
+    super
+  end
+# Temp fix to prevent app crash
+# if note commit id doesnt exist
+rescue
+  nil
+end
+
+ +
+ + + + +
+ + +
+ +
+ notify_only_author?(user) + click to toggle source +
+ + +
+ +

Check if we can notify commit author with email about our comment

+ +

If commit author email exist in project and commit author is not passed +user we can send email to him

+ +

params:

+ +
user - current user
+ +

return:

+ +
Boolean
+ + + +
+
# File app/models/note.rb, line 77
+def notify_only_author?(user)
+  for_commit? && commit_author &&
+    commit_author.email != user.email
+end
+
+ +
+ + + + +
+ + +
+ +
+ upvote?() + click to toggle source +
+ + +
+ +

Returns true if this is an upvote note, otherwise false is returned

+ + + +
+
# File app/models/note.rb, line 100
+def upvote?
+  note.start_with?('+1') || note.start_with?(':+1:')
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + -- cgit v1.2.1