diff options
| author | Nikita Verkhovin <vernik91@gmail.com> | 2015-02-07 17:14:55 +0600 |
|---|---|---|
| committer | Nikita Verkhovin <vernik91@gmail.com> | 2015-02-08 22:35:41 +0600 |
| commit | 8681cb3137511e51e19f76aef9839be28f8fcd6a (patch) | |
| tree | f2d5a929763d77b12c4248cc1bb50a01766bcbfe /app/models/note.rb | |
| parent | 0a34f2dcb562098c481140246f7ac22683b38d76 (diff) | |
| download | gitlab-ce-8681cb3137511e51e19f76aef9839be28f8fcd6a.tar.gz | |
Add labels notes
Diffstat (limited to 'app/models/note.rb')
| -rw-r--r-- | app/models/note.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index 39fe421fd7a..ccd9783e7d4 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -121,6 +121,36 @@ class Note < ActiveRecord::Base }) end + def create_labels_change_note(noteable, project, author, added_labels, removed_labels) + labels_count = added_labels.count + removed_labels.count + added_labels = added_labels.map{ |label| "~#{label.id}" }.join(' ') + removed_labels = removed_labels.map{ |label| "~#{label.id}" }.join(' ') + message = '' + + if added_labels.present? + message << "added #{added_labels}" + end + + if added_labels.present? && removed_labels.present? + message << ' and ' + end + + if removed_labels.present? + message << "removed #{removed_labels}" + end + + message << ' ' << 'label'.pluralize(labels_count) + body = "_#{message.capitalize}_" + + create( + noteable: noteable, + project: project, + author: author, + note: body, + system: true + ) + end + def create_new_commits_note(noteable, project, author, commits) commits_text = ActionController::Base.helpers.pluralize(commits.size, 'new commit') body = "Added #{commits_text}:\n\n" |
