Applied auto pep 8 changes
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
from .database import DatabaseController
|
||||
from models.products.product import Product
|
||||
|
||||
|
||||
class ProductController(DatabaseController):
|
||||
FIELDS = ['id', 'name', 'image', 'description', 'cost', 'category', 'sellerID', 'postedDate', 'quantityAvailable']
|
||||
FIELDS = ['id', 'name', 'image', 'description', 'cost',
|
||||
'category', 'sellerID', 'postedDate', 'quantityAvailable']
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
@@ -25,7 +27,6 @@ class ProductController(DatabaseController):
|
||||
)
|
||||
self._conn.commit()
|
||||
|
||||
|
||||
def read(self, name: str = "") -> list[Product] | None:
|
||||
params = [
|
||||
"%" + name + "%"
|
||||
@@ -39,24 +40,23 @@ class ProductController(DatabaseController):
|
||||
|
||||
if rows == None:
|
||||
return None
|
||||
|
||||
|
||||
products = list()
|
||||
|
||||
|
||||
# Create an object for each row
|
||||
for product in rows:
|
||||
params = dict(zip(self.FIELDS, product))
|
||||
obj = self.new_instance(Product, params)
|
||||
products.append(obj)
|
||||
|
||||
return products
|
||||
|
||||
return products
|
||||
|
||||
def read_all(self, category: str = "", search_term: str = "") -> list[Product] | None:
|
||||
params = [
|
||||
"%" + category + "%",
|
||||
"%" + search_term + "%"
|
||||
]
|
||||
|
||||
|
||||
cursor = self._conn.execute(
|
||||
"""SELECT * FROM Products
|
||||
INNER JOIN Categories ON Products.categoryID = Categories.id
|
||||
@@ -69,19 +69,19 @@ class ProductController(DatabaseController):
|
||||
|
||||
if len(rows) == 0:
|
||||
return None
|
||||
|
||||
|
||||
products = list()
|
||||
|
||||
|
||||
# Create an object for each row
|
||||
for product in rows:
|
||||
params = dict(zip(self.FIELDS, product))
|
||||
obj = self.new_instance(Product, params)
|
||||
products.append(obj)
|
||||
|
||||
|
||||
return products
|
||||
|
||||
def update(self):
|
||||
print("Doing work")
|
||||
|
||||
|
||||
def delete(self):
|
||||
print("Doing work")
|
||||
print("Doing work")
|
||||
|
||||
Reference in New Issue
Block a user