2011-11-24 21:46:19 +00:00
|
|
|
module Modules
|
|
|
|
module Models
|
|
|
|
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"
|
2011-11-29 14:36:51 +00:00
|
|
|
pl.description = "#{self.uname}_personal"
|
2011-11-24 21:46:19 +00:00
|
|
|
pl.platform_type = 'personal'
|
|
|
|
pl.distrib_type = APP_CONFIG['distr_types'].first
|
|
|
|
pl.visibility = 'hidden'
|
|
|
|
pl.save!
|
|
|
|
|
|
|
|
rep = pl.repositories.build
|
|
|
|
rep.owner = pl.owner
|
|
|
|
rep.name = 'main'
|
2011-11-29 14:36:51 +00:00
|
|
|
rep.description = 'main'
|
2011-11-24 21:46:19 +00:00
|
|
|
rep.save!
|
|
|
|
end
|
|
|
|
|
|
|
|
def personal_platform
|
|
|
|
platforms.personal.first
|
|
|
|
end
|
|
|
|
|
|
|
|
def personal_repository
|
|
|
|
personal_platform.repositories.first
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
module ClassMethods
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|