allow null category id

This commit is contained in:
Bui 2020-03-15 16:25:38 +00:00
parent 61e521dda3
commit c5f85d0d87
2 changed files with 2 additions and 1 deletions

2
app.py
View File

@ -169,7 +169,7 @@ def route_admin_songs_id_post(id):
else: else:
output['courses'][course] = None output['courses'][course] = None
output['category_id'] = int(request.form.get('category_id')) output['category_id'] = int(request.form.get('category_id')) or None
output['type'] = request.form.get('type') output['type'] = request.form.get('type')
output['offset'] = float(request.form.get('offset')) or None output['offset'] = float(request.form.get('offset')) or None
output['skin_id'] = int(request.form.get('skin_id')) or None output['skin_id'] = int(request.form.get('skin_id')) or None

View File

@ -65,6 +65,7 @@
<div class="form-field"> <div class="form-field">
<p><label for="category_id">Category</label></p> <p><label for="category_id">Category</label></p>
<select name="category_id" id="category_id"> <select name="category_id" id="category_id">
<option value="0">(none)</option>
{% for category in categories %} {% for category in categories %}
<option value="{{ category.id }}"{% if song.category_id == category.id %} selected{% endif %}>{{ category.title }}</option> <option value="{{ category.id }}"{% if song.category_id == category.id %} selected{% endif %}>{{ category.title }}</option>
{% endfor %} {% endfor %}