cursor -> children

master
Matt Huntington 3 years ago
parent 2c932b0191
commit 97a247e1bd

@ -28,9 +28,9 @@ app.wsgi_app = HTTPMethodOverrideMiddleware(app.wsgi_app)
def show_all(): def show_all():
cursor.execute('SELECT * FROM items WHERE parent_id IS NULL') cursor.execute('SELECT * FROM items WHERE parent_id IS NULL')
if request.cookies.get('movingItemId'): if request.cookies.get('movingItemId'):
return render_template('show.html', cursor=cursor, moving_item_id=request.cookies.get('movingItemId')) return render_template('show.html', children=cursor, moving_item_id=request.cookies.get('movingItemId'))
else: else:
return render_template('show.html', cursor=cursor) return render_template('show.html', children=cursor)
@app.post("/") @app.post("/")
def create(): def create():
@ -73,9 +73,9 @@ def show(id):
parent=cursor.fetchone() parent=cursor.fetchone()
cursor.execute('SELECT * FROM items WHERE parent_id=%s',[id]) cursor.execute('SELECT * FROM items WHERE parent_id=%s',[id])
if request.cookies.get('movingItemId'): if request.cookies.get('movingItemId'):
return render_template('show.html', parent=parent, cursor=cursor, moving_item_id=request.cookies.get('movingItemId')) return render_template('show.html', parent=parent, children=cursor, moving_item_id=request.cookies.get('movingItemId'))
else: else:
return render_template('show.html', parent=parent, cursor=cursor) return render_template('show.html', parent=parent, children=cursor)
@app.get('/<int:id>/edit') @app.get('/<int:id>/edit')
def edit(id): def edit(id):

@ -23,7 +23,7 @@
<h2>Items</h2> <h2>Items</h2>
{%endif%} {%endif%}
<ul> <ul>
{%for (id, title, description, created_at, updated_at, parent_id) in cursor%} {%for (id, title, description, created_at, updated_at, parent_id) in children%}
<li> <li>
<a href="/{{id}}">{{title}}</a> <a href="/{{id}}">{{title}}</a>
</li> </li>

Loading…
Cancel
Save