Skip to content
Snippets Groups Projects
Verified Commit 4f1026f8 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Allow sending data check notifications emails to groups

parent 08c56188
No related branches found
No related tags found
1 merge request!389Add data check system
Pipeline #5029 passed
......@@ -216,12 +216,19 @@ def send_emails_for_data_checks():
(DATA_CHECK_REGISTRY.data_checks_by_name[result["check"]], result["count"])
)
recipient_list = [
p.mail_sender
for p in get_site_preferences()["general__data_checks_recipients"]
if p.email
]
for group in get_site_preferences()["general__data_checks_recipient_groups"]:
recipient_list += [p.mail_sender for p in group.announcement_recipients if p.email]
send_templated_mail(
template_name="data_checks",
from_email=get_site_preferences()["mail__address"],
recipient_list=[
p.email for p in get_site_preferences()["general__data_checks_recipients"]
],
recipient_list=recipient_list,
context={"results": results_with_checks},
)
......
......@@ -13,7 +13,7 @@ from dynamic_preferences.types import (
StringPreference,
)
from .models import Person
from .models import Group, Person
from .registries import person_preferences_registry, site_preferences_registry
from .util.notifications import get_notification_choices_lazy
......@@ -232,3 +232,14 @@ class DataChecksEmailsRecipients(ModelMultipleChoicePreference):
default = []
model = Person
verbose_name = _("Email recipients for data checks problem emails")
@site_preferences_registry.register
class DataChecksEmailsRecipientGroups(ModelMultipleChoicePreference):
"""Email recipient groups for data check problem emails."""
section = general
name = "data_checks_recipient_groups"
default = []
model = Group
verbose_name = _("Email recipient groups for data checks problem emails")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment