Skip to content

Commit

Permalink
Log submission message as one message
Browse files Browse the repository at this point in the history
  • Loading branch information
qlands committed Apr 19, 2024
1 parent 46e5537 commit e055d11
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions formshare/processes/odk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3981,13 +3981,22 @@ def store_submission(request, user, project, assistant):
path = os.path.join(odk_dir, *["submissions", str(unique_id)])
os.makedirs(path)
xml_file = ""
submission_message = ""
if request.registry.settings.get("log_submissions", "false").upper() == "TRUE":
log.error(
"Received submission {}. user: {}, project: {}, assistant: {}. "
"It contains the following files:".format(
unique_id, user, project, assistant
if not "*isIncomplete*" in request.POST.keys():
submission_message = (
"Received submission {}. user: {}, project: {}, assistant: {}. "
"It contains the following files:\n".format(
unique_id, user, project, assistant
)
)
else:
submission_message = (
"Received incomplete submission {}. user: {}, project: {}, assistant: {}. "
"It contains the following files:\n".format(
unique_id, user, project, assistant
)
)
)
for key in request.POST.keys():
try:
if key != "*isIncomplete*":
Expand All @@ -4006,7 +4015,7 @@ def store_submission(request, user, project, assistant):
request.registry.settings.get("log_submissions", "false").upper()
== "TRUE"
):
log.error(filename)
submission_message = submission_message + filename + "\n"
input_file = request.POST[key].file
file_path = os.path.join(path, filename)
if file_path.upper().find(".XML") >= 0:
Expand Down Expand Up @@ -4056,6 +4065,11 @@ def store_submission(request, user, project, assistant):
+ ". URL: "
+ request.url
)
if request.registry.settings.get("log_submissions", "false").upper() == "TRUE":
submission_message = submission_message + "End of submission {}".format(
unique_id
)
log.error(submission_message)
if xml_file != "":
tree = etree.parse(xml_file)
root = tree.getroot()
Expand Down

0 comments on commit e055d11

Please sign in to comment.