예제 #1
0
def handler_exception(error):
    formatted = traceback.format_exc()
    lines = formatted.splitlines() if quorum.is_devel() else []

    return flask.Response(flask.render_template("error.html.tpl",
                                                error=str(error),
                                                traceback=lines),
                          status=500)
예제 #2
0
def do_ctt_extras():
    api = util.get_api()
    sale_orders = api.list_sale_orders(**{
        "start_record" : 0,
        "number_records" : -1,
        "eager[]" : [
            "customer",
            "customer.primary_contact_information",
            "shipping_address"
        ],
        "filters[]" : [
            "workflow_state:equals:5",
            "shipping_type:equals:2"
        ]
    })

    out_data = util.encode_ctt(sale_orders, encoding = "Cp1252")

    return flask.Response(
        out_data,
        mimetype = "binary/octet-stream"
    )
예제 #3
0
def do_template_extras():
    object = quorum.get_object()
    mask_name = object.get("mask_name", None)
    format = object.get("format", "png")
    base_file = object.get("base_file", None)
    base_data = base_file.read()

    mask_name = "mask_" + mask_name if mask_name else "mask"
    mask_name = mask_name.lower()
    mask_name = mask_name.replace(" ", "_")

    api = util.get_api()
    try: mask_data = api.public_media_system_company(label = mask_name)
    except Exception: mask_data = None
    if not mask_data: raise quorum.OperationalError("No mask defined")

    out_data = util.mask_image(base_data, mask_data, format = format)
    mimetype = mimetypes.guess_type("_." + format)[0]

    return flask.Response(
        out_data,
        mimetype = mimetype or "application/octet-stream"
    )
예제 #4
0
def handler_413(error):
    return flask.Response(flask.render_template(
        "error.html.tpl", error="412 - Precondition failed"),
                          status=413)
예제 #5
0
def handler_404(error):
    return flask.Response(flask.render_template("error.html.tpl",
                                                error="404 - Page not found"),
                          status=404)