day-cohort-70 / Bangazon-API-BandyChamps

0 stars 0 forks source link

Fixed bug preventing order row details from displaying on order page #57

Closed nicholas-davison closed 1 month ago

nicholas-davison commented 1 month ago

Added order total custom property to order model, included field in order serializer, changed filtered orders to only include completed orders

Changes

Requests / Responses

Request

GET /orders lists all orders, their associated line items, and the total cost of the each order.

Response

HTTP/1.1 200 OK

[
    {
        "id": 1,
        "url": "http://localhost:8000/orders/1",
        "created_date": "2019-08-16",
        "payment_type": "http://localhost:8000/payment-types/1",
        "customer": "http://localhost:8000/customers/5",
        "lineitems": [],
        "total": 0
    },
    {
        "id": 3,
        "url": "http://localhost:8000/orders/3",
        "created_date": "2019-03-26",
        "payment_type": "http://localhost:8000/payment-types/1",
        "customer": "http://localhost:8000/customers/5",
        "lineitems": [
            {
                "id": 7,
                "product": {
                    "id": 50,
                    "name": "Golf",
                    "price": 653.59,
                    "number_sold": 2,
                    "description": "1994 Volkswagen",
                    "quantity": 4,
                    "created_date": "2019-07-10",
                    "location": "Berlin",
                    "image_path": "http://localhost:8000/media/products/vehicle.png",
                    "average_rating": 3.25
                }
            },
            {
                "id": 8,
                "product": {
                    "id": 50,
                    "name": "Golf",
                    "price": 653.59,
                    "number_sold": 2,
                    "description": "1994 Volkswagen",
                    "quantity": 4,
                    "created_date": "2019-07-10",
                    "location": "Berlin",
                    "image_path": "http://localhost:8000/media/products/vehicle.png",
                    "average_rating": 3.25
                }
            },
            {
                "id": 9,
                "product": {
                    "id": 45,
                    "name": "Optima",
                    "price": 1655.15,
                    "number_sold": 1,
                    "description": "2008 Kia",
                    "quantity": 3,
                    "created_date": "2019-05-21",
                    "location": "Toronto",
                    "image_path": "http://localhost:8000/media/products/vehicle.png",
                    "average_rating": 0
                }
            }
        ],
        "total": 2962.33
    },
    {
        "id": 6,
        "url": "http://localhost:8000/orders/6",
        "created_date": "2019-07-01",
        "payment_type": "http://localhost:8000/payment-types/1",
        "customer": "http://localhost:8000/customers/5",
        "lineitems": [],
        "total": 0
    }
]

Testing

Related Issues