Changed platform clone
This commit is contained in:
parent
16b6e2ddfe
commit
33e8e49007
|
@ -84,7 +84,7 @@ class PlatformsController < ApplicationController
|
||||||
def clone
|
def clone
|
||||||
can_perform? @platform if @platform
|
can_perform? @platform if @platform
|
||||||
if request.post?
|
if request.post?
|
||||||
cloned = @platform.clone(params[:platform]['name'], params[:platform]['unixname'])
|
cloned = @platform.clone(params[:platform]['name'], params[:platform]['unixname'], current_user)
|
||||||
if cloned
|
if cloned
|
||||||
flash[:notice] = 'Клонирование успешно'
|
flash[:notice] = 'Клонирование успешно'
|
||||||
redirect_to cloned
|
redirect_to cloned
|
||||||
|
|
|
@ -63,13 +63,14 @@ class Platform < ActiveRecord::Base
|
||||||
platform_type == 'personal'
|
platform_type == 'personal'
|
||||||
end
|
end
|
||||||
|
|
||||||
def clone(new_name, new_unixname)
|
def clone(new_name, new_unixname, cowner)
|
||||||
# TODO * make it Delayed Job *
|
# TODO * make it Delayed Job *
|
||||||
p = Platform.new
|
p = Platform.new
|
||||||
p.name = new_name
|
p.name = new_name
|
||||||
p.unixname = new_unixname
|
p.unixname = new_unixname
|
||||||
p.parent = self
|
p.parent = self
|
||||||
p.repositories = repositories.map(&:clone)
|
p.owner = cowner
|
||||||
|
p.repositories = repositories.map{|r| r.clone(cowner)}
|
||||||
result = p.save
|
result = p.save
|
||||||
p.products = products.map do |pr|
|
p.products = products.map do |pr|
|
||||||
pr_cloned = Product.new
|
pr_cloned = Product.new
|
||||||
|
|
|
@ -32,11 +32,12 @@ class Repository < ActiveRecord::Base
|
||||||
# build_path(unixname)
|
# build_path(unixname)
|
||||||
# end
|
# end
|
||||||
|
|
||||||
def clone
|
def clone(cowner)
|
||||||
r = Repository.new
|
r = Repository.new
|
||||||
r.name = name
|
r.name = name
|
||||||
r.unixname = unixname
|
r.unixname = unixname
|
||||||
r.projects = projects
|
r.projects = projects
|
||||||
|
r.owner = cowner
|
||||||
r.save
|
r.save
|
||||||
return r
|
return r
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue