2016-07-27 16:41:19 -04:00
|
|
|
module Boards
|
2016-10-07 15:46:32 -04:00
|
|
|
class CreateService < BaseService
|
2016-07-27 16:41:19 -04:00
|
|
|
def execute
|
2016-10-06 15:20:21 -04:00
|
|
|
if project.boards.empty?
|
|
|
|
create_board!
|
|
|
|
else
|
|
|
|
project.boards.first
|
|
|
|
end
|
2016-07-27 16:41:19 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2016-07-28 00:36:38 -04:00
|
|
|
def create_board!
|
2016-10-06 15:20:21 -04:00
|
|
|
board = project.boards.create
|
2017-05-31 07:34:54 -04:00
|
|
|
board.lists.create(list_type: :backlog)
|
2017-03-24 08:40:35 -04:00
|
|
|
board.lists.create(list_type: :closed)
|
2016-10-06 15:20:21 -04:00
|
|
|
|
|
|
|
board
|
2016-07-28 00:36:38 -04:00
|
|
|
end
|
2016-07-27 16:41:19 -04:00
|
|
|
end
|
|
|
|
end
|