Blank submission makes no change

multichannel
HeNine 3 years ago
parent 6c9873ac60
commit b43e574e8d

@ -50,7 +50,9 @@ def get_playlist(line_id):
def update_line(line_id): def update_line(line_id):
db_conn = app.db_manager.get_conn() db_conn = app.db_manager.get_conn()
if "speakers" in request.json and isinstance(request.json["speakers"], list): if "speakers" in request.json and \
isinstance(request.json["speakers"], list) and \
request.json["speakers"] != []:
# Simpler than dealing with uniqueness # Simpler than dealing with uniqueness
database.query(db_conn, database.query(db_conn,
"DELETE FROM buscribe_line_speakers WHERE line = %(line_id)s AND verifier = %(verifier)s;", "DELETE FROM buscribe_line_speakers WHERE line = %(line_id)s AND verifier = %(verifier)s;",
@ -60,7 +62,9 @@ def update_line(line_id):
"VALUES %s;", "VALUES %s;",
[(line_id, speaker, "placeholder@example.com") for speaker in [(line_id, speaker, "placeholder@example.com") for speaker in
request.json["speakers"]]) request.json["speakers"]])
if "transcription" in request.json and isinstance(request.json["transcription"], str): if "transcription" in request.json and \
isinstance(request.json["transcription"], str) and \
request.json["transcription"] != "":
verified_line = request.json["transcription"].lower() verified_line = request.json["transcription"].lower()
verified_line = re.sub(r"[^[a-z]\s']]", "", verified_line) verified_line = re.sub(r"[^[a-z]\s']]", "", verified_line)

@ -37,6 +37,7 @@ function fillLineInfo(line_json) {
async function submit() { async function submit() {
const new_transcription = document.getElementById("new_transcription").value; const new_transcription = document.getElementById("new_transcription").value;
const new_speakers = await Promise.all(document.getElementById("speaker_input").value const new_speakers = await Promise.all(document.getElementById("speaker_input").value
.trim()
.split(",") .split(",")
.filter(x => x !== "") .filter(x => x !== "")
.map(speaker_raw => speaker_raw.trim()) .map(speaker_raw => speaker_raw.trim())

Loading…
Cancel
Save