[paperwork] Send admin cert emails to specific permission, not all staff

Closes #2
This commit is contained in:
Adam Goldsmith 2022-02-28 16:36:29 -05:00
parent 485c4f0806
commit 5ea485abf0
3 changed files with 33 additions and 2 deletions

View File

@ -87,10 +87,11 @@ def admin_email(ordered_queryset):
return make_multipart_email( return make_multipart_email(
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
to=( to=(
get_user_model() get_user_model()
.objects.filter(is_staff=True) .objects.with_perm(
"paperwork.receive_certification_emails", include_superusers=False
)
.values_list("email", flat=True) .values_list("email", flat=True)
), ),
) )

View File

@ -0,0 +1,24 @@
# Generated by Django 4.0.2 on 2022-03-11 20:28
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("paperwork", "0003_alter_certificationversion_id"),
]
operations = [
migrations.AlterModelOptions(
name="certification",
options={
"permissions": [
(
"receive_certification_emails",
"Receives notifications of all new certifications",
)
]
},
),
]

View File

@ -109,6 +109,12 @@ class Certification(models.Model):
class Meta: class Meta:
db_table = "Certifications" db_table = "Certifications"
permissions = [
(
"receive_certification_emails",
"Receives notifications of all new certifications",
),
]
class InstructorOrVendor(models.Model): class InstructorOrVendor(models.Model):