Fix TypeError when revision_count is stored as TEXT
The previous schema migration added revision_count as TEXT. SQLite stores the default as TEXT, but the app does integer arithmetic on it, causing: TypeError: unsupported operand type(s) for -: 'int' and 'str' - init_db() now adds revision_count as INTEGER. - app.py casts revision_count to int in play() and revise() and when incrementing in revise(), so existing TEXT values also work. Bump version 0.4.2 -> 0.4.3.
This commit is contained in:
parent
f5d3d487af
commit
4b48e0a44f
4 changed files with 8 additions and 7 deletions
6
app.py
6
app.py
|
|
@ -621,7 +621,7 @@ def play(token):
|
|||
|
||||
# Load runtime max revisions setting.
|
||||
max_revisions = get_max_revisions()
|
||||
revisions_left = max(0, max_revisions - (req.get('revision_count') or 0))
|
||||
revisions_left = max(0, max_revisions - int(req.get('revision_count') or 0))
|
||||
|
||||
return render_template('player.html', req=req, revisions_left=revisions_left)
|
||||
|
||||
|
|
@ -661,7 +661,7 @@ def revise(token):
|
|||
|
||||
# Enforce max revisions limit for customer-submitted revisions.
|
||||
max_revisions = get_max_revisions()
|
||||
current_count = req.get('revision_count') or 0
|
||||
current_count = int(req.get('revision_count') or 0)
|
||||
if current_count >= max_revisions:
|
||||
flash('Revision limit reached. Please speak to the booth operator if you need further changes.', 'error')
|
||||
return redirect(url_for('play', token=token))
|
||||
|
|
@ -689,7 +689,7 @@ def revise(token):
|
|||
log_revision(req['id'], new_count, note, old_a=old_a, old_b=old_b, new_a=new_a, new_b=new_b)
|
||||
update_request(req['id'], revision_note=note, status='revisions_requested',
|
||||
song_a_path=req.get('song_a_path'), song_b_path=req.get('song_b_path'),
|
||||
customer_approved='none', revision_count=new_count)
|
||||
customer_approved='none', revision_count=int(new_count))
|
||||
|
||||
# NOTE: No operator email is sent; the dashboard is the single queue.
|
||||
flash('Your feedback has been saved. We will regenerate and update you.', 'success')
|
||||
|
|
|
|||
Reference in a new issue