mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-13 13:09:41 +02:00
send notification on nameserver changes
This commit is contained in:
parent
ffaf3b5a37
commit
9c090ae5fe
2 changed files with 29 additions and 0 deletions
|
@ -39,6 +39,7 @@ class UserFixture:
|
||||||
"username": "be17c826-e200-4999-9389-2ded48c43691",
|
"username": "be17c826-e200-4999-9389-2ded48c43691",
|
||||||
"first_name": "Matthew",
|
"first_name": "Matthew",
|
||||||
"last_name": "Spence",
|
"last_name": "Spence",
|
||||||
|
"email": "mspence1845@gmail.com"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"username": "5f283494-31bd-49b5-b024-a7e7cae00848",
|
"username": "5f283494-31bd-49b5-b024-a7e7cae00848",
|
||||||
|
@ -155,6 +156,7 @@ class UserFixture:
|
||||||
"username": "d6bf296b-fac5-47ff-9c12-f88ccc5c1b99",
|
"username": "d6bf296b-fac5-47ff-9c12-f88ccc5c1b99",
|
||||||
"first_name": "Matthew-Analyst",
|
"first_name": "Matthew-Analyst",
|
||||||
"last_name": "Spence-Analyst",
|
"last_name": "Spence-Analyst",
|
||||||
|
"email": "mspence1845+1@gmail.com"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"username": "319c490d-453b-43d9-bc4d-7d6cd8ff6844",
|
"username": "319c490d-453b-43d9-bc4d-7d6cd8ff6844",
|
||||||
|
|
|
@ -441,6 +441,9 @@ class DomainNameserversView(DomainFormBaseView):
|
||||||
# no server information in this field, skip it
|
# no server information in this field, skip it
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
old_nameservers = self.object.nameservers
|
||||||
|
should_notify = old_nameservers and old_nameservers != nameservers
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.object.nameservers = nameservers
|
self.object.nameservers = nameservers
|
||||||
except NameserverError as Err:
|
except NameserverError as Err:
|
||||||
|
@ -467,6 +470,30 @@ class DomainNameserversView(DomainFormBaseView):
|
||||||
"48 hours to propagate across the internet.",
|
"48 hours to propagate across the internet.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# if the nameservers where changed, send notification to domain managers.
|
||||||
|
if should_notify:
|
||||||
|
managers = UserDomainRole.objects.filter(domain=self.object.name, role=UserDomainRole.Roles.MANAGER)
|
||||||
|
emails = list(managers.values_list("user", flat=True).values_list("email", flat=True))
|
||||||
|
to_addresses=', '.join(emails)
|
||||||
|
|
||||||
|
try:
|
||||||
|
send_templated_email(
|
||||||
|
"templateName",
|
||||||
|
"Subject Template Name",
|
||||||
|
to_address=to_addresses,
|
||||||
|
context={
|
||||||
|
"nameservers": nameservers,
|
||||||
|
"domain": self.object,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
except EmailSendingError as exc:
|
||||||
|
logger.warn(
|
||||||
|
"Could not sent notification email to %s for domain %s",
|
||||||
|
to_addresses,
|
||||||
|
self.object,
|
||||||
|
exc_info=True,
|
||||||
|
)
|
||||||
|
|
||||||
# superclass has the redirect
|
# superclass has the redirect
|
||||||
return super().form_valid(formset)
|
return super().form_valid(formset)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue