示例#1
0
文件: test_index.py 项目: robgil/atst
def test_review_task_order_draft(client, user_session, task_order):
    TaskOrders.update(task_order_id=task_order.id,
                      number="1234567890",
                      clins=[],
                      pdf=None)
    user_session(task_order.portfolio.owner)
    response = client.get(
        url_for("task_orders.review_task_order", task_order_id=task_order.id))
    assert response.status_code == 302
    assert url_for("task_orders.edit",
                   task_order_id=task_order.id) in response.location
示例#2
0
文件: new.py 项目: jimilinuxguy/atst
def update_task_order(
    form_data, next_page, current_template, portfolio_id=None, task_order_id=None
):
    form = None
    if task_order_id:
        task_order = TaskOrders.get(task_order_id)
        form = TaskOrderForm(form_data, obj=task_order)
    else:
        form = TaskOrderForm(form_data)

    if form.validate():
        task_order = None
        if task_order_id:
            task_order = TaskOrders.update(task_order_id, **form.data)
            portfolio_id = task_order.portfolio_id
        else:
            task_order = TaskOrders.create(g.current_user, portfolio_id, **form.data)

        return redirect(url_for(next_page, task_order_id=task_order.id))
    else:
        return (
            render_task_orders_edit(
                current_template, portfolio_id, task_order_id, form
            ),
            400,
        )
示例#3
0
文件: new.py 项目: jimilinuxguy/atst
def cancel_edit(task_order_id=None, portfolio_id=None):
    # Either save the currently entered data, or delete the TO
    save = http_request.args.get("save", "True").lower() == "true"

    if save:
        form_data = {**http_request.form}
        form = None
        if task_order_id:
            task_order = TaskOrders.get(task_order_id)
            form = TaskOrderForm(form_data, obj=task_order)
        else:
            form = TaskOrderForm(form_data)

        if form.validate(flash_invalid=False):
            task_order = None
            if task_order_id:
                task_order = TaskOrders.update(task_order_id, **form.data)
            else:
                task_order = TaskOrders.create(
                    g.current_user, portfolio_id, **form.data
                )
    elif not save and task_order_id:
        TaskOrders.delete(task_order_id)

    return redirect(
        url_for("task_orders.portfolio_funding", portfolio_id=g.portfolio.id)
    )
示例#4
0
文件: new.py 项目: v1psta/atst
def update_task_order(form, portfolio_id=None, task_order_id=None, flash_invalid=True):
    if form.validate(flash_invalid=flash_invalid):
        task_order = None
        try:
            if task_order_id:
                task_order = TaskOrders.update(task_order_id, **form.data)
                portfolio_id = task_order.portfolio_id
            else:
                task_order = TaskOrders.create(portfolio_id, **form.data)

            return task_order

        except AlreadyExistsError:
            flash("task_order_number_error", to_number=form.data["number"])
            return False
    else:
        return False
示例#5
0
def test_update_does_not_duplicate_clins():
    task_order = TaskOrderFactory.create(number="3453453456",
                                         create_clins=[{
                                             "number": "123"
                                         }, {
                                             "number": "456"
                                         }])
    clins = [
        {
            "jedi_clin_type": "JEDI_CLIN_1",
            "number": "123",
            "start_date": date(2020, 1, 1),
            "end_date": date(2021, 1, 1),
            "obligated_amount": Decimal("5000"),
            "total_amount": Decimal("10000"),
        },
        {
            "jedi_clin_type": "JEDI_CLIN_1",
            "number": "111",
            "start_date": date(2020, 1, 1),
            "end_date": date(2021, 1, 1),
            "obligated_amount": Decimal("5000"),
            "total_amount": Decimal("10000"),
        },
    ]
    task_order = TaskOrders.update(
        task_order_id=task_order.id,
        number="0000000000",
        clins=clins,
        pdf={
            "filename": "sample.pdf",
            "object_name": "1234567"
        },
    )
    assert len(task_order.clins) == 2
    for clin in task_order.clins:
        assert clin.number != "456"
示例#6
0
def test_update_enforces_unique_number():
    task_order = TaskOrderFactory.create()
    dupe_task_order = TaskOrderFactory.create()
    with pytest.raises(AlreadyExistsError):
        TaskOrders.update(dupe_task_order.id, task_order.number, [], None)