From 3cbc6b56097f94d5ca4429b9a4c15977540c718f Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Thu, 11 Jun 2020 22:48:26 +0200 Subject: [PATCH] meal type admin --- cookbook/admin.py | 2 +- cookbook/tasks.py | 0 recipes/__init__.py | 7 +++++++ recipes/celery.py | 24 ++++++++++++++++++++++++ requirements.txt | 3 ++- 5 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 cookbook/tasks.py create mode 100644 recipes/celery.py diff --git a/cookbook/admin.py b/cookbook/admin.py index 6e1cc8cf..0b4fe0fe 100644 --- a/cookbook/admin.py +++ b/cookbook/admin.py @@ -105,7 +105,7 @@ admin.site.register(MealPlan, MealPlanAdmin) class MealTypeAdmin(admin.ModelAdmin): - list_display = ('name', 'order') + list_display = ('name', 'created_by', 'order') admin.site.register(MealType, MealTypeAdmin) diff --git a/cookbook/tasks.py b/cookbook/tasks.py new file mode 100644 index 00000000..e69de29b diff --git a/recipes/__init__.py b/recipes/__init__.py index e69de29b..070e835d 100644 --- a/recipes/__init__.py +++ b/recipes/__init__.py @@ -0,0 +1,7 @@ +from __future__ import absolute_import, unicode_literals + +# This will make sure the app is always imported when +# Django starts so that shared_task will use this app. +from .celery import app as celery_app + +__all__ = ('celery_app',) diff --git a/recipes/celery.py b/recipes/celery.py new file mode 100644 index 00000000..0dfb0d2a --- /dev/null +++ b/recipes/celery.py @@ -0,0 +1,24 @@ +from __future__ import absolute_import, unicode_literals + +import os + +from celery import Celery + +# set the default Django settings module for the 'celery' program. +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'recipes.settings') + +app = Celery('recipes') + +# Using a string here means the worker doesn't have to serialize +# the configuration object to child processes. +# - namespace='CELERY' means all celery-related configuration keys +# should have a `CELERY_` prefix. +app.config_from_object('django.conf:settings', namespace='CELERY') + +# Load task modules from all registered Django app configs. +app.autodiscover_tasks() + + +@app.task(bind=True) +def debug_task(self): + print('Request: {0!r}'.format(self.request)) diff --git a/requirements.txt b/requirements.txt index e01177b2..03e878ed 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,4 +20,5 @@ simplejson==3.17.0 six==1.15.0 webdavclient3==3.14.4 whitenoise==5.1.0 -icalendar==4.0.6 \ No newline at end of file +icalendar==4.0.6 +Celery==4.4.5 \ No newline at end of file