diff --git a/slaeforms/app.py b/slaeforms/app.py index 8f1a6d5..05dec06 100644 --- a/slaeforms/app.py +++ b/slaeforms/app.py @@ -305,6 +305,8 @@ def sendpage(): update_session() return redirect("/form") + + # now to if it has a database field # find out which table we need to write to @@ -318,6 +320,22 @@ def sendpage(): new_entry = db_tables[table_name](id=new_id,user_id = session_user_id,date_created = date,stimulus_name=stimulus_name) + # handle possible Video that was send + if 'recordedVideo' in request.files: + video = request.files['recordedVideo'] + formatted_date = date.strftime("%Y.%m.%d %H-%M-%S") + print("date: ", date) + video_name = str(session_user_id) + "_" + session["current_block_name"] + "_" + session["current_stimulus_name"] + "_" + str(formatted_date) + ".webm" + path = os.path.join(UPLOAD_FOLDER, video_name) + print("path: ",path) + os.makedirs(UPLOAD_FOLDER, exist_ok=True) + video.save(path) + + if 'recordedVideo' in request.files: + if hasattr(new_entry, "video_upload"): + setattr(new_entry, "video_upload", video_name) + + for key, value in request.form.items(): print("hasattr key: ", key) if hasattr(new_entry, key): diff --git a/slaeforms/default.json b/slaeforms/default.json index 729e499..c6b4a73 100644 --- a/slaeforms/default.json +++ b/slaeforms/default.json @@ -255,6 +255,11 @@ "type": "string", "size": "250", "nullable": "true" + }, + "video_upload":{ + "type": "string", + "size": "100", + "nullable": "true" } } } diff --git a/slaeforms/uploads/d46ec7b4-d838-4344-a002-a8c6aba485a5_Block 2_video_1_2024.06.25 15-43-39.webm b/slaeforms/uploads/d46ec7b4-d838-4344-a002-a8c6aba485a5_Block 2_video_1_2024.06.25 15-43-39.webm new file mode 100644 index 0000000..e69de29