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
path: root/app
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2014-08-12 16:16:25 +0400
committerRobert Schilling <rschilling@student.tugraz.at>2014-08-13 14:28:19 +0400
commit9284038dbef5153dac40eda14f1685a72efe1d1a (patch)
tree1b195e94518f115316da6f98195943dc8d22c2c0 /app
parent53ead2e35c9195ae1f68bf5d7154e341636caf1b (diff)
Add, delete labels via API
Diffstat (limited to 'app')
-rw-r--r--app/models/label.rb9
-rw-r--r--app/models/project.rb4
2 files changed, 9 insertions, 4 deletions
diff --git a/app/models/label.rb b/app/models/label.rb
index ce982579675..b8dc11a5245 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -7,13 +7,14 @@ class Label < ActiveRecord::Base
validates :project, presence: true
# Dont allow '?', '&', and ',' for label titles
- validates :title, presence: true, format: { with: /\A[^&\?,&]*\z/ }
+ validates :title,
+ presence: true,
+ format: { with: /\A[^&\?,&]*\z/ },
+ uniqueness: true
scope :order_by_name, -> { reorder("labels.title ASC") }
- def name
- title
- end
+ alias_attribute :name, :title
def open_issues_count
issues.opened.count
diff --git a/app/models/project.rb b/app/models/project.rb
index a24eae7d26b..7f6aa6d4249 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -577,4 +577,8 @@ class Project < ActiveRecord::Base
def forks_count
ForkedProjectLink.where(forked_from_project_id: self.id).count
end
+
+ def find_label(name)
+ labels.find_by(name: name)
+ end
end