2015-04-26 12:48:37 +05:30
|
|
|
class Import::BaseController < ApplicationController
|
|
|
|
private
|
|
|
|
|
2016-09-29 09:46:39 +05:30
|
|
|
def find_or_create_namespace(name, owner)
|
|
|
|
return current_user.namespace if name == owner
|
|
|
|
return current_user.namespace unless current_user.can_create_group?
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
begin
|
2016-09-29 09:46:39 +05:30
|
|
|
name = params[:target_namespace].presence || name
|
|
|
|
namespace = Group.create!(name: name, path: name, owner: current_user)
|
2015-04-26 12:48:37 +05:30
|
|
|
namespace.add_owner(current_user)
|
2016-09-29 09:46:39 +05:30
|
|
|
namespace
|
2015-04-26 12:48:37 +05:30
|
|
|
rescue ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid
|
2016-09-29 09:46:39 +05:30
|
|
|
Namespace.find_by_path_or_name(name)
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|