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
|
2017-08-17 22:00:37 +05:30
|
|
|
board.lists.create(list_type: :closed)
|
2016-11-03 12:29:30 +05:30
|
|
|
|
|
|
|
board
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|