示例#1
0
def printSelectedItems():
    itemCodes = __getSelectedItemCodes(flask.request.form)

    logging.debug(
        "printSelectedItems: Requested to print %(cnt)d item(s): %(items)s"
        % {"cnt": len(itemCodes), "items": ",".join(itemCodes)}
    )

    if len(itemCodes) > 0:
        selectedItems = flask.g.model.getItems(itemCodes)
        selectedItems[:] = [formatItem(item, flask.g.language) for item in selectedItems]
        return respondHtml(
            "bidsheets",
            flask.g.userGroup,
            flask.g.language,
            {
                "items": selectedItems,
                "cancelledTarget": flask.url_for(".listItems"),
                "printedTarget": flask.url_for(".listItems"),
            },
        )
    else:
        return respondHtml(
            "message",
            flask.g.userGroup,
            flask.g.language,
            {"message": Result.NO_ITEMS_SELECTED, "okTarget": flask.url_for(".listItems")},
        )
示例#2
0
def printAddedItems():
    addedItems = flask.g.model.getAddedItems(flask.g.sessionID)
    if len(addedItems) == 0:
        logging.warning("printAdded: No items to be printed. Returning back to the adding the item.")
        return __respondNewItemHtml(None, Result.NOTHING_TO_PRINT)
    else:
        logging.debug("printAdded: Printing %(numItems)d item(s)." % {"numItems": len(addedItems)})
        addedItems[:] = [formatItem(item, flask.g.language) for item in addedItems]
        return respondHtml(
            "bidsheets",
            flask.g.userGroup,
            flask.g.language,
            {
                "items": addedItems,
                "cancelledTarget": flask.url_for(".printAddedCancelled"),
                "printedTarget": flask.url_for(".printAddedPrinted"),
            },
        )