def portfolio_funding(portfolio_id): portfolio = Portfolios.get(g.current_user, portfolio_id) task_orders = TaskOrders.sort(portfolio.task_orders) label_colors = { TaskOrderStatus.DRAFT: "warning", TaskOrderStatus.ACTIVE: "success", TaskOrderStatus.UPCOMING: "info", TaskOrderStatus.EXPIRED: "error", TaskOrderStatus.UNSIGNED: "purple", } return render_template( "task_orders/index.html", task_orders=task_orders, label_colors=label_colors )
def test_task_order_sorting(): """ Task orders should be listed first by status, and then by time_created. """ today = date.today() yesterday = today - timedelta(days=1) future = today + timedelta(days=100) task_orders = [ # 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)], ), TaskOrderFactory.create( signed_at=yesterday, clins=[CLINFactory.create(start_date=yesterday, end_date=future)], ), 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)], ), TaskOrderFactory.create( signed_at=yesterday, clins=[CLINFactory.create(start_date=future, end_date=future)], ), 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) ], ), 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)]), TaskOrderFactory.create( clins=[CLINFactory.create(start_date=today, end_date=today)]), TaskOrderFactory.create( clins=[CLINFactory.create(start_date=today, end_date=today)]), ] assert TaskOrders.sort(task_orders) == task_orders