diff --git a/.idea/CNA340_FinalProject.iml b/.idea/CNA340_FinalProject.iml deleted file mode 100644 index 86bd522..0000000 --- a/.idea/CNA340_FinalProject.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/shoppingcart.iml b/.idea/CNE310_FinalProject.iml similarity index 69% rename from .idea/shoppingcart.iml rename to .idea/CNE310_FinalProject.iml index 6711606..8fe898a 100644 --- a/.idea/shoppingcart.iml +++ b/.idea/CNE310_FinalProject.iml @@ -5,7 +5,4 @@ - - - \ No newline at end of file + diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..cc5462d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + diff --git a/.idea/misc.xml b/.idea/misc.xml index a31d283..55e5b97 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - - \ No newline at end of file + + diff --git a/.idea/modules.xml b/.idea/modules.xml index 15fe6e4..4c672b4 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,7 @@ - + - \ No newline at end of file + diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_6_16_2021_2_42_PM_[Default_Changelist]/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Update_at_6_16_2021_2_42_PM_[Default_Changelist]/shelved.patch new file mode 100644 index 0000000..5d4a59c --- /dev/null +++ b/.idea/shelf/Uncommitted_changes_before_Update_at_6_16_2021_2_42_PM_[Default_Changelist]/shelved.patch @@ -0,0 +1,644 @@ +Index: main.py +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP +<+># This creates a basic eCommerce website using Flask and SQLite\r\n# Zachary Rubin, zrubin@rtc.edu\r\n# CNA 340 Spring 2019\r\n\r\nfrom flask import *\r\nimport sqlite3, hashlib, os\r\nfrom werkzeug.utils import secure_filename\r\n\r\napp = Flask(__name__)\r\napp.secret_key = 'cna340'\r\nUPLOAD_FOLDER = 'static/uploads'\r\nALLOWED_EXTENSIONS = set(['jpeg', 'jpg', 'png', 'gif'])\r\napp.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER\r\n\r\ndef get_login_details():\r\n with sqlite3.connect('database.db') as conn:\r\n cur = conn.cursor()\r\n if 'email' not in session:\r\n logged_in = False\r\n first_name = ''\r\n no_of_items = 0\r\n else:\r\n logged_in = True\r\n cur.execute(\"SELECT user_id, first_name FROM users WHERE email = '\" + session['email'] + \"'\")\r\n user_id, first_name = cur.fetchone()\r\n cur.execute(\"SELECT count(productId) FROM kart WHERE user_id = \" + str(user_id))\r\n no_of_items = cur.fetchone()[0]\r\n conn.close()\r\n return (logged_in, first_name, no_of_items)\r\n\r\n@app.route(\"/\")\r\ndef root():\r\n logged_in, first_name, no_of_items = get_login_details()\r\n with sqlite3.connect('database.db') as conn:\r\n cur = conn.cursor()\r\n # Show last product added\r\n cur.execute('SELECT productId, name, price, description, image, stock FROM products ORDER BY productId DESC LIMIT 1 ')\r\n # Show all items\r\n #cur.execute('SELECT productId, name, price, description, image, stock FROM products LIMIT 1')\r\n item_data = cur.fetchall()\r\n # Show an error instead of the categories\r\n category_data = [(-1,\"Error\")]\r\n # Show all categories\r\n #cur.execute('SELECT categoryId, name FROM categories')\r\n #category_data = cur.fetchall()\r\n item_data = parse(item_data)\r\n return render_template('home.html', itemData=item_data, loggedIn=logged_in, firstName=first_name, noOfItems=no_of_items, categoryData=category_data)\r\n\r\n@app.route(\"/add\")\r\ndef admin():\r\n with sqlite3.connect('database.db') as conn:\r\n cur = conn.cursor()\r\n cur.execute(\"SELECT categoryId, name FROM categories\")\r\n categories = cur.fetchall()\r\n conn.close()\r\n return render_template('add.html', categories=categories)\r\n\r\n@app.route(\"/addItem\", methods=[\"GET\", \"POST\"])\r\ndef addItem():\r\n if request.method == \"POST\":\r\n name = request.form['name']\r\n price = float(request.form['price'])\r\n description = request.form['description']\r\n stock = int(request.form['stock'])\r\n categoryId = int(request.form['category'])\r\n\r\n #Upload image\r\n image = request.files['image']\r\n if image and allowed_file(image.filename):\r\n filename = secure_filename(image.filename)\r\n image.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))\r\n imagename = filename\r\n with sqlite3.connect('database.db') as conn:\r\n try:\r\n cur = conn.cursor()\r\n cur.execute('''INSERT INTO products (name, price, description, image, stock, categoryId) VALUES (?, ?, ?, ?, ?, ?)''', (name, price, description, imagename, stock, categoryId))\r\n conn.commit()\r\n msg=\"Added successfully\"\r\n except:\r\n msg=\"Error occured\"\r\n conn.rollback()\r\n conn.close()\r\n print(msg)\r\n return redirect(url_for('root'))\r\n\r\n@app.route(\"/displayCategory\")\r\ndef displayCategory():\r\n logged_in, first_name, no_of_items = get_login_details()\r\n category_id = request.args.get(\"categoryId\")\r\n with sqlite3.connect('database.db') as conn:\r\n cur = conn.cursor()\r\n cur.execute(\r\n \"SELECT products.productId, products.name, products.price, products.image, categories.name FROM products, categories WHERE products.categoryId = categories.categoryId AND categories.categoryId = \" + category_id)\r\n data = cur.fetchall()\r\n conn.close()\r\n category_name = data[0][4]\r\n data = parse(data)\r\n return render_template('displayCategory.html', data=data, loggedIn=logged_in, firstName=first_name,\r\n noOfItems=no_of_items, categoryName=category_name)\r\n\r\n\r\n@app.route(\"/account/profile\")\r\ndef profile_home():\r\n if 'email' not in session:\r\n return redirect(url_for('root'))\r\n logged_in, first_name, no_of_items = get_login_details()\r\n return render_template(\"profileHome.html\", loggedIn=logged_in, firstName=first_name, noOfItems=no_of_items)\r\n\r\n@app.route(\"/account/profile/edit\")\r\ndef edit_profile():\r\n if 'email' not in session:\r\n return redirect(url_for('root'))\r\n logged_in, first_name, no_of_items = get_login_details()\r\n with sqlite3.connect('database.db') as conn:\r\n cur = conn.cursor()\r\n cur.execute(\"SELECT userId, email, first_name, lastName, address1, address2, zipcode, city, state, country, phone FROM users WHERE email = '\" + session['email'] + \"'\")\r\n profile_data = cur.fetchone()\r\n conn.close()\r\n return render_template(\"editProfile.html\", profileData=profile_data, loggedIn=logged_in, firstName=first_name, noOfItems=no_of_items)\r\n\r\n@app.route(\"/account/profile/changePassword\", methods=[\"GET\", \"POST\"])\r\ndef change_password():\r\n if 'email' not in session:\r\n return redirect(url_for('login_form'))\r\n if request.method == \"POST\":\r\n old_password = request.form['oldpassword']\r\n old_password = hashlib.md5(old_password.encode()).hexdigest()\r\n new_password = request.form['newpassword']\r\n new_password = hashlib.md5(new_password.encode()).hexdigest()\r\n with sqlite3.connect('database.db') as conn:\r\n cur = conn.cursor()\r\n cur.execute(\"SELECT userId, password FROM users WHERE email = '\" + session['email'] + \"'\")\r\n user_id, password = cur.fetchone()\r\n if (password == old_password):\r\n try:\r\n cur.execute(\"UPDATE users SET password = ? WHERE userId = ?\", (new_password, user_id))\r\n conn.commit()\r\n msg=\"Changed successfully\"\r\n except:\r\n conn.rollback()\r\n msg = \"Failed\"\r\n return render_template(\"changePassword.html\", msg=msg)\r\n else:\r\n msg = \"Wrong password\"\r\n conn.close()\r\n return render_template(\"changePassword.html\", msg=msg)\r\n else:\r\n return render_template(\"changePassword.html\")\r\n\r\n@app.route(\"/updateProfile\", methods=[\"GET\", \"POST\"])\r\ndef update_profile():\r\n if request.method == 'POST':\r\n email = request.form['email']\r\n first_name = request.form['firstName']\r\n last_name = request.form['lastName']\r\n address1 = request.form['address1']\r\n address2 = request.form['address2']\r\n zipcode = request.form['zipcode']\r\n city = request.form['city']\r\n state = request.form['state']\r\n country = request.form['country']\r\n phone = request.form['phone']\r\n with sqlite3.connect('database.db') as con:\r\n try:\r\n cur = con.cursor()\r\n cur.execute('UPDATE users SET firstName = ?, lastName = ?, address1 = ?, address2 = ?, zipcode = ?, city = ?, state = ?, country = ?, phone = ? WHERE email = ?', (first_name, last_name, address1, address2, zipcode, city, state, country, phone, email))\r\n\r\n con.commit()\r\n msg = \"Saved Successfully\"\r\n except:\r\n con.rollback()\r\n msg = \"Error occured\"\r\n con.close()\r\n return redirect(url_for('edit_profile'))\r\n\r\n@app.route(\"/loginForm\")\r\ndef login_form():\r\n # Uncomment to enable logging in and registration\r\n #if 'email' in session:\r\n return redirect(url_for('root'))\r\n #else:\r\n # return render_template('login.html', error='')\r\n\r\n@app.route(\"/login\", methods = ['POST', 'GET'])\r\ndef login():\r\n if request.method == 'POST':\r\n email = request.form['email']\r\n password = request.form['password']\r\n if is_valid(email, password):\r\n session['email'] = email\r\n return redirect(url_for('root'))\r\n else:\r\n error = 'Invalid UserId / Password'\r\n return render_template('login.html', error=error)\r\n\r\n@app.route(\"/productDescription\")\r\ndef product_description():\r\n logged_in, first_name, no_of_items = get_login_details()\r\n product_id = request.args.get('productId')\r\n with sqlite3.connect('database.db') as conn:\r\n cur = conn.cursor()\r\n cur.execute(\r\n 'SELECT productId, name, price, description, image, stock FROM products WHERE productId = ' + product_id)\r\n productData = cur.fetchone()\r\n conn.close()\r\n return render_template(\"productDescription.html\", data=productData, loggedIn=logged_in, firstName=first_name,\r\n noOfItems=no_of_items)\r\n\r\n@app.route(\"/addToCart\")\r\ndef add_to_cart():\r\n if 'email' not in session:\r\n return redirect(url_for('login_form'))\r\n else:\r\n product_id = int(request.args.get('productId'))\r\n with sqlite3.connect('database.db') as conn:\r\n cur = conn.cursor()\r\n cur.execute(\"SELECT userId FROM users WHERE email = '\" + session['email'] + \"'\")\r\n user_id = cur.fetchone()[0]\r\n try:\r\n cur.execute(\"INSERT INTO kart (userId, productId) VALUES (?, ?)\", (user_id, product_id))\r\n conn.commit()\r\n msg = \"Added successfully\"\r\n except:\r\n conn.rollback()\r\n msg = \"Error occured\"\r\n conn.close()\r\n return redirect(url_for('root'))\r\n\r\n@app.route(\"/cart\")\r\ndef cart():\r\n if 'email' not in session:\r\n return redirect(url_for('login_form'))\r\n logged_in, first_name, no_of_items = get_login_details()\r\n email = session['email']\r\n with sqlite3.connect('database.db') as conn:\r\n cur = conn.cursor()\r\n cur.execute(\"SELECT userId FROM users WHERE email = '\" + email + \"'\")\r\n user_id = cur.fetchone()[0]\r\n cur.execute(\"SELECT products.productId, products.name, products.price, products.image FROM products, kart WHERE products.productId = kart.productId AND kart.userId = \" + str(user_id))\r\n products = cur.fetchall()\r\n total_price = 0\r\n for row in products:\r\n total_price += row[2]\r\n return render_template(\"cart.html\", products = products, totalPrice=total_price, loggedIn=logged_in, firstName=first_name, noOfItems=no_of_items)\r\n\r\n@app.route(\"/removeFromCart\")\r\ndef remove_from_cart():\r\n if 'email' not in session:\r\n return redirect(url_for('login_form'))\r\n email = session['email']\r\n product_id = int(request.args.get('productId'))\r\n with sqlite3.connect('database.db') as conn:\r\n cur = conn.cursor()\r\n cur.execute(\"SELECT user_id FROM users WHERE email = '\" + email + \"'\")\r\n user_id = cur.fetchone()[0]\r\n try:\r\n cur.execute(\"DELETE FROM kart WHERE user_id = \" + str(user_id) + \" AND productId = \" + str(product_id))\r\n conn.commit()\r\n msg = \"removed successfully\"\r\n except:\r\n conn.rollback()\r\n msg = \"error occured\"\r\n conn.close()\r\n return redirect(url_for('root'))\r\n\r\n@app.route(\"/logout\")\r\ndef logout():\r\n session.pop('email', None)\r\n return redirect(url_for('root'))\r\n\r\ndef is_valid(email, password):\r\n con = sqlite3.connect('database.db')\r\n cur = con.cursor()\r\n cur.execute('SELECT email, password FROM users')\r\n data = cur.fetchall()\r\n for row in data:\r\n if row[0] == email and row[1] == hashlib.md5(password.encode()).hexdigest():\r\n return True\r\n return False\r\n\r\n\r\n@app.route(\"/checkout\", methods=['GET','POST'])\r\ndef payment():\r\n if 'email' not in session:\r\n return redirect(url_for('login_form'))\r\n logged_in, first_name, no_of_items = get_login_details()\r\n email = session['email']\r\n\r\n with sqlite3.connect('database.db') as conn:\r\n cur = conn.cursor()\r\n cur.execute(\"SELECT userId FROM users WHERE email = '\" + email + \"'\")\r\n user_id = cur.fetchone()[0]\r\n cur.execute(\"SELECT products.productId, products.name, products.price, products.image FROM products, kart WHERE products.productId = kart.productId AND kart.userId = \" + str(user_id))\r\n products = cur.fetchall()\r\n total_price = 0\r\n for row in products:\r\n total_price += row[2]\r\n print(row)\r\n cur.execute(\"INSERT INTO Orders (userId, productId) VALUES (?, ?)\", (user_id, row[0]))\r\n cur.execute(\"DELETE FROM kart WHERE userId = \" + str(user_id))\r\n conn.commit()\r\n\r\n \r\n\r\n return render_template(\"checkout.html\", products = products, totalPrice=total_price, loggedIn=logged_in, firstName=first_name, noOfItems=no_of_items)\r\n\r\n@app.route(\"/register\", methods = ['GET', 'POST'])\r\ndef register():\r\n if request.method == 'POST':\r\n #Parse form data \r\n password = request.form['password']\r\n email = request.form['email']\r\n first_name = request.form['firstName']\r\n last_name = request.form['lastName']\r\n address1 = request.form['address1']\r\n address2 = request.form['address2']\r\n zipcode = request.form['zipcode']\r\n city = request.form['city']\r\n state = request.form['state']\r\n country = request.form['country']\r\n phone = request.form['phone']\r\n\r\n with sqlite3.connect('database.db') as con:\r\n try:\r\n cur = con.cursor()\r\n cur.execute('INSERT INTO users (password, email, firstName, lastName, address1, address2, zipcode, city, state, country, phone) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', (hashlib.md5(password.encode()).hexdigest(), email, first_name, last_name, address1, address2, zipcode, city, state, country, phone))\r\n\r\n con.commit()\r\n\r\n msg = \"Registered Successfully\"\r\n except:\r\n con.rollback()\r\n msg = \"Error occured\"\r\n con.close()\r\n return render_template(\"login.html\", error=msg)\r\n\r\n@app.route(\"/registrationForm\")\r\ndef registration_form():\r\n return render_template(\"register.html\")\r\n\r\ndef allowed_file(filename):\r\n return '.' in filename and \\\r\n filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS\r\n\r\ndef parse(data):\r\n ans = []\r\n i = 0\r\n while i < len(data):\r\n curr = []\r\n for j in range(7):\r\n if i >= len(data):\r\n break\r\n curr.append(data[i])\r\n i += 1\r\n ans.append(curr)\r\n return ans\r\n\r\nif __name__ == '__main__':\r\n app.run(debug=True)\r\n +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/main.py b/main.py +--- a/main.py (revision 0d60e133b958354ab390b97a8b1cd9951fc79e80) ++++ b/main.py (date 1623638514950) +@@ -176,10 +176,10 @@ + @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(): +Index: .idea/shoppingcart.iml +=================================================================== +diff --git a/.idea/shoppingcart.iml b/.idea/shoppingcart.iml +deleted file mode 100644 +--- a/.idea/shoppingcart.iml (revision 0d60e133b958354ab390b97a8b1cd9951fc79e80) ++++ /dev/null (revision 0d60e133b958354ab390b97a8b1cd9951fc79e80) +@@ -1,11 +0,0 @@ +- +- +- +- +- +- +- +- +- +- +\ No newline at end of file +Index: .idea/CNA340_FinalProject.iml +=================================================================== +diff --git a/.idea/CNA340_FinalProject.iml b/.idea/CNA340_FinalProject.iml +deleted file mode 100644 +--- a/.idea/CNA340_FinalProject.iml (revision 0d60e133b958354ab390b97a8b1cd9951fc79e80) ++++ /dev/null (revision 0d60e133b958354ab390b97a8b1cd9951fc79e80) +@@ -1,13 +0,0 @@ +- +- +- +- +- +- +- +- +- +- +- +- +\ No newline at end of file +Index: .idea/CNE310_FinalProject.iml +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/.idea/CNE310_FinalProject.iml b/.idea/CNE310_FinalProject.iml +new file mode 100644 +--- /dev/null (date 1623628053578) ++++ b/.idea/CNE310_FinalProject.iml (date 1623628053578) +@@ -0,0 +1,8 @@ ++ ++ ++ ++ ++ ++ ++ ++ +\ No newline at end of file +Index: .idea/modules.xml +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP +<+>\r\n\r\n \r\n \r\n \r\n \r\n \r\n +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/.idea/modules.xml b/.idea/modules.xml +--- a/.idea/modules.xml (revision 0d60e133b958354ab390b97a8b1cd9951fc79e80) ++++ b/.idea/modules.xml (date 1623628053605) +@@ -2,7 +2,7 @@ + + + +- ++ + + + +\ No newline at end of file +Index: .idea/workspace.xml +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP +<+>\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n 1521184065947\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/.idea/workspace.xml b/.idea/workspace.xml +--- a/.idea/workspace.xml (revision 0d60e133b958354ab390b97a8b1cd9951fc79e80) ++++ b/.idea/workspace.xml (date 1623879685131) +@@ -1,198 +1,47 @@ + + + +- +- ++ ++ ++ ++ ++ ++ ++ ++ ++ + +- +- +- +- +- +- +- +- +- ++ ++ ++ ++ + +- +- +- +- ++ ++ ++ ++ + +- +- +- +- +- +- ++ ++ ++ + +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- + + + +- + + + +- +- +- ++ + + +- +- 1521184065947 ++ ++ 1623627843759 + + + +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- ++ ++ ++ + +\ No newline at end of file +Index: .idea/misc.xml +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP +<+>\r\n\r\n \r\n +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/.idea/misc.xml b/.idea/misc.xml +--- a/.idea/misc.xml (revision 0d60e133b958354ab390b97a8b1cd9951fc79e80) ++++ b/.idea/misc.xml (date 1623628053710) +@@ -1,4 +1,4 @@ + + +- ++ + +\ No newline at end of file +Index: .idea/inspectionProfiles/profiles_settings.xml +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml +new file mode 100644 +--- /dev/null (date 1623628053793) ++++ b/.idea/inspectionProfiles/profiles_settings.xml (date 1623628053793) +@@ -0,0 +1,6 @@ ++ ++ ++ ++ +\ No newline at end of file diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_6_16_2021_2_42_PM__Default_Changelist_.xml b/.idea/shelf/Uncommitted_changes_before_Update_at_6_16_2021_2_42_PM__Default_Changelist_.xml new file mode 100644 index 0000000..26b23e9 --- /dev/null +++ b/.idea/shelf/Uncommitted_changes_before_Update_at_6_16_2021_2_42_PM__Default_Changelist_.xml @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 61919bd..fd05ab2 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,198 +1,46 @@ - - + + + + + + + + - - - - - - - - - + + + + - - - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - + - - 1521184065947 + + 1623627843759 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + \ No newline at end of file diff --git a/main.py b/main.py index 67fb91b..85e9ef6 100644 --- a/main.py +++ b/main.py @@ -41,8 +41,8 @@ def root(): # Show an error instead of the categories 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) @@ -93,7 +93,7 @@ def displayCategory(): "SELECT products.productId, products.name, products.price, products.image, categories.name FROM products, categories WHERE products.categoryId = categories.categoryId AND categories.categoryId = " + category_id) data = cur.fetchall() conn.close() - category_name = data[0][4] + category_name = data[0:] data = parse(data) return render_template('displayCategory.html', data=data, loggedIn=logged_in, firstName=first_name, noOfItems=no_of_items, categoryName=category_name) @@ -131,7 +131,7 @@ def change_password(): cur = conn.cursor() cur.execute("SELECT userId, password FROM users WHERE email = '" + session['email'] + "'") user_id, password = cur.fetchone() - if (password == old_password): + if (password == old_password): try: cur.execute("UPDATE users SET password = ? WHERE userId = ?", (new_password, user_id)) conn.commit() @@ -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(): @@ -357,3 +357,5 @@ def parse(data): if __name__ == '__main__': app.run(debug=True) + +