From c65e41b2d6333798f48869e9c1e678a66f11732a Mon Sep 17 00:00:00 2001 From: Hope Tambala Date: Fri, 10 Apr 2020 19:29:02 -0400 Subject: [PATCH] fix: purchase history --- app.py | 2 +- db/database.py | 4 +--- db/pineapplestore.db | Bin 57344 -> 57344 bytes endpoints/purchase_history.py | 23 +++++++++++++++++------ models/purchase_history.py | 29 ++++++++++++++++++----------- 5 files changed, 37 insertions(+), 21 deletions(-) diff --git a/app.py b/app.py index 2fdffd6..c4e9553 100644 --- a/app.py +++ b/app.py @@ -33,7 +33,7 @@ def home(): api.add_resource(UserRegister, '/user/register') api.add_resource(Inventory, '/product/') api.add_resource(InventoryProductList, '/products') -api.add_resource(PurchaseHistory, '/history/') +api.add_resource(PurchaseHistory, '/history/purchase/') api.add_resource(ScanHistory, '/history/scan/') api.add_resource(ScanHistoryRegister, '/history/scan') api.add_resource(Shopping, '/shopping') diff --git a/db/database.py b/db/database.py index afb0a64..34baa46 100644 --- a/db/database.py +++ b/db/database.py @@ -15,7 +15,7 @@ create_history_table ='{}{}{}{}{}{}'.format( 'CREATE TABLE IF NOT EXISTS', ' purchase_history(id INTEGER PRIMARY KEY,', - ' product text, user_id INTEGER NOT NULL,', + ' user_id INTEGER NOT NULL,', ' product_id INTEGER NOT NULL,', ' FOREIGN KEY (user_id) REFERENCES user(id),', ' FOREIGN KEY (product_id) REFERENCES inventory(id));' @@ -79,8 +79,6 @@ query = "INSERT OR REPLACE INTO inventory VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" cursor.execute(query, row) -cursor.execute('INSERT OR REPLACE INTO purchase_history VALUES(1, "tshirt", 1, 1);') - create_shipping_address_table = '{}{}{}{}{}'.format( 'CREATE TABLE IF NOT EXISTS', ' shipping_address(id INTEGER PRIMARY KEY, user_id INTEGER NOT NULL,', diff --git a/db/pineapplestore.db b/db/pineapplestore.db index 6f4dada3a2185e4f901e409067c6371deb6bf2b2..5890cf3a0ad987f8e7be2e0ad4a9c5c488663c51 100644 GIT binary patch delta 286 zcmZoTz}#?vd4e<}_e2?Id2R+hnGL)Q3=EtcI~e%B@-60F$#aUwk$VN#dd^K8J2oo{ zSaED##qp7atFfG!U0hd}u~~8QQr?)!yqr>-HTiBcig55nG4P+`pT(cfZ^ZYX?$lBme-(BTJM3 delta 416 zcmZoTz}#?vd4e>f*hCp;c`*h(nGL)Q3=Etcs~Gsc@-60_&9jHcn0pr2Le3=|t2Q?3 zaBSYe@sWkAiItgMTvwN|*>>_~-WZ;OqWqN7l!b|}pTrj6KGp)?DaHfCdn(o9gA5kiCPX5!z^ zz<-~AKhVU@{JwHP6^@)n21W+D1}3_O1|fzPR;CtK#s+!@re+2PhVnq2j*O`CMut{~ zW_o58#s(%9Ob{a