Added pizza API
Closes #490 (closed)
Short description
Introduces an API for the pizzas app.
Long description
Implements the proposal as described in #490 (closed), where the following methods are included in the API:
-
GET /api/v1/pizzas/to view pizzas (only if there is currently a PizzaEvent or if admin) -
GET /api/v1/pizzas/event/to view the current PizzaEvent. This returns a dictionary{'order': ..., 'event': ...}, whereeventis the current PizzaEvent andorderis your current order. -
GET /api/v1/pizzas/orders/to view all orders for the current event (only if admin. Also works for non-admins, but they only get to see their own order) -
GET /api/v1/pizzas/orders/[<id>|me]/to view a specific order (only if yours or admin) -
POST /api/v1/pizzas/orders/to create a new order (with an optional body containing a name, for adding an order for non-members) -
PUT /api/v1/pizzas/orders/[<id>|me]/to edit a specific order, with a product id in the body, and (for admins) a paid field in the body (only if yours or admin) -
DELETE /api/v1/pizzas/orders/[<id>|me]/to cancel a specific order (only if yours or admin)
Steps to use this feature
- Create a PizzaEvent instance.
- Use
POSTas described above to create an order. - Use
GETto view your order and the event. - Use
PUTto update your order. - Use
DELETEto cancel your order. - Note that the features above also work for other people's orders if you are admin.