more pep
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
import sys
|
||||
import os
|
||||
|
||||
PY3K = sys.version_info >= (3,0)
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from rowers.models import Alert, Condition, User
|
||||
from rowers.tasks import handle_send_email_alert
|
||||
@@ -13,15 +11,17 @@ from rowers import alerts
|
||||
|
||||
from rowers.utils import myqueue
|
||||
|
||||
import datetime
|
||||
|
||||
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')
|
||||
|
||||
|
||||
import datetime
|
||||
|
||||
class Command(BaseCommand):
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
@@ -29,8 +29,7 @@ class Command(BaseCommand):
|
||||
action='store_true',
|
||||
dest='testing',
|
||||
default=False,
|
||||
help="Run in testing mode, don't send emails",
|
||||
)
|
||||
help="Run in testing mode, don't send emails", )
|
||||
|
||||
def handle(self, *args, **options):
|
||||
if 'testing' in options:
|
||||
@@ -38,7 +37,8 @@ class Command(BaseCommand):
|
||||
else:
|
||||
testing = False
|
||||
|
||||
todaysalerts = Alert.objects.filter(next_run__lt = datetime.date.today(),emailalert=True)
|
||||
todaysalerts = Alert.objects.filter(
|
||||
next_run__lt=datetime.date.today(), emailalert=True)
|
||||
|
||||
for alert in todaysalerts:
|
||||
stats = alerts.alert_get_stats(alert)
|
||||
@@ -47,14 +47,14 @@ class Command(BaseCommand):
|
||||
othertexts = [alert.description()]
|
||||
|
||||
# send email
|
||||
job = myqueue(queue,handle_send_email_alert,
|
||||
alert.manager.email,
|
||||
alert.manager.first_name,
|
||||
alert.manager.last_name,
|
||||
alert.rower.user.first_name,
|
||||
alert.name,
|
||||
stats,debug=True,
|
||||
othertexts=othertexts)
|
||||
_ = myqueue(queue, handle_send_email_alert,
|
||||
alert.manager.email,
|
||||
alert.manager.first_name,
|
||||
alert.manager.last_name,
|
||||
alert.rower.user.first_name,
|
||||
alert.name,
|
||||
stats, debug=True,
|
||||
othertexts=othertexts)
|
||||
|
||||
# advance next_run
|
||||
if not testing:
|
||||
@@ -62,7 +62,7 @@ class Command(BaseCommand):
|
||||
alert.save()
|
||||
|
||||
if testing:
|
||||
print('{nr} alerts found'.format(nr = len(todaysalerts)))
|
||||
print('{nr} alerts found'.format(nr=len(todaysalerts)))
|
||||
|
||||
self.stdout.write(self.style.SUCCESS(
|
||||
'Successfully processed alerts'))
|
||||
|
||||
Reference in New Issue
Block a user