Esempio n. 1
0
def order(order_id):
    try:
        details = model.get_order_details(order_id)
    except model.NotFound:
        raise werkzeug.exceptions.NotFound
    try:
        estimate_order = model.get_estimate_order(order_id)
    except model.NotFound:
        estimate_order = None
    jobs = model.get_jobs(order_id)
    return render_template('order.html', details=details,
                           estimate_order=estimate_order, jobs=jobs)
Esempio n. 2
0
def accept_jobs(order_id):
    try:
        jobs = model.get_jobs(order_id)
    except model.NotFound:
        raise werkzeug.exceptions.NotFound

    jobs_form = forms.job_acceptance_form_factory(jobs)(request.form)
    if request.method == 'POST' and jobs_form.validate():
        data = jobs_form.get_safe_data()
        if not any(d['accepted'] for d in data):
            try:
                model.reject_order(order_id)
            except model.DatabaseError as e:
                raise werkzeug.exceptions.Forbidden from e
        else:
            try:
                model.save_job_acceptance(order_id, data)
            except model.DatabaseError as e:
                raise werkzeug.exceptions.Forbidden from e
        return redirect(url_for('order', order_id=order_id))
    return render_template("jobs_form.html", jobs_form=jobs_form, order_id=order_id,
                           jobs=jobs)