Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
rachidatecs committed Nov 28, 2024
2 parents 820a365 + 9e190da commit 7547a56
Show file tree
Hide file tree
Showing 16 changed files with 288 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/registrar/assets/src/sass/_theme/_forms.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@use "uswds-core" as *;
@use "cisa_colors" as *;
@use "typography" as *;

.usa-form .usa-button {
margin-top: units(3);
Expand Down Expand Up @@ -69,9 +70,9 @@ legend.float-left-tablet + button.float-right-tablet {
}

.read-only-label {
font-size: size('body', 'sm');
@extend .h4--sm-05;
font-weight: bold;
color: color('primary-dark');
margin-bottom: units(0.5);
}

.read-only-value {
Expand Down
7 changes: 7 additions & 0 deletions src/registrar/assets/src/sass/_theme/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ h2 {
color: color('primary-darker');
}

.h4--sm-05 {
font-size: size('body', 'sm');
font-weight: normal;
color: color('primary');
margin-bottom: units(0.5);
}

// Normalize typography in forms
.usa-form,
.usa-form fieldset {
Expand Down
2 changes: 2 additions & 0 deletions src/registrar/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def portfolio_permissions(request):
"has_organization_feature_flag": False,
"has_organization_requests_flag": False,
"has_organization_members_flag": False,
"is_portfolio_admin": False,
}
try:
portfolio = request.session.get("portfolio")
Expand All @@ -88,6 +89,7 @@ def portfolio_permissions(request):
"has_organization_feature_flag": True,
"has_organization_requests_flag": request.user.has_organization_requests_flag(),
"has_organization_members_flag": request.user.has_organization_members_flag(),
"is_portfolio_admin": request.user.is_portfolio_admin(portfolio),
}
return portfolio_context

Expand Down
3 changes: 3 additions & 0 deletions src/registrar/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ def has_view_suborganization_portfolio_permission(self, portfolio):
def has_edit_suborganization_portfolio_permission(self, portfolio):
return self._has_portfolio_permission(portfolio, UserPortfolioPermissionChoices.EDIT_SUBORGANIZATION)

def is_portfolio_admin(self, portfolio):
return "Admin" in self.portfolio_role_summary(portfolio)

def get_first_portfolio(self):
permission = self.portfolio_permissions.first()
if permission:
Expand Down
20 changes: 20 additions & 0 deletions src/registrar/templates/domain_add_user.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@

{% block domain_content %}
{% block breadcrumb %}
{% if portfolio %}
<!-- Navigation breadcrumbs -->
<nav class="usa-breadcrumb padding-top-0" aria-label="Domain breadcrumb">
<ol class="usa-breadcrumb__list">
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domains' %}" class="usa-breadcrumb__link"><span>Domains</span></a>
</li>
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domain' pk=domain.id %}" class="usa-breadcrumb__link"><span>{{ domain.name }}</span></a>
</li>
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domain-users' pk=domain.id %}" class="usa-breadcrumb__link"><span>Domain managers</span></a>
</li>
<li class="usa-breadcrumb__list-item usa-current" aria-current="page">
<span>Add a domain manager</span>
</li>
</ol>
</nav>
{% else %}
{% url 'domain-users' pk=domain.id as url %}
<nav class="usa-breadcrumb padding-top-0" aria-label="Domain manager breadcrumb">
<ol class="usa-breadcrumb__list">
Expand All @@ -16,6 +35,7 @@
</li>
</ol>
</nav>
{% endif %}
{% endblock breadcrumb %}
<h1>Add a domain manager</h1>
{% if has_organization_feature_flag %}
Expand Down
34 changes: 29 additions & 5 deletions src/registrar/templates/domain_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
{% load custom_filters %}

{% block domain_content %}
{% block breadcrumb %}
{% if portfolio %}
<!-- Navigation breadcrumbs -->
<nav class="usa-breadcrumb padding-top-0" aria-label="Domain breadcrumb">
<ol class="usa-breadcrumb__list">
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domains' %}" class="usa-breadcrumb__link"><span>Domains</span></a>
</li>
<li class="usa-breadcrumb__list-item usa-current" aria-current="page">
<span>{{ domain.name }}</span>
</li>
</ol>
</nav>
{% endif %}
{% endblock breadcrumb %}

{{ block.super }}
<div class="margin-top-4 tablet:grid-col-10">
<h2 class="text-bold text-primary-dark domain-name-wrap">{{ domain.name }}</h2>
Expand Down Expand Up @@ -74,13 +90,17 @@ <h3 class="margin-top-3"> DNS name servers </h3>
{% include "includes/summary_item.html" with title='DNSSEC' value='Not Enabled' edit_link=url editable=is_editable %}
{% endif %}

{% if portfolio and has_any_domains_portfolio_permission and has_view_suborganization_portfolio_permission %}
{% url 'domain-suborganization' pk=domain.id as url %}
{% include "includes/summary_item.html" with title='Suborganization' value=domain.domain_info.sub_organization edit_link=url editable=is_editable|and:has_edit_suborganization_portfolio_permission %}
{% if portfolio %}
{% if has_any_domains_portfolio_permission and has_edit_suborganization_portfolio_permission %}
{% url 'domain-suborganization' pk=domain.id as url %}
{% include "includes/summary_item.html" with title='Suborganization' value=domain.domain_info.sub_organization edit_link=url editable=is_editable|and:has_edit_suborganization_portfolio_permission %}
{% elif has_any_domains_portfolio_permission and has_view_suborganization_portfolio_permission %}
{% url 'domain-suborganization' pk=domain.id as url %}
{% include "includes/summary_item.html" with title='Suborganization' value=domain.domain_info.sub_organization edit_link=url editable=is_editable|and:has_view_suborganization_portfolio_permission view_button=True %}
{% endif %}
{% else %}
{% url 'domain-org-name-address' pk=domain.id as url %}
{% include "includes/summary_item.html" with title='Organization' value=domain.domain_info address='true' edit_link=url editable=is_editable %}

{% url 'domain-senior-official' pk=domain.id as url %}
{% include "includes/summary_item.html" with title='Senior official' value=domain.domain_info.senior_official contact='true' edit_link=url editable=is_editable %}
{% endif %}
Expand All @@ -92,7 +112,11 @@ <h3 class="margin-top-3"> DNS name servers </h3>
{% include "includes/summary_item.html" with title='Security email' value='None provided' edit_link=url editable=is_editable %}
{% endif %}
{% url 'domain-users' pk=domain.id as url %}
{% include "includes/summary_item.html" with title='Domain managers' users='true' list=True value=domain.permissions.all edit_link=url editable=is_editable %}
{% if portfolio %}
{% include "includes/summary_item.html" with title='Domain managers' domain_permissions=True value=domain edit_link=url editable=is_editable %}
{% else %}
{% include "includes/summary_item.html" with title='Domain managers' list=True users=True value=domain.permissions.all edit_link=url editable=is_editable %}
{% endif %}

</div>
{% endblock %} {# domain_content #}
18 changes: 18 additions & 0 deletions src/registrar/templates/domain_dns.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@
{% block title %}DNS | {{ domain.name }} | {% endblock %}

{% block domain_content %}
{% block breadcrumb %}
{% if portfolio %}
<!-- Navigation breadcrumbs -->
<nav class="usa-breadcrumb padding-top-0" aria-label="Domain breadcrumb">
<ol class="usa-breadcrumb__list">
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domains' %}" class="usa-breadcrumb__link"><span>Domains</span></a>
</li>
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domain' pk=domain.id %}" class="usa-breadcrumb__link"><span>{{ domain.name }}</span></a>
</li>
<li class="usa-breadcrumb__list-item usa-current" aria-current="page">
<span>DNS</span>
</li>
</ol>
</nav>
{% endif %}
{% endblock breadcrumb %}

<h1>DNS</h1>

Expand Down
22 changes: 22 additions & 0 deletions src/registrar/templates/domain_dnssec.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@

{% block domain_content %}

{% block breadcrumb %}
{% if portfolio %}
<!-- Navigation breadcrumbs -->
<nav class="usa-breadcrumb padding-top-0" aria-label="Domain breadcrumb">
<ol class="usa-breadcrumb__list">
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domains' %}" class="usa-breadcrumb__link"><span>Domains</span></a>
</li>
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domain' pk=domain.id %}" class="usa-breadcrumb__link"><span>{{ domain.name }}</span></a>
</li>
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domain-dns' pk=domain.id %}" class="usa-breadcrumb__link"><span>DNS</span></a>
</li>
<li class="usa-breadcrumb__list-item usa-current" aria-current="page">
<span>DNSSEC</span>
</li>
</ol>
</nav>
{% endif %}
{% endblock breadcrumb %}

<h1>DNSSEC</h1>

<p>DNSSEC, or DNS Security Extensions, is an additional security layer to protect your website. Enabling DNSSEC ensures that when someone visits your domain, they can be certain that it’s connecting to the correct server, preventing potential hijacking or tampering with your domain's records.</p>
Expand Down
26 changes: 26 additions & 0 deletions src/registrar/templates/domain_dsdata.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@
{% block title %}DS data | {{ domain.name }} | {% endblock %}

{% block domain_content %}

{% block breadcrumb %}
{% if portfolio %}
<!-- Navigation breadcrumbs -->
<nav class="usa-breadcrumb padding-top-0" aria-label="Domain breadcrumb">
<ol class="usa-breadcrumb__list">
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domains' %}" class="usa-breadcrumb__link"><span>Domains</span></a>
</li>
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domain' pk=domain.id %}" class="usa-breadcrumb__link"><span>{{ domain.name }}</span></a>
</li>
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domain-dns' pk=domain.id %}" class="usa-breadcrumb__link"><span>DNS</span></a>
</li>
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domain-dns-dnssec' pk=domain.id %}" class="usa-breadcrumb__link"><span>DNSSEC</span></a>
</li>
<li class="usa-breadcrumb__list-item usa-current" aria-current="page">
<span>DS data</span>
</li>
</ol>
</nav>
{% endif %}
{% endblock breadcrumb %}

{% if domain.dnssecdata is None %}
<div class="usa-alert usa-alert--info usa-alert--slim margin-bottom-3">
<div class="usa-alert__body">
Expand Down
22 changes: 22 additions & 0 deletions src/registrar/templates/domain_nameservers.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@
{% block title %}DNS name servers | {{ domain.name }} | {% endblock %}

{% block domain_content %}
{% block breadcrumb %}
{% if portfolio %}
<!-- Navigation breadcrumbs -->
<nav class="usa-breadcrumb padding-top-0" aria-label="Domain breadcrumb">
<ol class="usa-breadcrumb__list">
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domains' %}" class="usa-breadcrumb__link"><span>Domains</span></a>
</li>
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domain' pk=domain.id %}" class="usa-breadcrumb__link"><span>{{ domain.name }}</span></a>
</li>
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domain-dns' pk=domain.id %}" class="usa-breadcrumb__link"><span>DNS</span></a>
</li>
<li class="usa-breadcrumb__list-item usa-current" aria-current="page">
<span>DNS name servers</span>
</li>
</ol>
</nav>
{% endif %}
{% endblock breadcrumb %}

{# this is right after the messages block in the parent template #}
{% for form in formset %}
{% include "includes/form_errors.html" with form=form %}
Expand Down
19 changes: 19 additions & 0 deletions src/registrar/templates/domain_security_email.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@
{% block title %}Security email | {{ domain.name }} | {% endblock %}

{% block domain_content %}
{% block breadcrumb %}
{% if portfolio %}
<!-- Navigation breadcrumbs -->
<nav class="usa-breadcrumb padding-top-0" aria-label="Domain breadcrumb">
<ol class="usa-breadcrumb__list">
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domains' %}" class="usa-breadcrumb__link"><span>Domains</span></a>
</li>
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domain' pk=domain.id %}" class="usa-breadcrumb__link"><span>{{ domain.name }}</span></a>
</li>
<li class="usa-breadcrumb__list-item usa-current" aria-current="page">
<span>Security email</span>
</li>
</ol>
</nav>
{% endif %}
{% endblock breadcrumb %}

{% include "includes/form_errors.html" with form=form %}

<h1>Security email</h1>
Expand Down
21 changes: 21 additions & 0 deletions src/registrar/templates/domain_suborganization.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,30 @@
{% block title %}Suborganization{% if suborganization_name %} | suborganization_name{% endif %} | {% endblock %}

{% block domain_content %}

{% block breadcrumb %}
{% if portfolio %}
<!-- Navigation breadcrumbs -->
<nav class="usa-breadcrumb padding-top-0" aria-label="Domain breadcrumb">
<ol class="usa-breadcrumb__list">
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domains' %}" class="usa-breadcrumb__link"><span>Domains</span></a>
</li>
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domain' pk=domain.id %}" class="usa-breadcrumb__link"><span>{{ domain.name }}</span></a>
</li>
<li class="usa-breadcrumb__list-item usa-current" aria-current="page">
<span>Suborganization</span>
</li>
</ol>
</nav>
{% endif %}
{% endblock breadcrumb %}

{# this is right after the messages block in the parent template #}
{% include "includes/form_errors.html" with form=form %}


<h1>Suborganization</h1>

<p>
Expand Down
19 changes: 19 additions & 0 deletions src/registrar/templates/domain_users.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@
{% block title %}Domain managers | {{ domain.name }} | {% endblock %}

{% block domain_content %}
{% block breadcrumb %}
{% if portfolio %}
<!-- Navigation breadcrumbs -->
<nav class="usa-breadcrumb padding-top-0" aria-label="Domain breadcrumb">
<ol class="usa-breadcrumb__list">
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domains' %}" class="usa-breadcrumb__link"><span>Domains</span></a>
</li>
<li class="usa-breadcrumb__list-item">
<a href="{% url 'domain' pk=domain.id %}" class="usa-breadcrumb__link"><span>{{ domain.name }}</span></a>
</li>
<li class="usa-breadcrumb__list-item usa-current" aria-current="page">
<span>Domain managers</span>
</li>
</ol>
</nav>
{% endif %}
{% endblock breadcrumb %}

<h1>Domain managers</h1>

{% comment %}Copy below differs depending on whether view is in portfolio mode.{% endcomment %}
Expand Down
20 changes: 20 additions & 0 deletions src/registrar/templates/includes/summary_item.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,26 @@ <h4 class="register-form-review-header">{{ sub_header_text }}</h4>
{% endfor %}
</ul>
{% endif %}
{% elif domain_permissions %}
{% if value.permissions.all %}
{% if value.permissions|length == 1 %}
<p class="margin-top-0">{{ value.permissions.0.user.email }} </p>
{% else %}
<ul class="usa-list usa-list--unstyled margin-top-0">
{% for item in value.permissions.all %}
<li>{{ item.user.email }}</li>
{% endfor %}
</ul>
{% endif %}
{% endif %}
{% if value.invitations.all %}
<h4 class="h4--sm-05">Invited domain managers</h4>
<ul class="usa-list usa-list--unstyled margin-top-0">
{% for item in value.invitations.all %}
<li>{{ item.email }}</li>
{% endfor %}
</ul>
{% endif %}
{% else %}
<p class="margin-top-0 margin-bottom-0">
{% if value %}
Expand Down
9 changes: 9 additions & 0 deletions src/registrar/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,15 @@ def test_user_with_portfolio_roles_but_no_portfolio(self):
cm.exception.message, "When portfolio roles or additional permissions are assigned, portfolio is required."
)

@less_console_noise_decorator
def test_user_with_admin_portfolio_role(self):
portfolio, _ = Portfolio.objects.get_or_create(creator=self.user, organization_name="Hotel California")
self.assertFalse(self.user.is_portfolio_admin(portfolio))
UserPortfolioPermission.objects.get_or_create(
portfolio=portfolio, user=self.user, roles=[UserPortfolioRoleChoices.ORGANIZATION_ADMIN]
)
self.assertTrue(self.user.is_portfolio_admin(portfolio))

@less_console_noise_decorator
def test_get_active_requests_count_in_portfolio_returns_zero_if_no_portfolio(self):
# There is no portfolio referenced in session so should return 0
Expand Down
Loading

0 comments on commit 7547a56

Please sign in to comment.