registrasion/reporting/views.py
def discount_status(request, form):
    ''' Summarises the usage of a given discount. '''

    discounts = form.cleaned_data["discount"]

    items = commerce.DiscountItem.objects.filter(
        Q(discount__in=discounts),
    ).select_related("cart", "product", "product__category")

    items = group_by_cart_status(
        items,
        ["discount"],
        ["discount", "discount__description"],
    )

    headings = [
        "Discount", "Paid", "Reserved", "Unreserved", "Refunded",
    ]
    data = []

    for item in items:
        data.append([
            item["discount__description"],
            item["total_paid"],
            item["total_reserved"],
            item["total_unreserved"],
            item["total_refunded"],
        ])

    return ListReport("Usage by item", headings, data)
def discount_status(request, form):
    ''' Summarises the usage of a given discount. '''

    discounts = form.cleaned_data["discount"]

    items = commerce.DiscountItem.objects.filter(
        Q(discount__in=discounts),
    ).select_related("cart", "product", "product__category")

    items = group_by_cart_status(
        items,
        ["discount"],
        ["discount", "discount__description"],
    )

    headings = [
        "Discount", "Paid", "Reserved", "Unreserved", "Refunded",
    ]
    data = []

    for item in items:
        data.append([
            item["discount__description"],
            item["total_paid"],
            item["total_reserved"],
            item["total_unreserved"],
            item["total_refunded"],
        ])

    return ListReport("Usage by item", headings, data)
def discount_status ( request , form ) : discounts = form . cleaned_data [ "discount" ] items = commerce . DiscountItem . objects . filter ( Q ( discount__in = discounts ) , ) . select_related ( "cart" , "product" , "product__category" ) items = group_by_cart_status ( items , [ "discount" ] , [ "discount" , "discount__description" ] , ) headings = [ "Discount" , "Paid" , "Reserved" , "Unreserved" , "Refunded" , ] data = [ ] for item in items : data . append ( [ item [ "discount__description" ] , item [ "total_paid" ] , item [ "total_reserved" ] , item [ "total_unreserved" ] , item [ "total_refunded" ] , ] ) return ListReport ( "Usage by item" , headings , data )
Summarises the usage of a given discount.
Summarises the usage of a given discount .