Ejemplo n.º 1
0
def view(board_id, sprint_id='current'):
	'''
	Get the data for a board in a Board object
		arg: board_id - the id of the board to get
		arg: sprint_id - the id of a sprint belonging to the board for which to get stories.
			Passing in 'all' gets stories from all sprints, passing in 'current' gets
			all stories in the current sprint, and passing in 'backlog' gets all stories in the 
			backlog.
		return: the data in a Board object
	'''

	board_id_uuid = UUID(board_id)
	sprint = None
	if sprint_id == 'current':
		sprint = Sprints.get_current_sprint(board_id)
		if sprint is not None:
			sprint_id = sprint.id
		if sprint is None:
			now = datetime.datetime.now()#.strftime('%Y-%m-%d')
			later = now + relativedelta(weeks=2)#.strftime('%Y-%m-%d')
			sprint = Sprints.create(now, later, board_id)

	elif sprint_id != 'all' and sprint_id != 'backlog':
		sprint_id = UUID(sprint_id).hex
		sprint = Sprints.get(sprint_id)

	cursor.execute('''
			SELECT `name`, `id`
			FROM `boards`
			WHERE `id`=%s
		''',
		(board_id_uuid.bytes)
	)

	row = cursor.fetchone()
	board = None
	if row is not None:
		board = Board(row[0], binascii.b2a_hex(row[1]), Users.get_by_board(board_id), Stories.get_by_board(board_id, sprint_id), sprint)

	return board