mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-24 19:48:36 +02:00
Change requester to requestor in code
This commit is contained in:
parent
e88c50c173
commit
e9160e67f8
3 changed files with 20 additions and 20 deletions
|
@ -1,7 +1,7 @@
|
|||
{% autoescape off %}{# In a text file, we don't want to have HTML entities escaped #}
|
||||
Hi.
|
||||
|
||||
{{ requester_email }} has added you as a manager on {{ domain.name }}.
|
||||
{{ requestor_email }} has added you as a manager on {{ domain.name }}.
|
||||
|
||||
You can manage this domain on the .gov registrar <https://manage.get.gov>.
|
||||
|
||||
|
|
|
@ -2590,7 +2590,7 @@ class TestDomainManagers(TestDomainOverview):
|
|||
)
|
||||
|
||||
@boto3_mocking.patching
|
||||
def test_domain_invitation_email_has_email_as_requester_non_existent(self):
|
||||
def test_domain_invitation_email_has_email_as_requestor_non_existent(self):
|
||||
"""Inviting a non existent user sends them an email, with email as the name."""
|
||||
# make sure there is no user with this email
|
||||
email_address = "mayor@igorville.gov"
|
||||
|
@ -2623,13 +2623,13 @@ class TestDomainManagers(TestDomainOverview):
|
|||
email_content = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"]
|
||||
self.assertIn("info@example.com", email_content)
|
||||
|
||||
# Check that the requesters first/last name do not exist
|
||||
# Check that the requestors first/last name do not exist
|
||||
self.assertNotIn("First", email_content)
|
||||
self.assertNotIn("Last", email_content)
|
||||
self.assertNotIn("First Last", email_content)
|
||||
|
||||
@boto3_mocking.patching
|
||||
def test_domain_invitation_email_has_email_as_requester(self):
|
||||
def test_domain_invitation_email_has_email_as_requestor(self):
|
||||
"""Inviting a user sends them an email, with email as the name."""
|
||||
# Create a fake user object
|
||||
email_address = "mayor@igorville.gov"
|
||||
|
@ -2662,13 +2662,13 @@ class TestDomainManagers(TestDomainOverview):
|
|||
email_content = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"]
|
||||
self.assertIn("info@example.com", email_content)
|
||||
|
||||
# Check that the requesters first/last name do not exist
|
||||
# Check that the requestors first/last name do not exist
|
||||
self.assertNotIn("First", email_content)
|
||||
self.assertNotIn("Last", email_content)
|
||||
self.assertNotIn("First Last", email_content)
|
||||
|
||||
@boto3_mocking.patching
|
||||
def test_domain_invitation_email_has_email_as_requester_staff(self):
|
||||
def test_domain_invitation_email_has_email_as_requestor_staff(self):
|
||||
"""Inviting a user sends them an email, with email as the name."""
|
||||
# Create a fake user object
|
||||
email_address = "mayor@igorville.gov"
|
||||
|
@ -2705,7 +2705,7 @@ class TestDomainManagers(TestDomainOverview):
|
|||
email_content = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"]
|
||||
self.assertIn("help@get.gov", email_content)
|
||||
|
||||
# Check that the requesters first/last name do not exist
|
||||
# Check that the requestors first/last name do not exist
|
||||
self.assertNotIn("First", email_content)
|
||||
self.assertNotIn("Last", email_content)
|
||||
self.assertNotIn("First Last", email_content)
|
||||
|
|
|
@ -646,7 +646,7 @@ class DomainAddUserView(DomainFormBaseView):
|
|||
"""Get an absolute URL for this domain."""
|
||||
return self.request.build_absolute_uri(reverse("domain", kwargs={"pk": self.object.id}))
|
||||
|
||||
def _send_domain_invitation_email(self, email: str, requester: User, add_success=True):
|
||||
def _send_domain_invitation_email(self, email: str, requestor: User, add_success=True):
|
||||
"""Performs the sending of the domain invitation email,
|
||||
does not make a domain information object
|
||||
email: string- email to send to
|
||||
|
@ -654,16 +654,16 @@ class DomainAddUserView(DomainFormBaseView):
|
|||
adding a success message to the view if the email sending succeeds"""
|
||||
|
||||
# Set a default email address to send to for staff
|
||||
requester_email = "help@get.gov"
|
||||
requestor_email = "help@get.gov"
|
||||
|
||||
# Check if the email requester has a valid email address
|
||||
if not requester.is_staff and requester.email is not None and requester.email.strip() != "":
|
||||
requester_email = requester.email
|
||||
elif not requester.is_staff:
|
||||
# Check if the email requestor has a valid email address
|
||||
if not requestor.is_staff and requestor.email is not None and requestor.email.strip() != "":
|
||||
requestor_email = requestor.email
|
||||
elif not requestor.is_staff:
|
||||
messages.error(self.request, "Can't send invitation email. No email is associated with your account.")
|
||||
logger.error(
|
||||
f"Can't send email to '{email}' on domain '{self.object}'."
|
||||
f"No email exists for the requester '{requester.username}'.",
|
||||
f"No email exists for the requestor '{requestor.username}'.",
|
||||
exc_info=True,
|
||||
)
|
||||
return None
|
||||
|
@ -676,7 +676,7 @@ class DomainAddUserView(DomainFormBaseView):
|
|||
context={
|
||||
"domain_url": self._domain_abs_url(),
|
||||
"domain": self.object,
|
||||
"requester_email": requester_email,
|
||||
"requestor_email": requestor_email,
|
||||
},
|
||||
)
|
||||
except EmailSendingError:
|
||||
|
@ -691,7 +691,7 @@ class DomainAddUserView(DomainFormBaseView):
|
|||
if add_success:
|
||||
messages.success(self.request, f"{email} has been invited to this domain.")
|
||||
|
||||
def _make_invitation(self, email_address: str, requester: User):
|
||||
def _make_invitation(self, email_address: str, requestor: User):
|
||||
"""Make a Domain invitation for this email and redirect with a message."""
|
||||
invitation, created = DomainInvitation.objects.get_or_create(email=email_address, domain=self.object)
|
||||
if not created:
|
||||
|
@ -701,22 +701,22 @@ class DomainAddUserView(DomainFormBaseView):
|
|||
f"{email_address} has already been invited to this domain.",
|
||||
)
|
||||
else:
|
||||
self._send_domain_invitation_email(email=email_address, requester=requester)
|
||||
self._send_domain_invitation_email(email=email_address, requestor=requestor)
|
||||
return redirect(self.get_success_url())
|
||||
|
||||
def form_valid(self, form):
|
||||
"""Add the specified user on this domain."""
|
||||
requested_email = form.cleaned_data["email"]
|
||||
requester = self.request.user
|
||||
requestor = self.request.user
|
||||
# look up a user with that email
|
||||
try:
|
||||
requested_user = User.objects.get(email=requested_email)
|
||||
except User.DoesNotExist:
|
||||
# no matching user, go make an invitation
|
||||
return self._make_invitation(requested_email, requester)
|
||||
return self._make_invitation(requested_email, requestor)
|
||||
else:
|
||||
# if user already exists then just send an email
|
||||
self._send_domain_invitation_email(requested_email, requester, add_success=False)
|
||||
self._send_domain_invitation_email(requested_email, requestor, add_success=False)
|
||||
|
||||
try:
|
||||
UserDomainRole.objects.create(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue