gitlab-org--gitlab-foss/app/controllers/import/base_controller.rb

38 lines
1.0 KiB
Ruby
Raw Normal View History

2015-02-05 18:31:36 +00:00
class Import::BaseController < ApplicationController
private
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 10:19:44 +00:00
.includes(:import_state)
.where(import_type: import_type)
.to_json(only: [:id], methods: [:import_status])
end
def find_or_create_namespace(names, owner)
names = params[:target_namespace].presence || names
return current_user.namespace if names == owner
group = Groups::NestedCreateService.new(current_user, group_path: names).execute
group.errors.any? ? current_user.namespace : group
rescue => e
Gitlab::AppLogger.error(e)
current_user.namespace
2015-02-05 18:31:36 +00:00
end
def project_save_error(project)
# Projects::CreateService will set base message if unable to save
if project.errors[:base].present?
project.errors[:base].last
else
project.errors.full_messages.join(', ')
end
end
2015-02-05 18:31:36 +00:00
end