From f0c0cba2c289f20fecef7ce49c3e3703ffdfd3d8 Mon Sep 17 00:00:00 2001
From: b4-sharp <Bradley2.Sharp@live.uwe.ac.uk>
Date: Fri, 14 Apr 2023 04:48:06 +0100
Subject: [PATCH] Add comments, improve page names

---
 store/routes.py                | 4 ++--
 store/templates/item_page.html | 1 -
 store/templates/items.html     | 3 +++
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/store/routes.py b/store/routes.py
index 35dda03..af7f173 100644
--- a/store/routes.py
+++ b/store/routes.py
@@ -99,7 +99,7 @@ def item_sets():
     return render_template("items.html", title="Item Sets", items=items)
 
 
-@app.route("/item_page/item_<int:item_id>")
+@app.route("/item_<int:item_id>")
 def item_page(item_id):
     item = get_item_by_id(item_id)
     if not item:
@@ -108,7 +108,7 @@ def item_page(item_id):
     return render_template("item_page.html", item=item)
 
 
-@app.route("/item_set_page/item_set_<int:item_id>")
+@app.route("/item_set_<int:item_id>")
 def item_set_page(item_id):
     item = get_item_set_by_id(item_id)
     if not item:
diff --git a/store/templates/item_page.html b/store/templates/item_page.html
index 0eb54ca..d6fb4c7 100644
--- a/store/templates/item_page.html
+++ b/store/templates/item_page.html
@@ -1,5 +1,4 @@
 {%extends 'base.html' %}
-
 {% block content %}
 {% block title %} Item Page | Antiques Online {% endblock %}
 <div>
diff --git a/store/templates/items.html b/store/templates/items.html
index de28bb7..0dbf2ec 100644
--- a/store/templates/items.html
+++ b/store/templates/items.html
@@ -12,6 +12,9 @@
           style="width: 200px; height: 200px;"> <!-- Set image size to ensure content is always fitting. -->
         <h2>{{ item.description }}</h2>
         <p>£{{ item.price }}</p>
+        <!-- Ternary operator to genericise the page to sets and items. Because of python shenanigans trying 
+        to access an attribute that doesn't actually exist doesn't neccesarily cause an immediate exception and
+        so this can be used to check if the object is an item or item set.-->
         <a
           href="{{url_for('item_set_page', item_id = item.id) if item.items else url_for('item_page', item_id = item.id)}}">View
           Details</a>
-- 
GitLab