Read about our upcoming Code of Conduct on this issue

base_controller.rb 788 Bytes
Newer Older
Valery Sizov's avatar
Valery Sizov committed
1
2
3
class Import::BaseController < ApplicationController
  private

4
5
6
7
8
9
10
11
12
13
14
  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
        .includes(:import_state)
        .where(import_type: import_type)
        .to_json(only: [:id], methods: [:import_status])
  end

15
16
17
  def find_or_create_namespace(names, owner)
    names = params[:target_namespace].presence || names

18
19
20
    return current_user.namespace if names == owner

    group = Groups::NestedCreateService.new(current_user, group_path: names).execute
21

22
23
24
    group.errors.any? ? current_user.namespace : group
  rescue => e
    Gitlab::AppLogger.error(e)
25

26
    current_user.namespace
Valery Sizov's avatar
Valery Sizov committed
27
28
  end
end