def portfolio_funding(portfolio_id): portfolio = Portfolios.get(g.current_user, portfolio_id) task_orders = TaskOrders.sort_by_status(portfolio.task_orders) to_count = len(portfolio.task_orders) # TODO: Get expended amount from the CSP return render_template("task_orders/index.html", task_orders=task_orders, to_count=to_count)
def test_task_order_sort_by_status(): today = date.today() yesterday = today - timedelta(days=1) future = today + timedelta(days=100) initial_to_list = [ # Draft TaskOrderFactory.create(pdf=None), TaskOrderFactory.create(pdf=None), TaskOrderFactory.create(pdf=None), # Active TaskOrderFactory.create( signed_at=yesterday, clins=[CLINFactory.create(start_date=yesterday, end_date=future)], ), # Upcoming TaskOrderFactory.create( signed_at=yesterday, clins=[CLINFactory.create(start_date=future, end_date=future)], ), # Expired TaskOrderFactory.create( signed_at=yesterday, clins=[ CLINFactory.create(start_date=yesterday, end_date=yesterday) ], ), TaskOrderFactory.create( signed_at=yesterday, clins=[ CLINFactory.create(start_date=yesterday, end_date=yesterday) ], ), # Unsigned TaskOrderFactory.create( clins=[CLINFactory.create(start_date=today, end_date=today)]), ] sorted_by_status = TaskOrders.sort_by_status(initial_to_list) assert len(sorted_by_status["Draft"]) == 3 assert len(sorted_by_status["Active"]) == 1 assert len(sorted_by_status["Upcoming"]) == 1 assert len(sorted_by_status["Expired"]) == 2 assert len(sorted_by_status["Unsigned"]) == 1 assert list( sorted_by_status.keys()) == [status.value for status in SORT_ORDERING]