diff --git a/routes/conditions.py b/routes/conditions.py index 2cc3f04..21ae989 100644 --- a/routes/conditions.py +++ b/routes/conditions.py @@ -5,6 +5,8 @@ table_name = 'conditions' route = table_name r = getRethinkDB() +booleans = ["disbled"] + def create_conditions_routes(app): # Create a table (if not exists) if table_name not in r.table_list().run(get_connection()): @@ -24,6 +26,10 @@ def create_conditions_routes(app): else: # Assuming form data is in 'application/x-www-form-urlencoded' format data = request.form.to_dict() + # convert checkboxes to true/false + for key in booleans: + data[key] = key in request.form + result = r.table(table_name).insert(data).run(get_connection()) return render_template(route + '/create.html') @@ -50,6 +56,11 @@ def create_conditions_routes(app): data = request.json else: data = request.form.to_dict() + + # convert checkboxes to true/false + for key in booleans: + data[key] = key in request.form + r.table(table_name).get(id).update(data).run(get_connection()) return ""