diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/finders/projects_finder.rb | 3 | ||||
| -rw-r--r-- | app/models/project.rb | 1 | ||||
| -rw-r--r-- | app/models/project_custom_attribute.rb | 6 |
3 files changed, 10 insertions, 0 deletions
diff --git a/app/finders/projects_finder.rb b/app/finders/projects_finder.rb index eac6095d8dc..005612ededc 100644 --- a/app/finders/projects_finder.rb +++ b/app/finders/projects_finder.rb @@ -18,6 +18,8 @@ # non_archived: boolean # class ProjectsFinder < UnionFinder + include CustomAttributesFilter + attr_accessor :params attr_reader :current_user, :project_ids_relation @@ -44,6 +46,7 @@ class ProjectsFinder < UnionFinder collection = by_tags(collection) collection = by_search(collection) collection = by_archived(collection) + collection = by_custom_attributes(collection) sort(collection) end diff --git a/app/models/project.rb b/app/models/project.rb index b04aec550b1..38ac7b20b05 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -213,6 +213,7 @@ class Project < ActiveRecord::Base has_many :active_runners, -> { active }, through: :runner_projects, source: :runner, class_name: 'Ci::Runner' has_one :auto_devops, class_name: 'ProjectAutoDevops' + has_many :custom_attributes, class_name: 'ProjectCustomAttribute' accepts_nested_attributes_for :variables, allow_destroy: true accepts_nested_attributes_for :project_feature, update_only: true diff --git a/app/models/project_custom_attribute.rb b/app/models/project_custom_attribute.rb new file mode 100644 index 00000000000..3f1a7b86a82 --- /dev/null +++ b/app/models/project_custom_attribute.rb @@ -0,0 +1,6 @@ +class ProjectCustomAttribute < ActiveRecord::Base + belongs_to :project + + validates :project, :key, :value, presence: true + validates :key, uniqueness: { scope: [:project_id] } +end |
