Class: WorkItems::ImportCsvService

Inherits:
ImportCsv::BaseService show all
Extended by:
Gitlab::Utils::Override
Defined in:
app/services/work_items/import_csv_service.rb

Constant Summary collapse

FeatureNotAvailableError =
StandardError.new(
  'This feature is currently behind a feature flag and it is not available.'
)
NotAuthorizedError =
StandardError.new('You do not have permission to import work items in this project.')

Constants inherited from ImportCsv::BaseService

ImportCsv::BaseService::PreprocessError

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::Utils::Override

extended, extensions, included, method_added, override, prepended, queue_verification, verify!

Constructor Details

#initialize(*args) ⇒ ImportCsvService

Returns a new instance of ImportCsvService.



13
14
15
16
17
18
19
20
21
# File 'app/services/work_items/import_csv_service.rb', line 13

def initialize(*args)
  super

  @type_errors = {
    blank: [],
    missing: {},
    disallowed: {}
  }
end

Class Method Details

.required_headersObject



23
24
25
# File 'app/services/work_items/import_csv_service.rb', line 23

def self.required_headers
  %w[title type].freeze
end

Instance Method Details

#email_results_to_userObject



34
35
36
# File 'app/services/work_items/import_csv_service.rb', line 34

def email_results_to_user
  Notify.import_work_items_csv_email(user.id, project.id, results).deliver_later
end

#executeObject



27
28
29
30
31
32
# File 'app/services/work_items/import_csv_service.rb', line 27

def execute
  raise FeatureNotAvailableError if ::Feature.disabled?(:import_export_work_items_csv, project)
  raise NotAuthorizedError unless Ability.allowed?(user, :import_work_items, project)

  super
end