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

27 lines
458 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?
2018-12-05 23:21:45 +05:30
parent.boards.empty?
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