summaryrefslogtreecommitdiff
path: root/app/models/label.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-30 15:15:39 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-30 15:15:39 +0300
commit593df8e69a81a3ab0a4755db74dc282c00e02ef5 (patch)
treecdbec00afa3289a9fe4065a8c7ba56e5c82a365f /app/models/label.rb
parentcc331684593143cba773b0160222865eeb86b134 (diff)
downloadgitlab-ce-593df8e69a81a3ab0a4755db74dc282c00e02ef5.tar.gz
Improve labels
* allow developers to manage labels * add ability to remove label Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models/label.rb')
-rw-r--r--app/models/label.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/models/label.rb b/app/models/label.rb
index ea1daa6a204..5d6e5e91a0c 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -1,6 +1,7 @@
class Label < ActiveRecord::Base
belongs_to :project
has_many :label_links, dependent: :destroy
+ has_many :issues, through: :label_links, source: :target, source_type: 'Issue'
validates :color, format: { with: /\A\#[0-9A-Fa-f]{6}+\Z/ }, allow_blank: true
validates :project, presence: true
@@ -11,4 +12,8 @@ class Label < ActiveRecord::Base
def name
title
end
+
+ def open_issues_count
+ issues.opened.count
+ end
end