From 37a41cf1fc3fda772f6e7d37c0f3336dfc06aba2 Mon Sep 17 00:00:00 2001 From: Christopher Usher Date: Tue, 10 Nov 2020 10:37:18 +0100 Subject: [PATCH] fixes in response to review --- thrimbletrimmer/scripts/IO.js | 3 +-- thrimshim/thrimshim/main.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/thrimbletrimmer/scripts/IO.js b/thrimbletrimmer/scripts/IO.js index b516884..3772da7 100644 --- a/thrimbletrimmer/scripts/IO.js +++ b/thrimbletrimmer/scripts/IO.js @@ -275,8 +275,7 @@ thrimbletrimmerSubmit = function(state, override_changes=false) { //Submit to thrimshim var rowId = /id=(.*)(?:&|$)/.exec(document.location.search)[1]; - path = "/thrimshim/" + rowId + "?override_changes=" + override_changes; - fetch(path, { + fetch("/thrimshim/" + rowId, { method: 'POST', headers: { 'Accept': 'application/json', diff --git a/thrimshim/thrimshim/main.py b/thrimshim/thrimshim/main.py index 17bee0c..e3fa3ff 100644 --- a/thrimshim/thrimshim/main.py +++ b/thrimshim/thrimshim/main.py @@ -184,7 +184,7 @@ def get_row(ident): @authenticate def update_row(ident, editor=None): new_row = flask.request.json - override_changes = 'override_changes' in new_row + override_changes = new_row.get('override_changes', False) """Updates row of database with id = ident with the edit columns in new_row.""" @@ -193,8 +193,9 @@ def update_row(ident, editor=None): non_null_columns = ['upload_location', 'video_start', 'video_end', 'video_channel', 'video_quality', 'video_title', 'video_description', 'video_tags'] edit_columns = non_null_columns + ['allow_holes', 'uploader_whitelist'] - sheet_columns = ['sheet_name', 'event_start', 'event_end', 'category', - 'description', 'notes'] + sheet_columns = [ + 'sheet_name', 'event_start', 'event_end', 'category', 'description', 'notes' + ] #check vital edit columns are in new_row wanted = set(non_null_columns + ['state'] + sheet_columns) @@ -224,8 +225,10 @@ def update_row(ident, editor=None): built_query = sql.SQL(""" SELECT id, state, {} FROM events - WHERE id = %s""").format(sql.SQL(', ').join( - sql.Identifier(key) for key in sheet_columns)) + WHERE id = %s + """).format(sql.SQL(', ').join( + sql.Identifier(key) for key in sheet_columns + )) results = database.query(conn, built_query, ident) old_row = results.fetchone()._asdict() if old_row is None: