parent -> item

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

@ -70,12 +70,12 @@ def delete(id):
@app.get("/<int:id>")
def show(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])
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:
return render_template('show.html', parent=parent, children=cursor)
return render_template('show.html', item=item, children=cursor)
@app.get('/<int:id>/edit')
def edit(id):

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

Loading…
Cancel
Save