|
|
|
@ -61,7 +61,7 @@ def create_instrument(name, description, params, sockets, panel):
|
|
|
|
|
"INSERT OR IGNORE INTO params (param_name) VALUES (?)",(param,)
|
|
|
|
|
)
|
|
|
|
|
cur.execute(
|
|
|
|
|
"INSERT INTO instrument_param (instrument_id, param_name) VALUES (?, ?)", (instrument_id, param )
|
|
|
|
|
"INSERT INTO instrument_param (instrument, param_name) VALUES (?, ?)", (slug, param )
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
for socket in sockets:
|
|
|
|
@ -70,7 +70,7 @@ def create_instrument(name, description, params, sockets, panel):
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
cur.execute(
|
|
|
|
|
"INSERT INTO instrument_socket (instrument_id, socket_name) VALUES (?, ?)", (instrument_id, socket )
|
|
|
|
|
"INSERT INTO instrument_socket (instrument, socket_name) VALUES (?, ?)", (slug, socket )
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
connection.commit()
|
|
|
|
@ -147,25 +147,39 @@ def add_patch(instrument):
|
|
|
|
|
|
|
|
|
|
patch_id = cursor.lastrowid
|
|
|
|
|
|
|
|
|
|
patch.pop('name','')
|
|
|
|
|
patch.pop('slug','')
|
|
|
|
|
patch.pop('description','')
|
|
|
|
|
patch.pop('cables','')
|
|
|
|
|
instrument_params = cursor.execute('SELECT param_name FROM instrument_param WHERE instrument = ?', (instrument,)).fetchall()
|
|
|
|
|
instrument_sockets = cursor.execute('SELECT socket_name FROM instrument_socket WHERE instrument = ?', (instrument,)).fetchall()
|
|
|
|
|
|
|
|
|
|
for param, value in patch.items():
|
|
|
|
|
cursor.execute('INSERT INTO patch_param (patch_id, param_name, value) VALUES (?,?,?)',
|
|
|
|
|
(patch_id, param, value))
|
|
|
|
|
instrument_params = [row[0] for row in instrument_params]
|
|
|
|
|
instrument_sockets = [row[0] for row in instrument_sockets]
|
|
|
|
|
|
|
|
|
|
for key, value in patch.items():
|
|
|
|
|
destination = None
|
|
|
|
|
if key in instrument_params:
|
|
|
|
|
destination = 'param'
|
|
|
|
|
elif key in instrument_sockets:
|
|
|
|
|
destination = 'socket'
|
|
|
|
|
|
|
|
|
|
if destination is not None:
|
|
|
|
|
print(f'Insert {key} into {destination}')
|
|
|
|
|
cursor.execute(f'INSERT INTO patch_{destination} (patch_id, {destination}_name, value) VALUES (?,?,?)',
|
|
|
|
|
(patch_id, key, value))
|
|
|
|
|
|
|
|
|
|
connection.commit()
|
|
|
|
|
connection.close()
|
|
|
|
|
|
|
|
|
|
return redirect(url_for('patches', instrument=instrument))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with open(f'static/panels/{instrument}.svg', 'r') as f:
|
|
|
|
|
panel = f.read()
|
|
|
|
|
|
|
|
|
|
instrument = cursor.execute('SELECT * FROM instruments WHERE slug = ?', (instrument,)).fetchone()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connection.close()
|
|
|
|
|
return render_template('add_patch.html', instrument=instrument, panel = panel)
|
|
|
|
|
|
|
|
|
@ -173,8 +187,6 @@ def add_patch(instrument):
|
|
|
|
|
@app.route("/instruments/<instrument>/<name>", methods=['GET', 'POST'])
|
|
|
|
|
def patch(instrument, name):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
|
|
|
|
|
|
connection = get_db_connection()
|
|
|
|
@ -210,6 +222,9 @@ def patch(instrument, name):
|
|
|
|
|
params = cursor.execute('SELECT * FROM patch_param WHERE patch_id = ?',
|
|
|
|
|
(patch['id'],)).fetchall()
|
|
|
|
|
|
|
|
|
|
sockets = cursor.execute('SELECT * FROM patch_socket WHERE patch_id = ?',
|
|
|
|
|
(patch['id'],)).fetchall()
|
|
|
|
|
|
|
|
|
|
instrument = cursor.execute('SELECT * FROM instruments WHERE slug = ?',
|
|
|
|
|
(instrument,)).fetchone()
|
|
|
|
|
|
|
|
|
@ -218,7 +233,7 @@ def patch(instrument, name):
|
|
|
|
|
|
|
|
|
|
connection.close()
|
|
|
|
|
|
|
|
|
|
return render_template('patch.html', instrument=instrument, patch=patch, params=params, panel=panel, snippets=snippets)
|
|
|
|
|
return render_template('patch.html', instrument=instrument, patch=patch, params=params, sockets=sockets, panel=panel, snippets=snippets)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|