Models Refactoring: Move methods to roles
This commit is contained in:
parent
98b8416647
commit
0a70aca3b1
20 changed files with 531 additions and 524 deletions
|
@ -1,6 +1,7 @@
|
|||
require 'digest/md5'
|
||||
|
||||
class Key < ActiveRecord::Base
|
||||
include SshKey
|
||||
belongs_to :user
|
||||
belongs_to :project
|
||||
|
||||
|
@ -37,28 +38,11 @@ class Key < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def update_repository
|
||||
Gitlab::GitHost.system.new.configure do |c|
|
||||
c.update_keys(identifier, key)
|
||||
c.update_projects(projects)
|
||||
end
|
||||
end
|
||||
|
||||
def repository_delete_key
|
||||
Gitlab::GitHost.system.new.configure do |c|
|
||||
#delete key file is there is no identically deploy keys
|
||||
if !is_deploy_key || Key.where(:identifier => identifier).count() == 0
|
||||
c.delete_key(identifier)
|
||||
end
|
||||
c.update_projects(projects)
|
||||
end
|
||||
end
|
||||
|
||||
def is_deploy_key
|
||||
true if project_id
|
||||
end
|
||||
|
||||
#projects that has this key
|
||||
# projects that has this key
|
||||
def projects
|
||||
if is_deploy_key
|
||||
[project]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue