From ae7f424293ba658e225384a6b01e8e8d60663203 Mon Sep 17 00:00:00 2001 From: Dmitriy Shesterkin Date: Thu, 29 Jun 2017 18:49:20 +0300 Subject: [PATCH] add periodic tasks --- src/customer/tasks.py | 18 +++++++++--------- src/dokumentor/settings/common.py | 7 +------ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/customer/tasks.py b/src/customer/tasks.py index 25a221e..8801704 100644 --- a/src/customer/tasks.py +++ b/src/customer/tasks.py @@ -3,12 +3,12 @@ from __future__ import absolute_import import traceback +from celery.schedules import crontab +from celery.task import periodic_task from django.core.urlresolvers import reverse from django.utils import timezone from datetime import datetime, timedelta -from celery import shared_task, task - from django.core.mail import mail_admins from myauth.models import DokUser, ConfirmEmail @@ -18,7 +18,7 @@ from .models import License, UserProfile from .utils import check_one_profile -@shared_task +@periodic_task(ignore_result=True, run_every=crontab(hour=0, minute=0)) def check_license(): profiles = UserProfile.objects.all() 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(): """ Delete not activated users in 5 days after sending @@ -62,7 +62,7 @@ def delete_not_activated_users(): user.delete() -@shared_task +@periodic_task(ignore_result=True, run_every=crontab(hour=0, minute=0)) def send_offer_for_get_bonus(): """ 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 -@shared_task +@periodic_task(ignore_result=True, run_every=crontab(hour=0, minute=0)) def check_not_paid_accounts(): """ Check the unpaid bills(instance of license) and if their period @@ -106,6 +106,6 @@ def check_not_paid_accounts(): return account_list -@task -def test(arg): - print(arg) +@periodic_task(ignore_result=True, run_every=crontab()) +def test(): + print('hi') diff --git a/src/dokumentor/settings/common.py b/src/dokumentor/settings/common.py index e92125c..d04f408 100644 --- a/src/dokumentor/settings/common.py +++ b/src/dokumentor/settings/common.py @@ -283,12 +283,7 @@ CELERYBEAT_SCHEDULE = { 'check_not_paid_accounts': { 'task': 'src.customer.tasks.check_not_paid_accounts', 'schedule': timedelta(days=1), - }, - 'test_task': { - 'task': 'src.customer.tasks.test', - 'schedule': 30.0, - 'args': (16, 16) - }, + } } CAPTCHA_OUTPUT_FORMAT = \