2016-07-27 20:41:19 +00:00
|
|
|
module Boards
|
2016-10-07 19:46:32 +00:00
|
|
|
class CreateService < BaseService
|
2016-07-27 20:41:19 +00:00
|
|
|
def execute
|
2016-10-06 19:20:21 +00:00
|
|
|
if project.boards.empty?
|
|
|
|
create_board!
|
|
|
|
else
|
|
|
|
project.boards.first
|
|
|
|
end
|
2016-07-27 20:41:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2016-07-28 04:36:38 +00:00
|
|
|
def create_board!
|
2016-10-06 19:20:21 +00:00
|
|
|
board = project.boards.create
|
|
|
|
board.lists.create(list_type: :done)
|
|
|
|
|
|
|
|
board
|
2016-07-28 04:36:38 +00:00
|
|
|
end
|
2016-07-27 20:41:19 +00:00
|
|
|
end
|
|
|
|
end
|