From 3ab28db332f855a98058a493024d98392b7ee5bb Mon Sep 17 00:00:00 2001 From: adamjohnson650 <133832291+adamjohnson650@users.noreply.github.com> Date: Wed, 7 Jun 2023 08:14:56 -0700 Subject: [PATCH 01/14] Update main.py --- main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 67fb91b..c0d17ab 100644 --- a/main.py +++ b/main.py @@ -39,10 +39,10 @@ def root(): #cur.execute('SELECT productId, name, price, description, image, stock FROM products LIMIT 1') item_data = cur.fetchall() # Show an error instead of the categories - category_data = [(-1,"Error")] + #category_data = [(-1,"Error")] # Show all categories - #cur.execute('SELECT categoryId, name FROM categories') - #category_data = cur.fetchall() + cur.execute('SELECT categoryId, name FROM categories') + category_data = cur.fetchall() item_data = parse(item_data) return render_template('home.html', itemData=item_data, loggedIn=logged_in, firstName=first_name, noOfItems=no_of_items, categoryData=category_data) From 3ed044ef783e5833d60d2fc76ccf7128d58f0a94 Mon Sep 17 00:00:00 2001 From: Olakunleabiola <132951450+Olakunleabiola@users.noreply.github.com> Date: Wed, 7 Jun 2023 20:58:43 -0700 Subject: [PATCH 02/14] Update main.py --- main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 67fb91b..62db252 100644 --- a/main.py +++ b/main.py @@ -34,9 +34,9 @@ def root(): with sqlite3.connect('database.db') as conn: cur = conn.cursor() # Show last product added - cur.execute('SELECT productId, name, price, description, image, stock FROM products ORDER BY productId DESC LIMIT 1 ') + cur.execute('SELECT productId, name, price, description, image, stock FROM products ORDER BY productId ') # Show all items - #cur.execute('SELECT productId, name, price, description, image, stock FROM products LIMIT 1') + cur.execute('SELECT productId, name, price, description, image, stock FROM products') item_data = cur.fetchall() # Show an error instead of the categories category_data = [(-1,"Error")] From a13bf53ef253c38992b71b46cd6a88430a367c04 Mon Sep 17 00:00:00 2001 From: TheodoraK7090 Date: Thu, 8 Jun 2023 21:41:59 -0700 Subject: [PATCH 03/14] fixed routing issues --- main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 67fb91b..51ab405 100644 --- a/main.py +++ b/main.py @@ -176,10 +176,10 @@ def update_profile(): @app.route("/loginForm") def login_form(): # Uncomment to enable logging in and registration - #if 'email' in session: + if 'email' in session: return redirect(url_for('root')) - #else: - # return render_template('login.html', error='') + else: + return render_template('login.html', error='') @app.route("/login", methods = ['POST', 'GET']) def login(): From 26216493c8e036a4d1dedb6d28950f687970c045 Mon Sep 17 00:00:00 2001 From: TheodoraK7090 Date: Mon, 12 Jun 2023 17:52:42 -0700 Subject: [PATCH 04/14] Change for checking --- README.md | 2 +- main.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e9df433..06e0895 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Bookstore + # Bookstore Bookstore is a web application by Alabamazon and is the final project for CNE 310 IT Project Management. ## Getting Started ## diff --git a/main.py b/main.py index 51ab405..4e7419d 100644 --- a/main.py +++ b/main.py @@ -179,7 +179,7 @@ def login_form(): if 'email' in session: return redirect(url_for('root')) else: - return render_template('login.html', error='') + #return render_template('login.html', error='') @app.route("/login", methods = ['POST', 'GET']) def login(): From a9b0b6020f28e5c921e1db751bb53b699aeefab4 Mon Sep 17 00:00:00 2001 From: TheodoraK7090 Date: Mon, 12 Jun 2023 17:58:16 -0700 Subject: [PATCH 05/14] Corrected line 182 --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 4e7419d..51ab405 100644 --- a/main.py +++ b/main.py @@ -179,7 +179,7 @@ def login_form(): if 'email' in session: return redirect(url_for('root')) else: - #return render_template('login.html', error='') + return render_template('login.html', error='') @app.route("/login", methods = ['POST', 'GET']) def login(): From 7caae3fa5350cb958cb2d23a9adc50ba9306ffe7 Mon Sep 17 00:00:00 2001 From: TheodoraK7090 Date: Tue, 13 Jun 2023 16:48:24 -0700 Subject: [PATCH 06/14] change in "error" Changed from "error=" to "error = " --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index b1eea9d..6d0824b 100644 --- a/main.py +++ b/main.py @@ -179,7 +179,7 @@ def login_form(): if 'email' in session: return redirect(url_for('root')) else: - return render_template('login.html', error='') + return render_template('login.html', error = '') @app.route("/login", methods = ['POST', 'GET']) def login(): From f83652ba9a3b686f23c1af2ac13aef81b1a2d8a4 Mon Sep 17 00:00:00 2001 From: TheodoraK7090 Date: Tue, 13 Jun 2023 16:55:52 -0700 Subject: [PATCH 07/14] Changed error changed "error=" back --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 6d0824b..b1eea9d 100644 --- a/main.py +++ b/main.py @@ -179,7 +179,7 @@ def login_form(): if 'email' in session: return redirect(url_for('root')) else: - return render_template('login.html', error = '') + return render_template('login.html', error='') @app.route("/login", methods = ['POST', 'GET']) def login(): From 01fc3dcd19852ea8909f1d8206305dd93b6eb7a5 Mon Sep 17 00:00:00 2001 From: TheodoraK7090 Date: Tue, 13 Jun 2023 17:31:27 -0700 Subject: [PATCH 08/14] put back # --- database.db | Bin 28672 -> 28672 bytes main.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/database.db b/database.db index 26fcec2f7f733e9c79c9bd7b0262a68db0427e9d..a7accafd7cb5f417b671ff08fe5a726793811cf2 100644 GIT binary patch delta 172 zcmZp8z}WDBae_3X`9v9KR&xfuaIcLi3-~!0`5PJd8~Gk>7F0OEH~Ea**7{mTUIt%l zaY1JD^ODq*l*;V<LTFxQS!z*n zW=W-yfw7T+xqD)1Nn);oQ)x;{Mj}uR(9qD5lEk8bqQsQc;tbEcl*~j+Q%g%@BO?Pt IgGCAf08_j>@&Et; diff --git a/main.py b/main.py index b1eea9d..127336f 100644 --- a/main.py +++ b/main.py @@ -178,7 +178,7 @@ def login_form(): # Uncomment to enable logging in and registration if 'email' in session: return redirect(url_for('root')) - else: + #else: return render_template('login.html', error='') @app.route("/login", methods = ['POST', 'GET']) From 3a8673313bded555bf53a48f6d22bf4dcd8ae3cc Mon Sep 17 00:00:00 2001 From: TheodoraK7090 Date: Tue, 13 Jun 2023 17:36:33 -0700 Subject: [PATCH 09/14] took back # --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 127336f..b1eea9d 100644 --- a/main.py +++ b/main.py @@ -178,7 +178,7 @@ def login_form(): # Uncomment to enable logging in and registration if 'email' in session: return redirect(url_for('root')) - #else: + else: return render_template('login.html', error='') @app.route("/login", methods = ['POST', 'GET']) From 72f5dba04cf3c10e3a0f12e4fcc9f5edadbcba5e Mon Sep 17 00:00:00 2001 From: adamjohnson650 <133832291+adamjohnson650@users.noreply.github.com> Date: Tue, 13 Jun 2023 18:25:20 -0700 Subject: [PATCH 10/14] Update main.py --- main.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index b1eea9d..8e6b737 100644 --- a/main.py +++ b/main.py @@ -19,14 +19,14 @@ def get_login_details(): logged_in = False first_name = '' no_of_items = 0 - else: - logged_in = True - cur.execute("SELECT user_id, first_name FROM users WHERE email = '" + session['email'] + "'") - user_id, first_name = cur.fetchone() - cur.execute("SELECT count(productId) FROM kart WHERE user_id = " + str(user_id)) - no_of_items = cur.fetchone()[0] + #else: + #logged_in = True + #cur.execute("SELECT user_id, first_name FROM users WHERE email = '" + session['email'] + "'") + #user_id, first_name = cur.fetchone() + #cur.execute("SELECT count(productId) FROM kart WHERE user_id = " + str(user_id)) + #no_of_items = cur.fetchone()[0] conn.close() - return (logged_in, first_name, no_of_items) + (logged_in, first_name, no_of_items) @app.route("/") def root(): From a5bb9619aea0e06de91e8caa3c5d08c39e722a82 Mon Sep 17 00:00:00 2001 From: adamjohnson650 <133832291+adamjohnson650@users.noreply.github.com> Date: Tue, 13 Jun 2023 18:27:34 -0700 Subject: [PATCH 11/14] Revert "Update main.py" This reverts commit 72f5dba04cf3c10e3a0f12e4fcc9f5edadbcba5e. --- main.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index 8e6b737..b1eea9d 100644 --- a/main.py +++ b/main.py @@ -19,14 +19,14 @@ def get_login_details(): logged_in = False first_name = '' no_of_items = 0 - #else: - #logged_in = True - #cur.execute("SELECT user_id, first_name FROM users WHERE email = '" + session['email'] + "'") - #user_id, first_name = cur.fetchone() - #cur.execute("SELECT count(productId) FROM kart WHERE user_id = " + str(user_id)) - #no_of_items = cur.fetchone()[0] + else: + logged_in = True + cur.execute("SELECT user_id, first_name FROM users WHERE email = '" + session['email'] + "'") + user_id, first_name = cur.fetchone() + cur.execute("SELECT count(productId) FROM kart WHERE user_id = " + str(user_id)) + no_of_items = cur.fetchone()[0] conn.close() - (logged_in, first_name, no_of_items) + return (logged_in, first_name, no_of_items) @app.route("/") def root(): From 7ad54189d9a81a67e01eb20dc162d9d2e8e947bf Mon Sep 17 00:00:00 2001 From: adamjohnson650 <133832291+adamjohnson650@users.noreply.github.com> Date: Tue, 13 Jun 2023 18:30:28 -0700 Subject: [PATCH 12/14] Update .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ba13964..4e333d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ query.py venv/ -.idea \ No newline at end of file +.idea +database.db From f649616239ba3e6c8b143f6a2cb2f88cf46adbfe Mon Sep 17 00:00:00 2001 From: adamjohnson650 <133832291+adamjohnson650@users.noreply.github.com> Date: Tue, 13 Jun 2023 19:54:11 -0700 Subject: [PATCH 13/14] fixed code --- database.db | Bin 28672 -> 28672 bytes main.py | 10 +++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/database.db b/database.db index a7accafd7cb5f417b671ff08fe5a726793811cf2..b669868c435463798bc6a4dc8b76a6a20ad9c791 100644 GIT binary patch delta 181 zcmZp8z}WDBae_3X#Y7orRtpBbWX6pt3-~#h`2H~PH}d`2EU0jRZ}J&AgZf4$CSC?# zOHpYtVRKw&XGqY6F)D%<8REwk}OQXcBto)3;;`}_I zDu?vk#LOJM&Z aib8NnVo7Q-&;)Zfpp=QZ`Q}FX`Tzj8sWpiJ delta 181 zcmZp8z}WDBae_3X`9v9KR&xfuaIcLi3-~!0`5PJd8~Gk>7F0OEH~Ea5L4C5RWpa{% zMY5ThX`)GzVM?M=vTOHLfM;GxW}=a?k)g4PVWS=+FN3eIvZAoLq_L{FVydA*VoI{HrHN%y gqN!zKQc|j^S*n4ld76cMG0=|9jq>#Y02<#m@Bjb+ diff --git a/main.py b/main.py index b1eea9d..aee2093 100644 --- a/main.py +++ b/main.py @@ -21,9 +21,9 @@ def get_login_details(): no_of_items = 0 else: logged_in = True - cur.execute("SELECT user_id, first_name FROM users WHERE email = '" + session['email'] + "'") + cur.execute("SELECT userId, firstName FROM users WHERE email = '" + session['email'] + "'") user_id, first_name = cur.fetchone() - cur.execute("SELECT count(productId) FROM kart WHERE user_id = " + str(user_id)) + cur.execute("SELECT count(productId) FROM kart WHERE userId = " + str(user_id)) no_of_items = cur.fetchone()[0] conn.close() return (logged_in, first_name, no_of_items) @@ -113,7 +113,7 @@ def edit_profile(): logged_in, first_name, no_of_items = get_login_details() with sqlite3.connect('database.db') as conn: cur = conn.cursor() - cur.execute("SELECT userId, email, first_name, lastName, address1, address2, zipcode, city, state, country, phone FROM users WHERE email = '" + session['email'] + "'") + cur.execute("SELECT userId, email, firstName, lastName, address1, address2, zipcode, city, state, country, phone FROM users WHERE email = '" + session['email'] + "'") profile_data = cur.fetchone() conn.close() return render_template("editProfile.html", profileData=profile_data, loggedIn=logged_in, firstName=first_name, noOfItems=no_of_items) @@ -251,10 +251,10 @@ def remove_from_cart(): product_id = int(request.args.get('productId')) with sqlite3.connect('database.db') as conn: cur = conn.cursor() - cur.execute("SELECT user_id FROM users WHERE email = '" + email + "'") + cur.execute("SELECT userId FROM users WHERE email = '" + email + "'") user_id = cur.fetchone()[0] try: - cur.execute("DELETE FROM kart WHERE user_id = " + str(user_id) + " AND productId = " + str(product_id)) + cur.execute("DELETE FROM kart WHERE userId = " + str(user_id) + " AND productId = " + str(product_id)) conn.commit() msg = "removed successfully" except: From a1aaf71c11d51e35fd61a937415034d5cbc6567e Mon Sep 17 00:00:00 2001 From: TheodoraK7090 Date: Tue, 13 Jun 2023 21:15:22 -0700 Subject: [PATCH 14/14] typos --- main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index b1eea9d..22970df 100644 --- a/main.py +++ b/main.py @@ -77,7 +77,7 @@ def addItem(): conn.commit() msg="Added successfully" except: - msg="Error occured" + msg="Error occurred" conn.rollback() conn.close() print(msg) @@ -169,7 +169,7 @@ def update_profile(): msg = "Saved Successfully" except: con.rollback() - msg = "Error occured" + msg = "Error occurred" con.close() return redirect(url_for('edit_profile')) @@ -222,7 +222,7 @@ def add_to_cart(): msg = "Added successfully" except: conn.rollback() - msg = "Error occured" + msg = "Error occurred" conn.close() return redirect(url_for('root')) @@ -259,7 +259,7 @@ def remove_from_cart(): msg = "removed successfully" except: conn.rollback() - msg = "error occured" + msg = "error occurred" conn.close() return redirect(url_for('root')) @@ -330,7 +330,7 @@ def register(): msg = "Registered Successfully" except: con.rollback() - msg = "Error occured" + msg = "Error occurred" con.close() return render_template("login.html", error=msg)