2012-01-30 20:39:34 +00:00
|
|
|
# -*- encoding : utf-8 -*-
|
2011-11-24 21:46:19 +00:00
|
|
|
module Modules
|
|
|
|
module Models
|
|
|
|
module PersonalRepository
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
2012-12-27 18:27:50 +00:00
|
|
|
after_create :create_personal_repository, :unless => :system?
|
2011-11-24 21:46:19 +00:00
|
|
|
end
|
|
|
|
|
2012-03-29 21:34:22 +01:00
|
|
|
def create_personal_repository
|
2012-07-25 22:49:55 +01:00
|
|
|
begin
|
|
|
|
pl = own_platforms.build
|
|
|
|
pl.owner = self
|
|
|
|
pl.name = "#{self.uname}_personal"
|
|
|
|
pl.description = "#{self.uname}_personal"
|
|
|
|
pl.platform_type = 'personal'
|
|
|
|
pl.distrib_type = APP_CONFIG['distr_types'].first
|
|
|
|
pl.visibility = 'open'
|
|
|
|
pl.save!
|
2011-11-24 21:46:19 +00:00
|
|
|
|
2012-07-25 22:49:55 +01:00
|
|
|
rep = pl.repositories.build
|
|
|
|
rep.name = 'main'
|
|
|
|
rep.description = 'main'
|
|
|
|
rep.save!
|
|
|
|
rescue Exception => e
|
|
|
|
pl.now_destroy rescue false
|
|
|
|
raise e
|
|
|
|
end
|
|
|
|
return true
|
2012-03-29 21:34:22 +01:00
|
|
|
end
|
2011-11-24 21:46:19 +00:00
|
|
|
|
2012-03-29 21:34:22 +01:00
|
|
|
def personal_platform
|
2012-04-03 10:39:29 +01:00
|
|
|
own_platforms.personal.first
|
2012-03-29 21:34:22 +01:00
|
|
|
end
|
2011-11-24 21:46:19 +00:00
|
|
|
|
2012-03-29 21:34:22 +01:00
|
|
|
def personal_repository
|
|
|
|
personal_platform.repositories.first
|
2011-11-24 21:46:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
module ClassMethods
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|