[paperwork] Fix various bugs in certification email sending

This commit is contained in:
Adam Goldsmith 2022-02-24 21:59:16 -05:00
parent e81170204f
commit 888e47e84b
2 changed files with 7 additions and 3 deletions

View File

@ -90,13 +90,13 @@ class CertificationAdmin(admin.ModelAdmin):
def send_notifications(self, request, queryset): def send_notifications(self, request, queryset):
try: try:
emails = list(all_certification_emails(queryset)) emails = list(all_certification_emails(queryset))
print(emails)
with mail.get_connection() as conn: with mail.get_connection() as conn:
conn.send_messages(emails) conn.send_messages(emails)
for cert in queryset: for cert in queryset:
cert.update(shop_lead_notified=Now()) cert.shop_lead_notified = Now()
cert.save()
self.message_user( self.message_user(
request, request,

View File

@ -88,7 +88,11 @@ def admin_email(ordered_queryset):
f"{len(ordered_queryset)} new CMS Certifications issued", f"{len(ordered_queryset)} new CMS Certifications issued",
html_body, html_body,
# TODO: Admin emails should probably be from a group, not all staff # 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)
),
) )