From 1e45e233377b1d3d8efa0dabe831ff870111a5da Mon Sep 17 00:00:00 2001
From: Michael Drury <mpdrury15@gmail.com>
Date: Wed, 3 May 2023 12:58:16 +0100
Subject: [PATCH] added more comments

---
 instance/app.db | Bin 20480 -> 20480 bytes
 shop/routes.py  |  13 ++++++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/instance/app.db b/instance/app.db
index 658026cda18b1026ae13d2ff7edef976e8e77d5c..daa0cc1a7bd4ab7fc7735ff015c0e1881f1dcead 100644
GIT binary patch
delta 339
zcmXYrJx)SF6h?U_B-;4$3T;pU^Gqz~_s&c!F%oFR#Gsw`&D;qD5JOCmj@k;s28cT_
z?7-Ruunc#g6n5V^ImI_$C-Zf(s3h6)q>*HwPhY3Y#eDT~cHS{+_$K^dGVMOzJhaA`
zOO8qgW{ZLY5rjZswL?PhDRAyIx6T&U%3UZhasi&SQwW{~7HqLPs^*<pv#XwEla#xL
zR^#d=XWAoU9vwJ?6d|A%7Hwcqpyfgrh{ka5Q9C0+P&Agb(!xX32+FPAs~5M8c3Teb
z`J`pXcQZ2zxt7Y1@<Q<7SVSnI!r)94s0|MojVCE3+ih}DSO=kC-gr(9V0U=)TP@f2
t_tI@C{Ykf*toEH=9`BV)2lYz-wKg431{CU}zV9Io50jnGD!u+c{{b0bV@Lo1

delta 405
zcmb`DyG{Z@7=>9AOM?_7CMXcIHdZ_L`Af6JP6H8&wZWNxW<-P#FCcc<QbG0wh%aCa
zZ{QR7M!Jn}U`}(2FFE<nViPSk(W(~p*N17;|GfD+Iw&vyQkvJ^vc1aq4hP1M@{fA;
zs-0$!y(d0Dn~3XCOFqYmW)^*LRO^Ij<_Ke8!E<2|n74#*iBhuQ5TzACaOtTdoCt~3
zQNc(vf3F{RM0P)u52HzMm~~&fFBfrwV9;8k6iIy1B)7~94uWe#C0J#Gz#sq+96Ie-
z@Q$j)7PKSYg}mB`JFQ7JCYLFjo)4z!P~XNn0F%Xj5<CcxiYm&v<t|We7-QN8iAcd2
o5K2l_xKNJ<l%|A&MUyWZC++|KVEfb9ZSIuzx0U91dA&OQ1@!xO4gdfE

diff --git a/shop/routes.py b/shop/routes.py
index ad6f95d..e5ecb73 100644
--- a/shop/routes.py
+++ b/shop/routes.py
@@ -151,6 +151,7 @@ def cart():
 
     # gets the total price of the cart and then decides on if the user is allowed free shipping and if not adds
     # shipping cost to the final price
+    # repeated in checkout as need some of the variables created in the code to pass into template
 
     total_price = get_total_cart_price()
 
@@ -197,6 +198,7 @@ def wishlist():
                 c.wishlist = ''
             db.session.commit()
         return redirect(url_for('wishlist'))
+
     return render_template('wishlist.html', wishlist_list = wishlist_list, wishlist_size = len(wishlist_list), remove_form = remove_form)
 
 
@@ -224,10 +226,11 @@ def item_page():
 
         review_form = reviewForm()
 
+        # adds the review to the reviews database as well as the authors id
+
         if review_form.validate_on_submit():
             review_in = review_form.review.data
-            for c in db.session.query(User).filter_by(id=current_user.get_id()):
-                current_user_username = c.username
+            current_user_username = current_user.username
             review_table.new_review(review_in=review_in, product_id_in=product_in.product_id, author_in = current_user_username)
 
         reviews = review_table.query.filter_by(product_id=product_in.product_id)
@@ -252,6 +255,10 @@ def checkout():
     # gets the total price of items using the get_total_price function
     total_price = get_total_cart_price()
 
+    # gets the total price of the cart and then decides on if the user is allowed free shipping and if not adds
+    # shipping cost to the final price
+    # repeated in cart as need some of the variables created in the code to pass into template
+
     free_shipping = False
     shipping_price = 14.99
     if total_price >= 2000:
@@ -279,7 +286,7 @@ def get_total_cart_price():
         total_price += item.product_price
     return total_price
 
-
+# just takes you to the thank you page
 @app.route('/thank_you', methods=['GET', 'POST'])
 @login_required
 def thank_you():
-- 
GitLab