コード例 #1
0
ファイル: new.py プロジェクト: jimilinuxguy/atst
def render_task_orders_edit(
    template, portfolio_id=None, task_order_id=None, form=None, extra_args=None
):
    render_args = extra_args or {}

    render_args["contract_start"] = app.config.get("CONTRACT_START_DATE")
    render_args["contract_end"] = app.config.get("CONTRACT_END_DATE")

    if task_order_id:
        task_order = TaskOrders.get(task_order_id)
        portfolio_id = task_order.portfolio_id
        render_args["form"] = form or TaskOrderForm(obj=task_order)
        render_args["task_order_id"] = task_order_id
        render_args["task_order"] = task_order
    else:
        render_args["form"] = form or TaskOrderForm()

    render_args["cancel_save_url"] = url_for(
        "task_orders.cancel_edit",
        task_order_id=task_order_id,
        portfolio_id=portfolio_id,
        save=True,
    )
    render_args["cancel_discard_url"] = url_for(
        "task_orders.cancel_edit",
        task_order_id=task_order_id,
        portfolio_id=portfolio_id,
        save=False,
    )

    return render_template(template, **render_args)
コード例 #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 プロジェクト: jimilinuxguy/atst
def edit(task_order_id):
    task_order = TaskOrders.get(task_order_id)

    if not task_order.pdf:
        return redirect(
            url_for("task_orders.form_step_one_add_pdf", task_order_id=task_order_id)
        )
    elif not task_order.number:
        return redirect(
            url_for("task_orders.form_step_two_add_number", task_order_id=task_order_id)
        )
    elif not task_order.clins_are_completed:
        return redirect(
            url_for(
                "task_orders.form_step_three_add_clins", task_order_id=task_order_id
            )
        )
    elif task_order.is_completed:
        return redirect(
            url_for("task_orders.form_step_four_review", task_order_id=task_order_id)
        )
    else:
        return redirect(
            url_for("task_orders.form_step_one_add_pdf", task_order_id=task_order_id)
        )
コード例 #5
0
ファイル: new.py プロジェクト: jimilinuxguy/atst
def submit_task_order(task_order_id):
    task_order = TaskOrders.get(task_order_id)
    TaskOrders.sign(task_order=task_order, signer_dod_id=g.current_user.dod_id)

    flash("task_order_submitted", task_order=task_order)

    return redirect(
        url_for("task_orders.portfolio_funding", portfolio_id=task_order.portfolio_id)
    )
コード例 #6
0
ファイル: new.py プロジェクト: jimilinuxguy/atst
def form_step_five_confirm_signature(task_order_id):
    task_order = TaskOrders.get(task_order_id)

    if task_order.is_completed == False:
        raise NoAccessError("task order form signature")

    return render_task_orders_edit(
        "task_orders/step_5.html", task_order_id=task_order_id, form=SignatureForm()
    )
コード例 #7
0
def review_task_order(task_order_id):
    task_order = TaskOrders.get(task_order_id)
    if task_order.is_draft:
        return redirect(url_for("task_orders.edit", task_order_id=task_order.id))
    else:
        signature_form = SignatureForm()
        return render_template(
            "task_orders/review.html",
            task_order=task_order,
            signature_form=signature_form,
        )
コード例 #8
0
ファイル: new.py プロジェクト: jimilinuxguy/atst
def form_step_four_review(task_order_id):
    task_order = TaskOrders.get(task_order_id)

    extra_args = {
        "pdf_download_url": app.csp.files.generate_download_link(
            task_order.pdf.object_name, task_order.pdf.filename
        )
    }

    if task_order.is_completed == False:
        raise NoAccessError("task order form review")

    return render_task_orders_edit(
        "task_orders/step_4.html", task_order_id=task_order_id, extra_args=extra_args
    )
コード例 #9
0
ファイル: new.py プロジェクト: v1psta/atst
def update_and_render_next(
    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)

    task_order = update_task_order(form, portfolio_id, task_order_id)
    if task_order:
        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,
        )
コード例 #10
0
def download_task_order_pdf(task_order_id):
    task_order = TaskOrders.get(task_order_id)
    if task_order.pdf:
        return send_file(task_order.pdf)
    else:
        raise NotFoundError("task_order pdf")