2016-09-13 17:45:13 +05:30
|
|
|
module Boards
|
2016-11-03 12:29:30 +05:30
|
|
|
class CreateService < BaseService
|
2016-09-13 17:45:13 +05:30
|
|
|
def execute
|
2016-11-03 12:29:30 +05:30
|
|
|
if project.boards.empty?
|
|
|
|
create_board!
|
|
|
|
else
|
|
|
|
project.boards.first
|
|
|
|
end
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def create_board!
|
2016-11-03 12:29:30 +05:30
|
|
|
board = project.boards.create
|
|
|
|
board.lists.create(list_type: :backlog)
|
|
|
|
board.lists.create(list_type: :done)
|
|
|
|
|
|
|
|
board
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|