From 888e47e84b7f5bc7151c61504681eb8d25fce22b Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Thu, 24 Feb 2022 21:59:16 -0500 Subject: [PATCH] [paperwork] Fix various bugs in certification email sending --- paperwork/admin.py | 4 ++-- paperwork/certification_emails.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/paperwork/admin.py b/paperwork/admin.py index be40909..86aee5c 100644 --- a/paperwork/admin.py +++ b/paperwork/admin.py @@ -90,13 +90,13 @@ class CertificationAdmin(admin.ModelAdmin): def send_notifications(self, request, queryset): try: emails = list(all_certification_emails(queryset)) - print(emails) with mail.get_connection() as conn: conn.send_messages(emails) for cert in queryset: - cert.update(shop_lead_notified=Now()) + cert.shop_lead_notified = Now() + cert.save() self.message_user( request, diff --git a/paperwork/certification_emails.py b/paperwork/certification_emails.py index e82c306..0e6f270 100644 --- a/paperwork/certification_emails.py +++ b/paperwork/certification_emails.py @@ -88,7 +88,11 @@ def admin_email(ordered_queryset): f"{len(ordered_queryset)} new CMS Certifications issued", html_body, # TODO: Admin emails should probably be from a group, not all staff - to=[get_user_model().filter(is_staff=True).values("email", flat=True)], + to=( + get_user_model() + .objects.filter(is_staff=True) + .values_list("email", flat=True) + ), )