Skip to content

Added pizza API

Gijs Hendriksen requested to merge 490-pizza-api into master

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': ...}, where event is the current PizzaEvent and order is 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

  1. Create a PizzaEvent instance.
  2. Use POST as described above to create an order.
  3. Use GET to view your order and the event.
  4. Use PUT to update your order.
  5. Use DELETE to cancel your order.
  6. Note that the features above also work for other people's orders if you are admin.

Merge request reports