Private
Public Access
1
0
Files
rowsandall/rowers/management/commands/loadnextweeksessions.py

45 lines
1.2 KiB
Python

#!/srv/venv/bin/python
import sys
import os
from django.core.management.base import BaseCommand
from rowers.models import Rower
from rowers.tasks import handle_loadnextweek
from rowers.utils import myqueue, dologging
import django_rq
PY3K = sys.version_info >= (3, 0)
queue = django_rq.get_queue('default')
queuelow = django_rq.get_queue('low')
queuehigh = django_rq.get_queue('low')
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument(
'--testing',
action='store_true',
dest='testing',
default=False,
help="Run in testing mode, don't send emails", )
def handle(self, *args, **options):
if 'testing' in options:
testing = options['testing']
else:
testing = False
rowers = Rower.objects.filter(training_plan_code__isnull=False).exclude(training_plan_code__exact='')
rowers = rowers.filter(training_plan_secret__isnull=False).exclude(training_plan_secret__exact='')
for rower in rowers:
_ = myqueue(queue, handle_loadnextweek,
rower)
self.stdout.write(self.style.SUCCESS(
'Successfully loaded next week plans'
))