Merge branch 'main' into za/1271-admin-add-notes

This commit is contained in:
zandercymatics 2024-01-25 13:48:25 -07:00
commit fcb555413a
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
9 changed files with 46 additions and 55 deletions

View file

@ -26,7 +26,6 @@ on:
- rb
- ko
- ab
- bl
- rjm
- dk

View file

@ -26,7 +26,6 @@ on:
- rb
- ko
- ab
- bl
- rjm
- dk

View file

@ -1,32 +0,0 @@
---
applications:
- name: getgov-bl
buildpacks:
- python_buildpack
path: ../../src
instances: 1
memory: 512M
stack: cflinuxfs4
timeout: 180
command: ./run.sh
health-check-type: http
health-check-http-endpoint: /health
health-check-invocation-timeout: 40
env:
# Send stdout and stderr straight to the terminal without buffering
PYTHONUNBUFFERED: yup
# Tell Django where to find its configuration
DJANGO_SETTINGS_MODULE: registrar.config.settings
# Tell Django where it is being hosted
DJANGO_BASE_URL: https://getgov-bl.app.cloud.gov
# Tell Django how much stuff to log
DJANGO_LOG_LEVEL: INFO
# default public site location
GETGOV_PUBLIC_SITE_URL: https://get.gov
# Flag to disable/enable features in prod environments
IS_PRODUCTION: False
routes:
- route: getgov-bl.app.cloud.gov
services:
- getgov-credentials
- getgov-bl-database

View file

@ -660,7 +660,6 @@ ALLOWED_HOSTS = [
"getgov-rb.app.cloud.gov",
"getgov-ko.app.cloud.gov",
"getgov-ab.app.cloud.gov",
"getgov-bl.app.cloud.gov",
"getgov-rjm.app.cloud.gov",
"getgov-dk.app.cloud.gov",
"manage.get.gov",

View file

@ -0,0 +1,24 @@
# Generated by Django 4.2.7 on 2024-01-23 22:01
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("registrar", "0063_veryimportantperson"),
]
operations = [
migrations.AlterField(
model_name="domainapplication",
name="address_line1",
field=models.TextField(blank=True, help_text="Street address", null=True, verbose_name="Address line 1"),
),
migrations.AlterField(
model_name="domainapplication",
name="address_line2",
field=models.TextField(
blank=True, help_text="Street address line 2 (optional)", null=True, verbose_name="Address line 2"
),
),
]

View file

@ -431,11 +431,13 @@ class DomainApplication(TimeStampedModel):
null=True,
blank=True,
help_text="Street address",
verbose_name="Address line 1",
)
address_line2 = models.TextField(
null=True,
blank=True,
help_text="Street address line 2 (optional)",
verbose_name="Address line 2",
)
city = models.TextField(
null=True,

View file

@ -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>.

View file

@ -2803,7 +2803,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"
@ -2836,13 +2836,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"
@ -2875,13 +2875,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"
@ -2918,7 +2918,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)

View file

@ -648,7 +648,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
@ -656,16 +656,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
@ -678,7 +678,7 @@ class DomainAddUserView(DomainFormBaseView):
context={
"domain_url": self._domain_abs_url(),
"domain": self.object,
"requester_email": requester_email,
"requestor_email": requestor_email,
},
)
except EmailSendingError:
@ -693,7 +693,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:
@ -703,22 +703,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(