From d97c8cc8921494c0300d84ae01756b456c494336 Mon Sep 17 00:00:00 2001 From: Zambom Date: Wed, 1 Feb 2017 17:42:20 -0200 Subject: [PATCH] Adding crontab to do notifications cron job --- amadeus/settings.py | 5 +++++ notifications/cron.py | 8 +++++--- requirements.txt | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/amadeus/settings.py b/amadeus/settings.py index faad125..1e4cf4a 100644 --- a/amadeus/settings.py +++ b/amadeus/settings.py @@ -52,6 +52,7 @@ INSTALLED_APPS = [ 's3direct', 'django_summernote', 'session_security', + 'django_crontab', 'django_cron', 'amadeus', @@ -176,6 +177,10 @@ CRON_CLASSES = [ 'notifications.cron.Notify' ] +CRONJOBS = [ + ('1 */12 * * *', 'notifications.cron.notification_cron') +] + #SECURITY SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO','https') diff --git a/notifications/cron.py b/notifications/cron.py index 5b72fcb..a877a0d 100644 --- a/notifications/cron.py +++ b/notifications/cron.py @@ -4,11 +4,13 @@ from django_cron import CronJobBase, Schedule from .utils import set_notifications class Notify(CronJobBase): - RUN_EVERY_MINS = 1 # every minute + RUN_EVERY_MINS = 1440 # every day schedule = Schedule(run_every_mins=RUN_EVERY_MINS) code = 'amadeus.notification_cron' # a unique code def do(self): - print("Hey") - set_notifications() \ No newline at end of file + set_notifications() + +def notification_cron(): + set_notifications() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index bf40d05..ada73ea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -34,4 +34,5 @@ Werkzeug==0.11.11 whitenoise==3.2.2 django-session-security==2.4.0 django-cron==0.5.0 +django-crontab==0.7.1 python-dateutil==2.6.0 \ No newline at end of file -- libgit2 0.21.2