mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-06-03 19:17:42 +02:00
Merge branch 'main' into za/1271-admin-add-notes
This commit is contained in:
commit
fcb555413a
9 changed files with 46 additions and 55 deletions
1
.github/workflows/migrate.yaml
vendored
1
.github/workflows/migrate.yaml
vendored
|
@ -26,7 +26,6 @@ on:
|
||||||
- rb
|
- rb
|
||||||
- ko
|
- ko
|
||||||
- ab
|
- ab
|
||||||
- bl
|
|
||||||
- rjm
|
- rjm
|
||||||
- dk
|
- dk
|
||||||
|
|
||||||
|
|
1
.github/workflows/reset-db.yaml
vendored
1
.github/workflows/reset-db.yaml
vendored
|
@ -26,7 +26,6 @@ on:
|
||||||
- rb
|
- rb
|
||||||
- ko
|
- ko
|
||||||
- ab
|
- ab
|
||||||
- bl
|
|
||||||
- rjm
|
- rjm
|
||||||
- dk
|
- dk
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
|
@ -660,7 +660,6 @@ ALLOWED_HOSTS = [
|
||||||
"getgov-rb.app.cloud.gov",
|
"getgov-rb.app.cloud.gov",
|
||||||
"getgov-ko.app.cloud.gov",
|
"getgov-ko.app.cloud.gov",
|
||||||
"getgov-ab.app.cloud.gov",
|
"getgov-ab.app.cloud.gov",
|
||||||
"getgov-bl.app.cloud.gov",
|
|
||||||
"getgov-rjm.app.cloud.gov",
|
"getgov-rjm.app.cloud.gov",
|
||||||
"getgov-dk.app.cloud.gov",
|
"getgov-dk.app.cloud.gov",
|
||||||
"manage.get.gov",
|
"manage.get.gov",
|
||||||
|
|
|
@ -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"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -431,11 +431,13 @@ class DomainApplication(TimeStampedModel):
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
help_text="Street address",
|
help_text="Street address",
|
||||||
|
verbose_name="Address line 1",
|
||||||
)
|
)
|
||||||
address_line2 = models.TextField(
|
address_line2 = models.TextField(
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
help_text="Street address line 2 (optional)",
|
help_text="Street address line 2 (optional)",
|
||||||
|
verbose_name="Address line 2",
|
||||||
)
|
)
|
||||||
city = models.TextField(
|
city = models.TextField(
|
||||||
null=True,
|
null=True,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{% autoescape off %}{# In a text file, we don't want to have HTML entities escaped #}
|
{% autoescape off %}{# In a text file, we don't want to have HTML entities escaped #}
|
||||||
Hi.
|
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>.
|
You can manage this domain on the .gov registrar <https://manage.get.gov>.
|
||||||
|
|
||||||
|
|
|
@ -2803,7 +2803,7 @@ class TestDomainManagers(TestDomainOverview):
|
||||||
)
|
)
|
||||||
|
|
||||||
@boto3_mocking.patching
|
@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."""
|
"""Inviting a non existent user sends them an email, with email as the name."""
|
||||||
# make sure there is no user with this email
|
# make sure there is no user with this email
|
||||||
email_address = "mayor@igorville.gov"
|
email_address = "mayor@igorville.gov"
|
||||||
|
@ -2836,13 +2836,13 @@ class TestDomainManagers(TestDomainOverview):
|
||||||
email_content = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"]
|
email_content = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"]
|
||||||
self.assertIn("info@example.com", email_content)
|
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("First", email_content)
|
||||||
self.assertNotIn("Last", email_content)
|
self.assertNotIn("Last", email_content)
|
||||||
self.assertNotIn("First Last", email_content)
|
self.assertNotIn("First Last", email_content)
|
||||||
|
|
||||||
@boto3_mocking.patching
|
@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."""
|
"""Inviting a user sends them an email, with email as the name."""
|
||||||
# Create a fake user object
|
# Create a fake user object
|
||||||
email_address = "mayor@igorville.gov"
|
email_address = "mayor@igorville.gov"
|
||||||
|
@ -2875,13 +2875,13 @@ class TestDomainManagers(TestDomainOverview):
|
||||||
email_content = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"]
|
email_content = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"]
|
||||||
self.assertIn("info@example.com", email_content)
|
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("First", email_content)
|
||||||
self.assertNotIn("Last", email_content)
|
self.assertNotIn("Last", email_content)
|
||||||
self.assertNotIn("First Last", email_content)
|
self.assertNotIn("First Last", email_content)
|
||||||
|
|
||||||
@boto3_mocking.patching
|
@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."""
|
"""Inviting a user sends them an email, with email as the name."""
|
||||||
# Create a fake user object
|
# Create a fake user object
|
||||||
email_address = "mayor@igorville.gov"
|
email_address = "mayor@igorville.gov"
|
||||||
|
@ -2918,7 +2918,7 @@ class TestDomainManagers(TestDomainOverview):
|
||||||
email_content = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"]
|
email_content = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"]
|
||||||
self.assertIn("help@get.gov", email_content)
|
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("First", email_content)
|
||||||
self.assertNotIn("Last", email_content)
|
self.assertNotIn("Last", email_content)
|
||||||
self.assertNotIn("First Last", email_content)
|
self.assertNotIn("First Last", email_content)
|
||||||
|
|
|
@ -648,7 +648,7 @@ class DomainAddUserView(DomainFormBaseView):
|
||||||
"""Get an absolute URL for this domain."""
|
"""Get an absolute URL for this domain."""
|
||||||
return self.request.build_absolute_uri(reverse("domain", kwargs={"pk": self.object.id}))
|
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,
|
"""Performs the sending of the domain invitation email,
|
||||||
does not make a domain information object
|
does not make a domain information object
|
||||||
email: string- email to send to
|
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"""
|
adding a success message to the view if the email sending succeeds"""
|
||||||
|
|
||||||
# Set a default email address to send to for staff
|
# 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
|
# Check if the email requestor has a valid email address
|
||||||
if not requester.is_staff and requester.email is not None and requester.email.strip() != "":
|
if not requestor.is_staff and requestor.email is not None and requestor.email.strip() != "":
|
||||||
requester_email = requester.email
|
requestor_email = requestor.email
|
||||||
elif not requester.is_staff:
|
elif not requestor.is_staff:
|
||||||
messages.error(self.request, "Can't send invitation email. No email is associated with your account.")
|
messages.error(self.request, "Can't send invitation email. No email is associated with your account.")
|
||||||
logger.error(
|
logger.error(
|
||||||
f"Can't send email to '{email}' on domain '{self.object}'."
|
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,
|
exc_info=True,
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
@ -678,7 +678,7 @@ class DomainAddUserView(DomainFormBaseView):
|
||||||
context={
|
context={
|
||||||
"domain_url": self._domain_abs_url(),
|
"domain_url": self._domain_abs_url(),
|
||||||
"domain": self.object,
|
"domain": self.object,
|
||||||
"requester_email": requester_email,
|
"requestor_email": requestor_email,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
except EmailSendingError:
|
except EmailSendingError:
|
||||||
|
@ -693,7 +693,7 @@ class DomainAddUserView(DomainFormBaseView):
|
||||||
if add_success:
|
if add_success:
|
||||||
messages.success(self.request, f"{email} has been invited to this domain.")
|
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."""
|
"""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)
|
invitation, created = DomainInvitation.objects.get_or_create(email=email_address, domain=self.object)
|
||||||
if not created:
|
if not created:
|
||||||
|
@ -703,22 +703,22 @@ class DomainAddUserView(DomainFormBaseView):
|
||||||
f"{email_address} has already been invited to this domain.",
|
f"{email_address} has already been invited to this domain.",
|
||||||
)
|
)
|
||||||
else:
|
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())
|
return redirect(self.get_success_url())
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
"""Add the specified user on this domain."""
|
"""Add the specified user on this domain."""
|
||||||
requested_email = form.cleaned_data["email"]
|
requested_email = form.cleaned_data["email"]
|
||||||
requester = self.request.user
|
requestor = self.request.user
|
||||||
# look up a user with that email
|
# look up a user with that email
|
||||||
try:
|
try:
|
||||||
requested_user = User.objects.get(email=requested_email)
|
requested_user = User.objects.get(email=requested_email)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
# no matching user, go make an invitation
|
# no matching user, go make an invitation
|
||||||
return self._make_invitation(requested_email, requester)
|
return self._make_invitation(requested_email, requestor)
|
||||||
else:
|
else:
|
||||||
# if user already exists then just send an email
|
# 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:
|
try:
|
||||||
UserDomainRole.objects.create(
|
UserDomainRole.objects.create(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue