FIxed csv download and redirect path after delete
This commit is contained in:
parent
fec137280c
commit
0da3885866
6
app.py
6
app.py
@ -50,10 +50,10 @@ def create():
|
|||||||
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='')
|
||||||
outcsv = csv.writer(outfile)
|
outcsv = csv.writer(outfile, delimiter='|')
|
||||||
records = db.session.query(Asset).all()
|
records = db.session.query(Asset).all()
|
||||||
outcsv.writerow([column.hostname for column in Asset.__mapper__.columns])
|
outcsv.writerow([column.name for column in Asset.__mapper__.columns])
|
||||||
[outcsv.writerow([getattr(curr, column.hostname) for column in Asset.__mapper__.columns]) for curr in records]
|
[outcsv.writerow([getattr(curr, column.name) for column in Asset.__mapper__.columns]) for curr in records]
|
||||||
outfile.close()
|
outfile.close()
|
||||||
return send_file('inventory_export.csv', as_attachment=True)
|
return send_file('inventory_export.csv', as_attachment=True)
|
||||||
|
|
||||||
|
@ -7,13 +7,13 @@
|
|||||||
<body align="center">
|
<body align="center">
|
||||||
<div align="center">
|
<div align="center">
|
||||||
<a href="/create">Add</a> |
|
<a href="/create">Add</a> |
|
||||||
<a href="/view">View</a>
|
<a href="/viewall">View</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form action='' method="post">
|
<form action='' method="post">
|
||||||
Do you want to delete the item?
|
Do you want to delete the item?
|
||||||
<input type = "submit" value="Confirm">
|
<input type = "submit" value="Confirm">
|
||||||
<a href='/view'>Cancel</a>
|
<a href='/viewall'>Cancel</a>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
{{item.warrantyfrom}}
|
{{item.warrantyfrom}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
${{item.status}}
|
{{item.status}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{item.staffnum}}
|
{{item.staffnum}}
|
||||||
|
Loading…
Reference in New Issue
Block a user