Commit 7c82dc09 authored by Lukáš Lalinský's avatar Lukáš Lalinský

Fix toggle_track_mbid

parent dc4f9131
Pipeline #20581 passed with stages
in 3 minutes and 55 seconds
......@@ -168,26 +168,28 @@ def mbid(mbid):
@metadata_page.route('/edit/toggle-track-mbid', methods=['GET', 'POST'])
def toggle_track_mbid():
conn = db.session.connection()
fingerprint_db = db.get_fingerprint_db()
ingest_db = db.get_ingest_db()
app_db = db.get_app_db()
user = require_user()
track_id = request.values.get('track_id', type=int)
if track_id:
query =[schema.track.c.gid], == track_id)
track_gid = conn.execute(query).scalar()
track_gid = fingerprint_db.execute(query).scalar()
track_gid = request.values.get('track_gid')
track_id = resolve_track_gid(conn, track_gid)
track_id = resolve_track_gid(fingerprint_db, track_gid)
state = bool(request.values.get('state', type=int))
mbid = request.values.get('mbid')
if not track_id or not mbid or not track_gid:
return redirect(url_for('general.index'))
if not is_moderator(conn,
if not is_moderator(app_db,
title = 'MusicBrainz account required'
return render_template('toggle_track_mbid_login.html', title=title)
query =[, schema.track_mbid.c.disabled],
sql.and_(schema.track_mbid.c.track_id == track_id,
schema.track_mbid.c.mbid == mbid))
rows = conn.execute(query).fetchall()
rows = fingerprint_db.execute(query).fetchall()
if not rows:
return redirect(url_for('general.index'))
id, current_state = rows[0]
......@@ -196,10 +198,10 @@ def toggle_track_mbid():
if request.form.get('submit'):
note = request.values.get('note')
update_stmt = schema.track_mbid.update().where( == id).values(disabled=state)
insert_stmt = schema.track_mbid_change.insert().values(track_mbid_id=id, account_id=session['id'],
disabled=state, note=note)
return redirect(url_for('.track', track_id=track_id))
if state:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment