2015-02-05 13:31:36 -05:00
|
|
|
class Import::BaseController < ApplicationController
|
|
|
|
private
|
|
|
|
|
2018-05-02 09:35:04 -04:00
|
|
|
def find_already_added_projects(import_type)
|
|
|
|
current_user.created_projects.where(import_type: import_type).includes(:import_state)
|
|
|
|
end
|
|
|
|
|
|
|
|
def find_jobs(import_type)
|
|
|
|
current_user.created_projects
|
2018-05-09 06:19:44 -04:00
|
|
|
.includes(:import_state)
|
|
|
|
.where(import_type: import_type)
|
|
|
|
.to_json(only: [:id], methods: [:import_status])
|
2018-05-02 09:35:04 -04:00
|
|
|
end
|
|
|
|
|
2017-04-05 06:09:31 -04:00
|
|
|
def find_or_create_namespace(names, owner)
|
|
|
|
names = params[:target_namespace].presence || names
|
|
|
|
|
2018-01-26 10:39:10 -05:00
|
|
|
return current_user.namespace if names == owner
|
|
|
|
|
|
|
|
group = Groups::NestedCreateService.new(current_user, group_path: names).execute
|
2017-04-05 06:09:31 -04:00
|
|
|
|
2018-01-26 10:39:10 -05:00
|
|
|
group.errors.any? ? current_user.namespace : group
|
|
|
|
rescue => e
|
|
|
|
Gitlab::AppLogger.error(e)
|
2017-04-05 06:09:31 -04:00
|
|
|
|
2018-01-26 10:39:10 -05:00
|
|
|
current_user.namespace
|
2015-02-05 13:31:36 -05:00
|
|
|
end
|
|
|
|
end
|