2011-10-27 14:04:03 +01:00
|
|
|
module PersonalRepository
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
after_create :create_personal_repository
|
|
|
|
end
|
|
|
|
|
|
|
|
module InstanceMethods
|
|
|
|
def create_personal_repository
|
|
|
|
pl = platforms.build
|
|
|
|
pl.owner = self
|
|
|
|
pl.name = "#{self.uname}_personal"
|
|
|
|
pl.unixname = "#{self.uname}_personal"
|
|
|
|
pl.platform_type = 'personal'
|
2011-10-31 00:33:47 +00:00
|
|
|
pl.distrib_type = APP_CONFIG['distr_types'].first
|
2011-10-31 01:07:27 +00:00
|
|
|
pl.visibility = 'hidden'
|
2011-10-30 20:03:05 +00:00
|
|
|
pl.save!
|
2011-10-27 14:04:03 +01:00
|
|
|
|
|
|
|
rep = pl.repositories.build
|
|
|
|
rep.owner = pl.owner
|
|
|
|
rep.name = 'main'
|
|
|
|
rep.unixname = 'main'
|
2011-10-30 20:03:05 +00:00
|
|
|
rep.save!
|
2011-10-27 14:04:03 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def personal_platform
|
|
|
|
platforms.personal.first
|
|
|
|
end
|
|
|
|
|
|
|
|
def personal_repository
|
|
|
|
personal_platform.repositories.first
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|