repair weekly_finaid_email_report
+import datetime
import logging
from django.db.models import Count, Sum
@@ -12,11 +13,17 @@ logger = logging.getLogger(__name__)
class Command(NoArgsCommand):
- def handle_noargs(self, **options):
- if datetime.datetime.now().isoweekday() == 3: # Wednesday
+ def add_arguments(self, parser):
+ parser.add_argument('--force', dest="force", default=False, const=True, action='store_const')
+
+ def handle(self, *args, **options):
+ if datetime.datetime.now().isoweekday() == 3 or options['force']: # Wednesday, or forced run!
+ print('sending email...')
result = FinancialAidApplication.objects.aggregate(Count('id'), Sum('amount_requested'))
template_name = 'admin/weekly'
send_email_message(template_name,
from_=settings.FINANCIAL_AID_EMAIL,
to=settings.FINANCIAL_AID_WEEKLY_REPORT_EMAIL,
context=result)
+ else:
+ print('no email sent, not Wednesday and --force not supplied')
