sdacelo commited on
Commit
7e2efd0
·
1 Parent(s): 0854db3

comment the delete part

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -81,7 +81,7 @@ def get_orders():
81
  def get_payments():
82
  return efd.payments
83
 
84
- # Post
85
  @app.post("/customers/", summary="Add a customer", description="Allows you to add a new customer to the customers list.", tags=["Customers"])
86
  def create_customer(customer: Customer):
87
  efd.customers.append(customer.model_dump())
@@ -110,15 +110,15 @@ def update_product(product_id: str, updated_product: Product):
110
  raise HTTPException(status_code=404, detail="Product not found")
111
 
112
  # DELETE
113
- @app.delete("/customers/{customer_id}", summary="Delete a customer", description="Allows you to delete a customer by their ID.", tags=["Customers"])
114
- def delete_customer(customer_id: str):
115
- initial_length = len(efd.customers)
116
- efd.customers = [c for c in efd.customers if c["customer_id"] != customer_id]
117
- if len(efd.customers) < initial_length:
118
- return {"message": "Customer successfully deleted !"}
119
- raise HTTPException(status_code=404, detail="Customer not found")
120
-
121
- @app.delete("/products/{product_id}", summary="Delete a product", description="Allows you to delete a product by its ID.", tags=["Products"])
122
- def delete_product(product_id: str):
123
- efd.products = [p for p in efd.products if p["product_id"] != product_id]
124
- return {"message": "Product successfully deleted !"}
 
81
  def get_payments():
82
  return efd.payments
83
 
84
+ # POST
85
  @app.post("/customers/", summary="Add a customer", description="Allows you to add a new customer to the customers list.", tags=["Customers"])
86
  def create_customer(customer: Customer):
87
  efd.customers.append(customer.model_dump())
 
110
  raise HTTPException(status_code=404, detail="Product not found")
111
 
112
  # DELETE
113
+ # @app.delete("/customers/{customer_id}", summary="Delete a customer", description="Allows you to delete a customer by their ID.", tags=["Customers"])
114
+ # def delete_customer(customer_id: str):
115
+ # initial_length = len(efd.customers)
116
+ # efd.customers = [c for c in efd.customers if c["customer_id"] != customer_id]
117
+ # if len(efd.customers) < initial_length:
118
+ # return {"message": "Customer successfully deleted !"}
119
+ # raise HTTPException(status_code=404, detail="Customer not found")
120
+
121
+ # @app.delete("/products/{product_id}", summary="Delete a product", description="Allows you to delete a product by its ID.", tags=["Products"])
122
+ # def delete_product(product_id: str):
123
+ # efd.products = [p for p in efd.products if p["product_id"] != product_id]
124
+ # return {"message": "Product successfully deleted !"}