def handle(self, *args, **options): mailer = Mailer.objects.all() t = datetime.datetime.strptime(options['print_date'], DATE_FORMAT) for mail in mailer: shifts = Shift.objects.filter(facility=mail.facility).filter( ending_time__year=t.strftime("%Y"), ending_time__month=t.strftime("%m"), ending_time__day=t.strftime("%d")) \ .order_by('task', 'ending_time') \ .annotate(volunteer_count=Count('helpers')) \ .select_related('task', 'facility') \ .prefetch_related('helpers', 'helpers__user') # if it's not used anyway, we maybe shouldn't even render it? # # message = render_to_string('shifts_today.html', locals()) iua = GenerateExcelSheet(shifts=shifts, mailer=mail) iua.send_file()
def handle(self, *args, **options): mailer = Mailer.objects.all() t = datetime.datetime.strptime(options['print_date'], DATE_FORMAT) for mail in mailer: needs = Need.objects.filter(location=mail.location).filter( ending_time__year=t.strftime("%Y"), ending_time__month=t.strftime("%m"), ending_time__day=t.strftime("%d")) \ .order_by('topic', 'ending_time') \ .annotate(volunteer_count=Count('helpers')) \ .select_related('topic', 'location') \ .prefetch_related('helpers', 'helpers__user') # if it's not used anyway, we maybe shouldn't even render it? # # message = render_to_string('shifts_today.html', locals()) iua = GenerateExcelSheet(shifts=needs, mailer=mail) iua.send_file()
def handle(self, *args, **options): mailer = Mailer.objects.all() for mail in mailer: now = datetime.datetime.now() needs = Need.objects.filter(location=mail.location).\ filter( time_period_to__date_time__year=now.strftime("%Y"), time_period_to__date_time__month=now.strftime("%m"), time_period_to__date_time__day=now.strftime("%d"))\ .order_by('topic', 'time_period_to__date_time') message = render_to_string('shifts_today.html', locals()) iua = GenerateExcelSheet(needs=needs, mailer=mail)