Merge pull request #1026 from cisagov/rh/482-youve-been-added-to-domain

482 -- Domain Invitation to You've Been Added To A Domain!
This commit is contained in:
Rebecca H 2023-09-25 09:25:34 -07:00 committed by GitHub
commit 4d4a14a187
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 6 deletions

View file

@ -1,6 +1,32 @@
You have been invited to manage the domain {{ domain.name }} on get.gov,
the registrar for .gov domain names.
{% autoescape off %}{# In a text file, we don't want to have HTML entities escaped #}
Hi.
To accept your invitation, go to <{{ domain_url }}>.
{{ full_name }} has added you as a manager on {{ domain.name }}.
You will need to log in with a Login.gov account using this email address.
YOU NEED A LOGIN.GOV ACCOUNT
Youll need a Login.gov account to manage your .gov domain. Login.gov provides
a simple and secure process for signing into many government services with one
account. If you dont already have one, follow these steps to create your
Login.gov account <https://login.gov/help/get-started/create-your-account/>.
DOMAIN MANAGEMENT
As a .gov domain manager you can add or update information about your domain.
Youll also serve as a contact for your .gov domain. Please keep your contact
information updated. Learn more about domain management <https://get.gov/help/>.
SOMETHING WRONG?
If youre not affiliated with {{ domain.name }} or think you received this
message in error, contact the .gov team <https://get.gov/help/#contact-us>.
THANK YOU
.Gov helps the public identify official, trusted information. Thank you for
using a .gov domain.
----------------------------------------------------------------
The .gov team
Contact us: <https://get.gov/contact/>
Visit <https://get.gov>
{% endautoescape %}

View file

@ -1 +1 @@
You are invited to manage {{ domain.name }} on get.gov
Youve been added to a .gov domain

View file

@ -457,6 +457,7 @@ def completed_application(
has_anything_else=True,
status=DomainApplication.STARTED,
user=False,
name="city.gov",
):
"""A completed domain application."""
if not user:
@ -468,7 +469,7 @@ def completed_application(
email="testy@town.com",
phone="(555) 555 5555",
)
domain, _ = DraftDomain.objects.get_or_create(name="city.gov")
domain, _ = DraftDomain.objects.get_or_create(name=name)
alt, _ = Website.objects.get_or_create(website="city1.gov")
current, _ = Website.objects.get_or_create(website="city.com")
you, _ = Contact.objects.get_or_create(

View file

@ -1079,6 +1079,7 @@ class TestWithDomainPermissions(TestWithUser):
self.domain_information.delete()
if hasattr(self.domain, "contacts"):
self.domain.contacts.all().delete()
DomainApplication.objects.all().delete()
self.domain.delete()
self.role.delete()
except ValueError: # pass if already deleted
@ -1197,6 +1198,10 @@ class TestDomainDetail(TestWithDomainPermissions, WebTest):
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
self.domain_information, _ = DomainInformation.objects.get_or_create(
creator=self.user, domain=self.domain
)
add_page = self.app.get(
reverse("domain-users-add", kwargs={"pk": self.domain.id})
)
@ -1218,6 +1223,10 @@ class TestDomainDetail(TestWithDomainPermissions, WebTest):
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
self.domain_information, _ = DomainInformation.objects.get_or_create(
creator=self.user, domain=self.domain
)
mock_client = MagicMock()
mock_client_instance = mock_client.return_value
with boto3_mocking.clients.handler_for("sesv2", mock_client):
@ -1270,6 +1279,11 @@ class TestDomainDetail(TestWithDomainPermissions, WebTest):
add_page = self.app.get(
reverse("domain-users-add", kwargs={"pk": self.domain.id})
)
self.domain_information, _ = DomainInformation.objects.get_or_create(
creator=self.user, domain=self.domain
)
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
add_page.form["email"] = EMAIL
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)

View file

@ -16,6 +16,7 @@ from django.views.generic.edit import FormMixin
from registrar.models import (
Domain,
DomainInformation,
DomainInvitation,
User,
UserDomainRole,
@ -335,6 +336,11 @@ class DomainAddUserView(DomainPermissionView, FormMixin):
)
else:
# created a new invitation in the database, so send an email
domaininfo = DomainInformation.objects.filter(domain=self.object)
first = domaininfo.first().creator.first_name
last = domaininfo.first().creator.last_name
full_name = f"{first} {last}"
try:
send_templated_email(
"emails/domain_invitation.txt",
@ -343,6 +349,7 @@ class DomainAddUserView(DomainPermissionView, FormMixin):
context={
"domain_url": self._domain_abs_url(),
"domain": self.object,
"full_name": full_name,
},
)
except EmailSendingError: