Skip to content

Commit

Permalink
Added categories
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshShah1997 committed Aug 11, 2016
1 parent 8ab416c commit d0a88cb
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 43 deletions.
Binary file modified database.db
Binary file not shown.
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ def root():
cur = conn.cursor()
cur.execute('SELECT productId, name, price, description, image, stock FROM products')
itemData = cur.fetchall()
cur.execute('SELECT categoryId, name FROM categories')
categoryData = cur.fetchall()

return render_template('home.html', data=itemData, loggedIn=loggedIn, firstName=firstName, noOfItems=noOfItems)
return render_template('home.html', data=itemData, loggedIn=loggedIn, firstName=firstName, noOfItems=noOfItems, categoryData=categoryData)

@app.route("/add")
def admin():
Expand Down
5 changes: 4 additions & 1 deletion static/css/home.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
width: 150px;
}

#display {
.display {
margin-top: 20px;
margin-left: 20px;
margin-right: 20px;
Expand All @@ -24,3 +24,6 @@ table {
text-align: center;
}

.displayCategory ul li {
font-size: 20px;
}
9 changes: 3 additions & 6 deletions static/css/productDescription.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,15 @@
margin-top: 20px;
margin-bottom: 20px;
display: inline-block;
}

#descriptionTable {
border: 1px solid black;
font-size: 20px;
font-size: 19px;
}

#descriptionTable td {
border: 1px solid black;
width: 150px;
}

#addToCart {
font-size: 20px;
}


80 changes: 45 additions & 35 deletions templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,57 +8,67 @@
<body>
<div id="title">
<a href="/">
<img id="logo" src= {{ url_for('static', filename='images/logo.png') }} />
<img id="logo" src= {{ url_for('static', filename='images/logo.png') }} />
</a>
<form>
<input id="searchBox" type="text" name="searchQuery">
<input id="searchButton" type="submit" value="Search">
</form>

{% if not loggedIn %}
<div id="signInButton">
<a class="link" href="/loginForm">Sign In</a>
</div>
<div id="signInButton">
<a class="link" href="/loginForm">Sign In</a>
</div>
{% else %}
<div id="displayUserId">Hello, <br>{{firstName}}</div>
<div id="signInButton">
<a class="link" href="/logout">Sign Out</a>
</div>
<div id="signInButton">
<a class="link" href="/logout">Sign Out</a>
</div>
{% endif %}
<div id="kart">
<a class="link" href="/cart">
<img src={{url_for('static', filename='images/shoppingCart.png')}} id="cartIcon" />
CART {{noOfItems}}
<img src={{url_for('static', filename='images/shoppingCart.png')}} id="cartIcon" />
CART {{noOfItems}}
</a>
</div>
</div>
<div id="display">
<h2>Items</h2>
<table>
<tr id="productName">
{% for row in data %}
<td>
{{row[1]}}
</td>
{% endfor %}
</tr>
<tr id="productImage">
{% for row in data %}
<td>
<a href="/productDescription?productId={{row[0]}}">
<img src={{ url_for('static', filename='uploads/' + row[4]) }} id="itemImage" />
</a>
</td>
<div class="display">
<div class="displayCategory">
<h2>Shop by Category: </h2>
<ul>
{% for row in categoryData %}
<li><a href="/displayCategory?categoryId={{row[0]}}">{{row[1]}}</a></li>
{% endfor %}
</tr>
<tr id="productPrice">
{% for row in data %}
<td>
${{row[2]}}
</td>
{% endfor %}
</tr>
</table>
</ul>
</div>
<div>
<h2>Items</h2>
<table>
<tr id="productName">
{% for row in data %}
<td>
{{row[1]}}
</td>
{% endfor %}
</tr>
<tr id="productImage">
{% for row in data %}
<td>
<a href="/productDescription?productId={{row[0]}}">
<img src={{ url_for('static', filename='uploads/' + row[4]) }} id="itemImage" />
</a>
</td>
{% endfor %}
</tr>
<tr id="productPrice">
{% for row in data %}
<td>
${{row[2]}}
</td>
{% endfor %}
</tr>
</table>
</div>
</div>
</body>
</html>
Expand Down

0 comments on commit d0a88cb

Please sign in to comment.