Commit d97c8cc8921494c0300d84ae01756b456c494336

Authored by Zambom
1 parent 3b8b3da4

Adding crontab to do notifications cron job

amadeus/settings.py
@@ -52,6 +52,7 @@ INSTALLED_APPS = [ @@ -52,6 +52,7 @@ INSTALLED_APPS = [
52 's3direct', 52 's3direct',
53 'django_summernote', 53 'django_summernote',
54 'session_security', 54 'session_security',
  55 + 'django_crontab',
55 'django_cron', 56 'django_cron',
56 57
57 'amadeus', 58 'amadeus',
@@ -176,6 +177,10 @@ CRON_CLASSES = [ @@ -176,6 +177,10 @@ CRON_CLASSES = [
176 'notifications.cron.Notify' 177 'notifications.cron.Notify'
177 ] 178 ]
178 179
  180 +CRONJOBS = [
  181 + ('1 */12 * * *', 'notifications.cron.notification_cron')
  182 +]
  183 +
179 #SECURITY 184 #SECURITY
180 SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO','https') 185 SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO','https')
181 186
notifications/cron.py
@@ -4,11 +4,13 @@ from django_cron import CronJobBase, Schedule @@ -4,11 +4,13 @@ from django_cron import CronJobBase, Schedule
4 from .utils import set_notifications 4 from .utils import set_notifications
5 5
6 class Notify(CronJobBase): 6 class Notify(CronJobBase):
7 - RUN_EVERY_MINS = 1 # every minute 7 + RUN_EVERY_MINS = 1440 # every day
8 8
9 schedule = Schedule(run_every_mins=RUN_EVERY_MINS) 9 schedule = Schedule(run_every_mins=RUN_EVERY_MINS)
10 code = 'amadeus.notification_cron' # a unique code 10 code = 'amadeus.notification_cron' # a unique code
11 11
12 def do(self): 12 def do(self):
13 - print("Hey")  
14 - set_notifications()  
15 \ No newline at end of file 13 \ No newline at end of file
  14 + set_notifications()
  15 +
  16 +def notification_cron():
  17 + set_notifications()
16 \ No newline at end of file 18 \ No newline at end of file
requirements.txt
@@ -34,4 +34,5 @@ Werkzeug==0.11.11 @@ -34,4 +34,5 @@ Werkzeug==0.11.11
34 whitenoise==3.2.2 34 whitenoise==3.2.2
35 django-session-security==2.4.0 35 django-session-security==2.4.0
36 django-cron==0.5.0 36 django-cron==0.5.0
  37 +django-crontab==0.7.1
37 python-dateutil==2.6.0 38 python-dateutil==2.6.0
38 \ No newline at end of file 39 \ No newline at end of file