debian-mirror-gitlab/app/services/boards/create_service.rb

29 lines
567 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2016-09-13 17:45:13 +05:30
module Boards
2018-03-17 18:26:18 +05:30
class CreateService < Boards::BaseService
2016-09-13 17:45:13 +05:30
def execute
2017-09-10 17:25:29 +05:30
create_board! if can_create_board?
2016-09-13 17:45:13 +05:30
end
private
2017-09-10 17:25:29 +05:30
def can_create_board?
2019-09-30 21:07:59 +05:30
parent.boards.empty? || parent.multiple_issue_boards_available?
2017-09-10 17:25:29 +05:30
end
2016-09-13 17:45:13 +05:30
def create_board!
2018-03-17 18:26:18 +05:30
board = parent.boards.create(params)
2017-09-10 17:25:29 +05:30
if board.persisted?
board.lists.create(list_type: :backlog)
board.lists.create(list_type: :closed)
end
2016-11-03 12:29:30 +05:30
board
2016-09-13 17:45:13 +05:30
end
end
end
2019-12-04 20:38:33 +05:30
Boards::CreateService.prepend_if_ee('EE::Boards::CreateService')