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
|
|
|
|
board.lists.create(list_type: :done)
|
|
|
|
|
|
|
|
board
|
2016-07-28 00:36:38 -04:00
|
|
|
end
|
2016-07-27 16:41:19 -04:00
|
|
|
end
|
|
|
|
end
|