Resolved merge conflict

This commit is contained in:
2024-01-15 17:45:47 +00:00
21 changed files with 217 additions and 48 deletions

View File

@ -1,14 +1,25 @@
from abc import ABC, abstractmethod
from typing import Mapping, Any
import sqlite3
import os
class DatabaseController(ABC):
__sqlitefile = "./data/wmgzon.db"
__data_dir = "./data/"
__db_name = "wmgzon.db"
# Use test file if necessary
if os.environ.get("ENVIRON") == "test":
__db_name = "test_" + __db_name
__sqlitefile = __data_dir + __db_name
def __init__(self):
self._conn = None
try:
self._conn = sqlite3.connect(self.__sqlitefile)
# Creates a connection and specifies a flag to parse all types back down into
# Python declared types e.g. date & time
self._conn = sqlite3.connect(self.__sqlitefile, detect_types=sqlite3.PARSE_DECLTYPES)
except sqlite3.Error as e:
# Close the connection if still open
if self._conn:

View File

@ -2,7 +2,7 @@ from .database import DatabaseController
from models.products.product import Product
class ProductController(DatabaseController):
FIELDS = ['id', 'name', 'image', 'description', 'cost', 'category', 'sellerID', 'postedDate', 'quantity']
FIELDS = ['id', 'name', 'image', 'description', 'cost', 'category', 'sellerID', 'postedDate', 'quantityAvailable']
def __init__(self):
super().__init__()
@ -20,7 +20,7 @@ class ProductController(DatabaseController):
]
self._conn.execute(
"INSERT INTO Products (name, cost, image, description, category, sellerID, postedDate, quantityAvailable) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
"INSERT INTO Products (name, image, description, cost, categoryID, sellerID, postedDate, quantityAvailable) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
params
)
self._conn.commit()
@ -46,7 +46,7 @@ class ProductController(DatabaseController):
for product in rows:
params = dict(zip(self.FIELDS, product))
obj = self.new_instance(Product, params)
products.push(obj)
products.append(obj)
return products

View File

@ -55,14 +55,12 @@ def signup():
return redirect("/signup")
database.create(Customer(
0,
request.form['username'],
sha512(request.form['password'].encode()).hexdigest(), # Hashed as soon as it is recieved on the backend
request.form['firstname'],
request.form['lastname'],
request.form['email'],
"123",
"Customer"
"123"
))
# Code 307 Preserves the original request (POST)