parent -> item

master
Matt Huntington 3 years ago
parent 97a247e1bd
commit 6903affc87

@ -70,12 +70,12 @@ def delete(id):
@app.get("/<int:id>") @app.get("/<int:id>")
def show(id): def show(id):
cursor.execute('SELECT * FROM items WHERE id=%s', [id]) cursor.execute('SELECT * FROM items WHERE id=%s', [id])
parent=cursor.fetchone() item=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, children=cursor, moving_item_id=request.cookies.get('movingItemId')) return render_template('show.html', item=item, children=cursor, moving_item_id=request.cookies.get('movingItemId'))
else: else:
return render_template('show.html', parent=parent, children=cursor) return render_template('show.html', item=item, children=cursor)
@app.get('/<int:id>/edit') @app.get('/<int:id>/edit')
def edit(id): def edit(id):

@ -6,10 +6,10 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
</head> </head>
<body> <body>
{%if parent%} {%if item%}
<header> <header>
<h1>{{parent[1]}}</h1> <h1>{{item[1]}}</h1>
{{parent[2]}} {{item[2]}}
</header> </header>
{%else%} {%else%}
<header> <header>
@ -17,7 +17,7 @@
</header> </header>
{%endif%} {%endif%}
<section> <section>
{%if parent%} {%if item%}
<h2>Child Items</h2> <h2>Child Items</h2>
{%else%} {%else%}
<h2>Items</h2> <h2>Items</h2>
@ -30,8 +30,8 @@
{%endfor%} {%endfor%}
</ul> </ul>
{%if moving_item_id %} {%if moving_item_id %}
{% if parent %} {% if item %}
<form action="/{{parent[0]}}/move?_method=PUT" method="POST"> <form action="/{{item[0]}}/move?_method=PUT" method="POST">
<input type="submit" value="Move Item Here"/> <input type="submit" value="Move Item Here"/>
</form> </form>
{% else %} {% else %}
@ -46,8 +46,8 @@
<form action="/" method="POST"> <form action="/" method="POST">
<input name="title" type="text"> <input name="title" type="text">
<textarea name="description"></textarea> <textarea name="description"></textarea>
{%if parent%} {%if item%}
<input type="hidden" name="parent_id" value="{{parent[0]}}"/> <input type="hidden" name="parent_id" value="{{item[0]}}"/>
{%endif%} {%endif%}
<input type="submit"/> <input type="submit"/>
</form> </form>
@ -55,12 +55,12 @@
<section> <section>
<nav> <nav>
<ul> <ul>
{%if parent%} {%if item%}
{%if parent[5]%} {%if item[5]%}
<li><a href="/{{parent[5]}}">To Parent</a></li> <li><a href="/{{item[5]}}">To Parent</a></li>
{%endif%} {%endif%}
<li><a href="/">To Index</a></li> <li><a href="/">To Index</a></li>
<li><a href="/{{parent[0]}}/edit">Edit</a></li> <li><a href="/{{item[0]}}/edit">Edit</a></li>
{%endif%} {%endif%}
</ul> </ul>
</nav> </nav>

Loading…
Cancel
Save