#4 #6 Base creation of a product viewing page with the ability to edit as a seller

This commit is contained in:
2024-01-24 18:07:41 +00:00
parent 95768f8a8c
commit 0951bcc23e
10 changed files with 193 additions and 28 deletions

View File

@ -4,7 +4,7 @@ from models.products.product import Product
class ProductController(DatabaseController):
FIELDS = ['id', 'name', 'image', 'description', 'cost',
'category', 'sellerID', 'postedDate', 'quantityAvailable']
'sellerID', 'category', 'postedDate', 'quantityAvailable']
def __init__(self):
super().__init__()
@ -131,8 +131,30 @@ class ProductController(DatabaseController):
return products
def update(self):
print("Doing work")
def update(self, product: Product):
params = [
product.name,
product.description,
product.image,
product.cost,
product.quantityAvailable,
product.category,
product.id
]
cursor = self._conn.execute(
"""UPDATE Products
SET name = ?,
description = ?,
image = ?,
cost = ?,
quantityAvailable = ?,
categoryID = ?
WHERE id = ?
""",
params
)
self._conn.commit()
def delete(self):
print("Doing work")