Fixed more data types
This commit is contained in:
parent
d314da9551
commit
fec137280c
17
app.py
17
app.py
@ -15,7 +15,7 @@ with app.app_context():
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return redirect('/view')
|
||||
return redirect('/viewall')
|
||||
|
||||
|
||||
@app.route('/create/', methods=['GET', 'POST'])
|
||||
@ -43,10 +43,10 @@ def create():
|
||||
except exc.StatementError:
|
||||
return render_template('create.html', exc='status')
|
||||
|
||||
return redirect('/view')
|
||||
return redirect('/viewall')
|
||||
|
||||
|
||||
@app.route('/view/', methods=['GET', 'POST'])
|
||||
@app.route('/viewall/', methods=['GET', 'POST'])
|
||||
def view_list():
|
||||
if request.method == 'POST':
|
||||
outfile = open('inventory_export.csv', 'w', newline='')
|
||||
@ -77,10 +77,9 @@ def update(assettag):
|
||||
assettag = request.form['assettag']
|
||||
hostname = request.form['hostname']
|
||||
warrantyfrom = request.form['warrantyfrom']
|
||||
try:
|
||||
status = float(request.form['status'])
|
||||
except ValueError:
|
||||
return render_template('update.html', item=item, exc='status')
|
||||
status = request.form['status']
|
||||
if status not in ['Active', 'Inactive']:
|
||||
return render_template('update.html', item=item, exc='status') # Ensure status is valid
|
||||
try:
|
||||
staffnum = int(request.form['staffnum'])
|
||||
except ValueError:
|
||||
@ -99,7 +98,7 @@ def update(assettag):
|
||||
except (exc.StatementError, exc.InvalidRequestError) as e:
|
||||
return render_template('update.html', item=item, exc='status')
|
||||
|
||||
return redirect(f'/view/')
|
||||
return redirect(f'/viewall/')
|
||||
return f"Asset {assettag} is not found"
|
||||
|
||||
return render_template('update.html', item=item)
|
||||
@ -112,7 +111,7 @@ def delete(assettag):
|
||||
if item:
|
||||
db.session.delete(item)
|
||||
db.session.commit()
|
||||
return redirect('/view')
|
||||
return redirect('/viewall')
|
||||
abort(404)
|
||||
|
||||
return render_template('delete.html')
|
||||
|
@ -29,7 +29,7 @@
|
||||
</p>
|
||||
<p>
|
||||
<label for="warrantyfrom">Warranty From:</label>
|
||||
<input id="warrantyfrom" type = "text" name = "warrantyfrom" required/>
|
||||
<input id="warrantyfrom" type = "date" name = "warrantyfrom" required/>
|
||||
</p>
|
||||
<p>
|
||||
<label for="status">Status:</label>
|
||||
|
@ -20,23 +20,23 @@
|
||||
|
||||
<form action='' method = "POST">
|
||||
<p>
|
||||
<label for="assettag">SKU:</label>
|
||||
<label for="assettag">Asset Tag:</label>
|
||||
<input id="assettag" type = "text" name = "assettag" value="{{item.assettag}}" required/>
|
||||
</p>
|
||||
<p>
|
||||
<label for="hostname">Name:</label>
|
||||
<label for="hostname">Host Name:</label>
|
||||
<input id="hostname" type = "text" name = "hostname" value="{{item.hostname}}" required/>
|
||||
</p>
|
||||
<p>
|
||||
<label for="warrantyfrom">Description:</label>
|
||||
<label for="warrantyfrom">Warranty From:</label>
|
||||
<input id="warrantyfrom" type = "text" name = "warrantyfrom" value="{{item.warrantyfrom}}" required/>
|
||||
</p>
|
||||
<p>
|
||||
<label for="status">Price:</label>
|
||||
<label for="status">Status:</label>
|
||||
<input id="status" type = "integer" name = "status" value="{{item.status}}" required/>
|
||||
</p>
|
||||
<p>
|
||||
<label for="staffnum">Quantity:</label>
|
||||
<label for="staffnum">Staff No:</label>
|
||||
<input id="staffnum" type = "integer" name = "staffnum" value="{{item.staffnum}}" required/>
|
||||
</p>
|
||||
<p>
|
||||
|
Loading…
Reference in New Issue
Block a user