From e00a923a2d117f6be092ded4687b6662c3f72ee9 Mon Sep 17 00:00:00 2001 From: Floris272 Date: Thu, 24 Oct 2024 14:53:45 +0200 Subject: [PATCH] [maykinmedia/open-producten#24] Add celery task --- src/openforms/conf/base.py | 4 ++++ src/openforms/contrib/open_producten/tasks.py | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/openforms/contrib/open_producten/tasks.py diff --git a/src/openforms/conf/base.py b/src/openforms/conf/base.py index 12a2dcd80d..13489ae515 100644 --- a/src/openforms/conf/base.py +++ b/src/openforms/conf/base.py @@ -780,6 +780,10 @@ "task": "openforms.authentication.tasks.update_saml_metadata", "schedule": crontab(hour=0, minute=0, day_of_week="sunday"), }, + "import-open-producten-prices": { + "task": "openforms.contrib.open_producten.tasks.import_product_type_prices", + "schedule": crontab(hour=0, minute=0, day_of_week="*"), + }, } RETRY_SUBMISSIONS_TIME_LIMIT = config( diff --git a/src/openforms/contrib/open_producten/tasks.py b/src/openforms/contrib/open_producten/tasks.py new file mode 100644 index 0000000000..3059c2732d --- /dev/null +++ b/src/openforms/contrib/open_producten/tasks.py @@ -0,0 +1,21 @@ +import io +import logging + +from django.core.management import call_command + +from openforms.celery import app + +logger = logging.getLogger(__name__) + + +@app.task() +def import_product_type_prices(): + logger.info("starting import_prices() task") + + out = io.StringIO() + + call_command("import_prices", stdout=out) + + logger.info("finished import_prices() task") + + return out.getvalue()