2014-03-11 08:58:36 +00:00
|
|
|
module PersonalRepository
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
after_create :create_personal_repository, unless: :system?
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_personal_repository
|
|
|
|
begin
|
2014-09-30 21:05:53 +01:00
|
|
|
pl = own_platforms.build
|
|
|
|
pl.owner = self
|
|
|
|
pl.name = "#{self.uname}_personal"
|
|
|
|
pl.description = "#{self.uname}_personal"
|
|
|
|
pl.platform_type = Platform::TYPE_PERSONAL
|
|
|
|
pl.distrib_type = APP_CONFIG['distr_types'].first
|
|
|
|
pl.visibility = Platform::VISIBILITY_OPEN
|
2014-03-11 08:58:36 +00:00
|
|
|
pl.save!
|
|
|
|
|
2014-09-30 21:05:53 +01:00
|
|
|
rep = pl.repositories.build
|
|
|
|
rep.name = 'main'
|
2014-03-11 08:58:36 +00:00
|
|
|
rep.description = 'main'
|
|
|
|
rep.save!
|
|
|
|
rescue Exception => e
|
|
|
|
pl.now_destroy rescue false
|
|
|
|
raise e
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
def personal_platform
|
|
|
|
own_platforms.personal.first
|
|
|
|
end
|
|
|
|
|
|
|
|
def personal_repository
|
|
|
|
personal_platform.repositories.first
|
|
|
|
end
|
|
|
|
end
|