If override_date is provided, coerce it into a datetime

This commit is contained in:
Trenton H 2022-11-22 10:11:27 -08:00
parent f015556562
commit de98d748a9

View File

@ -3,6 +3,7 @@ import logging
import os import os
import shutil import shutil
import uuid import uuid
from datetime import datetime
from pathlib import Path from pathlib import Path
from typing import Type from typing import Type
@ -98,6 +99,14 @@ def consume_file(
path = Path(path).resolve() path = Path(path).resolve()
# Celery converts this to a string, but everything expects a datetime
# Long term solution is to not use JSON for the serializer but pickle instead
if override_created is not None and isinstance(override_created, str):
try:
override_created = datetime.fromisoformat(override_created)
except Exception:
pass
# check for separators in current document # check for separators in current document
if settings.CONSUMER_ENABLE_BARCODES: if settings.CONSUMER_ENABLE_BARCODES: