add periodic tasks

prod
Dmitriy Shesterkin 9 years ago
parent 0b3db9035e
commit ae7f424293
  1. 18
      src/customer/tasks.py
  2. 7
      src/dokumentor/settings/common.py

@ -3,12 +3,12 @@ from __future__ import absolute_import
import traceback import traceback
from celery.schedules import crontab
from celery.task import periodic_task
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.utils import timezone from django.utils import timezone
from datetime import datetime, timedelta from datetime import datetime, timedelta
from celery import shared_task, task
from django.core.mail import mail_admins from django.core.mail import mail_admins
from myauth.models import DokUser, ConfirmEmail from myauth.models import DokUser, ConfirmEmail
@ -18,7 +18,7 @@ from .models import License, UserProfile
from .utils import check_one_profile from .utils import check_one_profile
@shared_task @periodic_task(ignore_result=True, run_every=crontab(hour=0, minute=0))
def check_license(): def check_license():
profiles = UserProfile.objects.all() profiles = UserProfile.objects.all()
now = datetime.today() now = datetime.today()
@ -40,7 +40,7 @@ def check_license():
) )
@shared_task @periodic_task(ignore_result=True, run_every=crontab(hour=0, minute=0))
def delete_not_activated_users(): def delete_not_activated_users():
""" """
Delete not activated users in 5 days after sending Delete not activated users in 5 days after sending
@ -62,7 +62,7 @@ def delete_not_activated_users():
user.delete() user.delete()
@shared_task @periodic_task(ignore_result=True, run_every=crontab(hour=0, minute=0))
def send_offer_for_get_bonus(): def send_offer_for_get_bonus():
""" """
Sending a proposal with a bonus to new users without the purchased license Sending a proposal with a bonus to new users without the purchased license
@ -85,7 +85,7 @@ def send_offer_for_get_bonus():
return user_list return user_list
@shared_task @periodic_task(ignore_result=True, run_every=crontab(hour=0, minute=0))
def check_not_paid_accounts(): def check_not_paid_accounts():
""" """
Check the unpaid bills(instance of license) and if their period Check the unpaid bills(instance of license) and if their period
@ -106,6 +106,6 @@ def check_not_paid_accounts():
return account_list return account_list
@task @periodic_task(ignore_result=True, run_every=crontab())
def test(arg): def test():
print(arg) print('hi')

@ -283,12 +283,7 @@ CELERYBEAT_SCHEDULE = {
'check_not_paid_accounts': { 'check_not_paid_accounts': {
'task': 'src.customer.tasks.check_not_paid_accounts', 'task': 'src.customer.tasks.check_not_paid_accounts',
'schedule': timedelta(days=1), 'schedule': timedelta(days=1),
}, }
'test_task': {
'task': 'src.customer.tasks.test',
'schedule': 30.0,
'args': (16, 16)
},
} }
CAPTCHA_OUTPUT_FORMAT = \ CAPTCHA_OUTPUT_FORMAT = \

Loading…
Cancel
Save