diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-05-06 16:10:55 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-05-06 16:10:55 +0400 |
commit | 1882baa1aaa1c195cce55678b2b8a12e1b59db34 (patch) | |
tree | 9df49c181609531a474046aca2b205bba45e2c05 /app/models | |
parent | 8e4625af614b58df97d60031c2b5c72f37f1a692 (diff) |
Feature: Deploy keys between projects
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/deploy_key.rb | 2 | ||||
-rw-r--r-- | app/models/key.rb | 4 | ||||
-rw-r--r-- | app/models/project.rb | 4 | ||||
-rw-r--r-- | app/models/user.rb | 2 |
4 files changed, 6 insertions, 6 deletions
diff --git a/app/models/deploy_key.rb b/app/models/deploy_key.rb index 6d9ec9a47e4..548ef4f9a27 100644 --- a/app/models/deploy_key.rb +++ b/app/models/deploy_key.rb @@ -1,4 +1,6 @@ class DeployKey < Key has_many :deploy_keys_projects, dependent: :destroy has_many :projects, through: :deploy_keys_projects + + scope :in_projects, ->(projects) { joins(:deploy_keys_projects).where('deploy_keys_projects.project_id in (?)', projects) } end diff --git a/app/models/key.rb b/app/models/key.rb index 31fb522f3ff..a72357a6d01 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -46,10 +46,6 @@ class Key < ActiveRecord::Base errors.add(:key, "can't be fingerprinted") if $?.exitstatus != 0 end - def is_deploy_key - project.present? - end - # projects that has this key def projects user.authorized_projects diff --git a/app/models/project.rb b/app/models/project.rb index 291316f3088..203ccb8e290 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -55,7 +55,6 @@ class Project < ActiveRecord::Base has_many :users_projects, dependent: :destroy has_many :notes, dependent: :destroy has_many :snippets, dependent: :destroy - has_many :deploy_keys, dependent: :destroy, class_name: "Key", foreign_key: "project_id" has_many :hooks, dependent: :destroy, class_name: "ProjectHook" has_many :protected_branches, dependent: :destroy has_many :user_team_project_relationships, dependent: :destroy @@ -65,6 +64,9 @@ class Project < ActiveRecord::Base has_many :user_team_user_relationships, through: :user_teams has_many :user_teams_members, through: :user_team_user_relationships + has_many :deploy_keys_projects, dependent: :destroy + has_many :deploy_keys, through: :deploy_keys_projects + delegate :name, to: :owner, allow_nil: true, prefix: true # Validations diff --git a/app/models/user.rb b/app/models/user.rb index fb2e62279a5..1d90ec3b37a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -89,7 +89,7 @@ class User < ActiveRecord::Base has_many :personal_projects, through: :namespace, source: :projects has_many :projects, through: :users_projects - has_many :own_projects, foreign_key: :creator_id + has_many :own_projects, foreign_key: :creator_id, class_name: 'Project' has_many :owned_projects, through: :namespaces, source: :projects # |