Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2370: email domain managers on domain invitation [MEOWARD] #3351

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/registrar/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,8 @@ class Meta:

autocomplete_fields = ["user", "domain"]

change_form_template = "django/admin/user_domain_role_change_form.html"

# Fixes a bug where non-superusers are redirected to the main page
def delete_view(self, request, object_id, extra_context=None):
"""Custom delete_view implementation that specifies redirect behaviour"""
Expand Down Expand Up @@ -1500,7 +1502,7 @@ class Meta:

autocomplete_fields = ["domain"]

change_form_template = "django/admin/email_clipboard_change_form.html"
change_form_template = "django/admin/domain_invitation_change_form.html"

# Select domain invitations to change -> Domain invitations
def changelist_view(self, request, extra_context=None):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% extends 'django/admin/email_clipboard_change_form.html' %}
{% load custom_filters %}
{% load i18n static %}

{% block content_subtitle %}
<div class="usa-alert usa-alert--info usa-alert--slim">
<div class="usa-alert__body margin-left-1 maxw-none">
<p class="usa-alert__text maxw-none">
If you add someone to a domain here, it will trigger emails to the invitee and all managers of the domain when you click "save." If you don't want to trigger those emails, use the <a class="usa-link" href="{% url 'admin:registrar_userdomainrole_changelist' %}">User domain roles permissions table</a> instead.
</p>
</div>
</div>
{{ block.super }}
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% extends 'django/admin/email_clipboard_change_form.html' %}
{% load custom_filters %}
{% load i18n static %}

{% block content_subtitle %}
<div class="usa-alert usa-alert--info usa-alert--slim">
<div class="usa-alert__body margin-left-1 maxw-none">
<p class="usa-alert__text maxw-none">
If you add someone to a domain here, it will not trigger any emails. To trigger emails, use the <a class="usa-link" href="{% url 'admin:registrar_domaininvitation_changelist' %}">User Domain Role invitations table</a> instead.
</p>
</div>
</div>
{{ block.super }}
{% endblock %}
43 changes: 43 additions & 0 deletions src/registrar/templates/emails/domain_manager_notification.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{% autoescape off %}{# In a text file, we don't want to have HTML entities escaped #}
Hi,{% if domain_manager and domain_manager.first_name %} {{ domain_manager.first_name }}.{% endif %}

A domain manager was invited to {{ domain.name }}.
DOMAIN: {{ domain.name }}
INVITED BY: {{ requestor_email }}
INVITED ON: {{date}}
MANAGER INVITED: {{ invited_email_address }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Katherine-Osos not important for now, but when we get to multiple portfolios, we may want to consider having the org name on notifications.

(Devs ignore this comment, n/a for your ticket)



----------------------------------------------------------------


NEXT STEPS

The person who received the invitation will become a domain manager once they log in to the
.gov registrar. They'll need to access the registrar using a Login.gov account that's
associated with the invited email address.

If you need to cancel this invitation or remove the domain manager (because they've already
logged in), you can do that by going to this domain in the .gov registrar <https://manage.get.gov/>.


WHY DID YOU RECEIVE THIS EMAIL?

You’re listed as a domain manager for {{ domain.name }}, so you’ll receive a notification whenever
someone is invited to manage that domain.

If you have questions or concerns, reach out to the person who sent the invitation or reply to this email.


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/>
Learn about .gov <https://get.gov>

The .gov registry is a part of the Cybersecurity and Infrastructure Security Agency
(CISA) <https://cisa.gov/>
{% endautoescape %}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A domain manager was invited to {{ domain.name }}
48 changes: 48 additions & 0 deletions src/registrar/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,29 @@ def test_has_model_description(self):
)
self.assertContains(response, "Show more")

@less_console_noise_decorator
def test_has_change_form_description(self):
"""Tests if this model has a model description on the change form view"""
self.client.force_login(self.superuser)

domain, _ = Domain.objects.get_or_create(name="systemofadown.com")

domain_invitation, _ = DomainInvitation.objects.get_or_create(email="[email protected]", domain=domain)

response = self.client.get(
"/admin/registrar/domaininvitation/{}/change/".format(domain_invitation.pk),
follow=True,
)

# Make sure that the page is loaded correctly
self.assertEqual(response.status_code, 200)

# Test for a description snippet
self.assertContains(
response,
"If you add someone to a domain here, it will trigger emails to the invitee and all managers of the domain",
)

@less_console_noise_decorator
def test_get_filters(self):
"""Ensures that our filters are displaying correctly"""
Expand Down Expand Up @@ -1957,6 +1980,31 @@ def test_has_model_description(self):
)
self.assertContains(response, "Show more")

@less_console_noise_decorator
def test_has_change_form_description(self):
"""Tests if this model has a model description on the change form view"""
self.client.force_login(self.superuser)

domain, _ = Domain.objects.get_or_create(name="systemofadown.com")

user_domain_role, _ = UserDomainRole.objects.get_or_create(
user=self.superuser, domain=domain, role=[UserDomainRole.Roles.MANAGER]
)

response = self.client.get(
"/admin/registrar/userdomainrole/{}/change/".format(user_domain_role.pk),
follow=True,
)

# Make sure that the page is loaded correctly
self.assertEqual(response.status_code, 200)

# Test for a description snippet
self.assertContains(
response,
"If you add someone to a domain here, it will not trigger any emails.",
)

def test_domain_sortable(self):
"""Tests if the UserDomainrole sorts by domain correctly"""
with less_console_noise():
Expand Down
Loading
Loading