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