forked from server/soundboard
Change SQL query to get already set tags
This commit is contained in:
parent
80e0ba439b
commit
03be396c87
@ -94,6 +94,24 @@ def edit(sound):
|
|||||||
# TODO: Store changes
|
# TODO: Store changes
|
||||||
return redirect("/edit")
|
return redirect("/edit")
|
||||||
|
|
||||||
tags = queryDB("SELECT name FROM tag ORDER BY name COLLATE NOCASE")
|
tags = queryDB("""\
|
||||||
|
SELECT
|
||||||
|
tag.name,
|
||||||
|
checked.id IS NOT NULL AS checked
|
||||||
|
FROM
|
||||||
|
tag
|
||||||
|
LEFT OUTER JOIN (
|
||||||
|
SELECT
|
||||||
|
tag.id
|
||||||
|
FROM
|
||||||
|
tag
|
||||||
|
JOIN
|
||||||
|
button_tags
|
||||||
|
ON
|
||||||
|
fk_tag = tag.id
|
||||||
|
WHERE fk_button = 1
|
||||||
|
) AS checked
|
||||||
|
ON tag.id = checked.id""")
|
||||||
|
print(tags)
|
||||||
|
|
||||||
return render_template("edit.html", sound=sound, tags=tags)
|
return render_template("edit.html", sound=sound, tags=tags)
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
<input type="text" id="search" placeholder="Search Tag" />
|
<input type="text" id="search" placeholder="Search Tag" />
|
||||||
<ul class="tags">
|
<ul class="tags">
|
||||||
{% for tag in tags %}
|
{% for tag in tags %}
|
||||||
<li class="tag"><span>{{ tag.name }}</span><input type="checkbox" /></li>
|
<li class="tag"><span>{{ tag.name }}</span><input type="checkbox" {{ 'checked="true" '|safe if tag.checked }}/></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
<input type="button" value="Cancel" />
|
<input type="button" value="Cancel" />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user