Updated jinja templates and css to better enable product alteration

This commit is contained in:
Luke Else 2024-01-30 19:05:09 +00:00
parent fa76e11f83
commit faad412809
7 changed files with 98 additions and 60 deletions

View File

@ -27,7 +27,7 @@ h2 {
gap: 1em 1em; gap: 1em 1em;
} }
.input-form input, .input-form select, .input-form option, .input-form textarea { .input-form-row input, .input-form-row select, .input-form-row option, .input-form-row textarea {
width: 100%; width: 100%;
padding: 0 0 0 10px; padding: 0 0 0 10px;
margin: 0; margin: 0;
@ -56,12 +56,12 @@ h2 {
} }
} }
.input-form textarea { .input-form-row textarea {
min-height: 120px; min-height: 120px;
max-width: 100%; max-width: 100%;
} }
.input-form input[type="submit"] { .input-form-row input[type="submit"] {
border: none; border: none;
display:block; display:block;
background-color: rgba(255, 255, 255, .10); background-color: rgba(255, 255, 255, .10);

View File

@ -58,7 +58,7 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: space-between; justify-content: space-between;
gap: 2em 2em; gap: 1em 1em;
padding: .5rem 1rem 2rem 2rem; padding: .5rem 1rem 2rem 2rem;
/* background: var(--bg-secondary); */ /* background: var(--bg-secondary); */
border-radius: .5rem .5rem; border-radius: .5rem .5rem;
@ -90,7 +90,7 @@
.product-details { .product-details {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding: 5% 0; padding: 2% 0;
/* justify-content: center; */ /* justify-content: center; */
/* align-items: center; */ /* align-items: center; */
gap: 1rem 1rem; gap: 1rem 1rem;

View File

@ -3,9 +3,17 @@
<div id="input-form-wrap"> <div id="input-form-wrap">
<h2>Login</h2> <h2>Login</h2>
<form class="input-form" method="POST"> <form class="input-form" method="POST">
<div class="input-form-row">
<input type="text" id="username" name="username" placeholder="Username" required> <input type="text" id="username" name="username" placeholder="Username" required>
</div>
<div class="input-form-row">
<input type="password" id="password" name="password" placeholder="Password" required> <input type="password" id="password" name="password" placeholder="Password" required>
</div>
<div class="input-form-row">
<input type="submit" id="login" value="Login"> <input type="submit" id="login" value="Login">
</div>
</form> </form>
<div id="create-account-wrap"> <div id="create-account-wrap">

View File

@ -8,19 +8,26 @@
<input type="file" id="image" name="image" accept="image/x" required> <input type="file" id="image" name="image" accept="image/x" required>
</div> </div>
<div class="input-form-row">
<textarea id="description" name="description" placeholder="Product Description" required></textarea> <textarea id="description" name="description" placeholder="Product Description" required></textarea>
</div>
<div class="input-form-row">
<select name="category" id="category"> <select name="category" id="category">
{% for category in categories %} {% for category in categories %}
<option value="{{category.id}}">{{category.name}}</option> <option value="{{category.id}}">{{category.name}}</option>
{% endfor %} {% endfor %}
</select> </select>
</div>
<div class="input-form-row"> <div class="input-form-row">
<input type="number" id="cost" name="cost" placeholder=10.99 min=0 step=any required> <input type="number" id="cost" name="cost" placeholder="Cost" min=0 step=0.01 required>
<input type="number" id="quantity" name="quantity" placeholder=0 min=0 required> <input type="number" id="quantity" name="quantity" placeholder="Quantity Available" min=0 required>
</div> </div>
<div class="input-form-row">
<input type="submit" id="Create Product" value="Create Product"> <input type="submit" id="Create Product" value="Create Product">
</div>
</form> </form>
<div id="create-account-wrap"> <div id="create-account-wrap">

View File

@ -1,23 +1,16 @@
<link rel="stylesheet" href="{{ url_for('static', filename='css/products.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='css/products.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/loginform.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='css/loginform.css') }}">
<div class="product-fs"> {% if product != None %}
{% if product != None %}
{% if user.id == product.sellerID %} {% if user.id == product.sellerID %}
<form class="input-form" method="POST" action="/products/update/{{product.id}}" enctype="multipart/form-data"> <form class="product-fs" method="POST" action="/products/update/{{product.id}}" enctype="multipart/form-data">
<div class="product-title"> <img class="product-image" src="{{url_for('static', filename='assets/img/products/' + product.image)}}" alt="Brake Disks"/>
<div class="product-details">
<div class="input-form-row">
<input type="text" id="name" name="name" placeholder="Product Name" value="{{product.name}}" required> <input type="text" id="name" name="name" placeholder="Product Name" value="{{product.name}}" required>
</div> </div>
<div class="product-information">
<div class="product-image">
<img src="{{url_for('static', filename='assets/img/products/' + product.image)}}" alt="Brake Disks" height="auto" width="150px" />
<input type="file" id="image" name="image" accept="image/x">
</div>
<div>
<div class="input-form-row"> <div class="input-form-row">
<input type="number" id="cost" name="cost" placeholder=10.99 min=0 step=any value="{{product.cost}}"required> <textarea id="description" name="description" placeholder="Product Description" required>{{product.description}}</textarea>
<input type="textarea" id="description" name="description" placeholder="Product Description" value="{{product.description}}" required>
</div> </div>
<div class="input-form-row"> <div class="input-form-row">
@ -33,14 +26,34 @@
</div> </div>
<div class="input-form-row"> <div class="input-form-row">
<input type="number" id="quantity" name="quantity" placeholder=0 min=0 value="{{product.quantityAvailable}}" required> <input type="file" id="image" name="image" accept="image/x">
</div>
<div class="input-form-row">
<input type="submit" id="Create Product" value="Update Product">
</div> </div>
</div> </div>
<div class="product-acquisition-pane">
<div class="input-form-row">
<input type="number" id="cost" name="cost" placeholder="Cost" min=0 step=0.01 value="{{product.cost}}"required>
</div> </div>
<input type="submit" id="Create Product" value="Create Product"> <div class="product-delivery">Earliest Delivery Friday 24th December</div>
</form> <div class="product-postage">+£{{product.cost}} P&P</div>
<div class="product-add-to-cart"></div> <div class="product-stock">
<div class="input-form-row">
<input type="number" id="quantity" name="quantity" placeholder="Quantity Available" min=0 value="{{product.quantityAvailable}}" required>
</div>
{% if product.quantityAvailable > 0 %}
<div class="product-instock">In Stock</div>
<div class="product-quantity">{{product.quantityAvailable}} Available</div>
{% else %} {% else %}
<div class="product-nostock">Out of Stock</div>
{% endif %}
</div>
</div>
</form>
{% else %}
<div class="product-fs">
<img class="product-image" src="{{url_for('static', filename='assets/img/products/' + product.image)}}" alt="Brake Disks"/> <img class="product-image" src="{{url_for('static', filename='assets/img/products/' + product.image)}}" alt="Brake Disks"/>
<div class="product-details"> <div class="product-details">
<div class="product-title">{{product.name}}</div> <div class="product-title">{{product.name}}</div>
@ -60,6 +73,8 @@
{% endif %} {% endif %}
</div> </div>
</div> </div>
</div>
{% endif %} {% endif %}
{% endif %} {% endif %}
</div>

View File

@ -13,12 +13,18 @@
<input type="email" id="email" name="email" placeholder="Email Address" required> <input type="email" id="email" name="email" placeholder="Email Address" required>
</div> </div>
<div class="input-form-row">
<input type="password" id="password" name="password" minlength=8 placeholder="Password" required> <input type="password" id="password" name="password" minlength=8 placeholder="Password" required>
</div>
<label class="checkbox">Signup as a Seller? <label class="checkbox">Signup as a Seller?
<input type="checkbox" id="seller" name="seller"/> <input type="checkbox" id="seller" name="seller"/>
<span class="checkmark"></span> <span class="checkmark"></span>
</label> </label>
<div class="input-form-row">
<input type="submit" id="Sign Up" value="Sign Up"> <input type="submit" id="Sign Up" value="Sign Up">
</div>
</form> </form>
<div id="create-account-wrap"> <div id="create-account-wrap">

View File

@ -2,7 +2,7 @@ import os
import uuid import uuid
import pathlib import pathlib
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'} ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif', 'bmp'}
def allowed_file(filename) -> bool: def allowed_file(filename) -> bool:
@ -44,3 +44,5 @@ def remove_file(dir: str):
os.remove(dir) os.remove(dir)
except FileNotFoundError: except FileNotFoundError:
pass pass
except IsADirectoryError:
pass