Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-09-03 15:50:23 +0300
committerValery Sizov <vsv2711@gmail.com>2015-09-03 15:50:23 +0300
commit57d001309013c4c27e593778ec68b523e7d73b81 (patch)
tree627a5c54481f52b3d49c655fcd675c9b568ab849 /app/models/label.rb
parent28219ea9211d6caafa34620859ff0e879ec54c12 (diff)
CRUD for admin labels
Diffstat (limited to 'app/models/label.rb')
-rw-r--r--app/models/label.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/label.rb b/app/models/label.rb
index 230631b5180..4a22bd53400 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -24,7 +24,7 @@ class Label < ActiveRecord::Base
validates :color,
format: { with: /\A#[0-9A-Fa-f]{6}\Z/ },
allow_blank: false
- validates :project, presence: true
+ validates :project, presence: true, unless: Proc.new { |service| service.template? }
# Don't allow '?', '&', and ',' for label titles
validates :title,
@@ -34,6 +34,8 @@ class Label < ActiveRecord::Base
default_scope { order(title: :asc) }
+ scope :templates, -> { where(template: true) }
+
alias_attribute :name, :title
def self.reference_prefix
@@ -78,4 +80,8 @@ class Label < ActiveRecord::Base
def open_issues_count
issues.opened.count
end
+
+ def template?
+ template
+ end
end