-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2499 from cisagov/rjm/2377-portfolio-org-page
- Loading branch information
Showing
8 changed files
with
286 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,6 @@ | |
DomainDsdataFormset, | ||
DomainDsdataForm, | ||
) | ||
from .portfolio import ( | ||
PortfolioOrgAddressForm, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
"""Forms for portfolio.""" | ||
|
||
import logging | ||
from django import forms | ||
from django.core.validators import RegexValidator | ||
|
||
from ..models import DomainInformation, Portfolio | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class PortfolioOrgAddressForm(forms.ModelForm): | ||
"""Form for updating the portfolio org mailing address.""" | ||
|
||
zipcode = forms.CharField( | ||
label="Zip code", | ||
validators=[ | ||
RegexValidator( | ||
"^[0-9]{5}(?:-[0-9]{4})?$|^$", | ||
message="Enter a zip code in the required format, like 12345 or 12345-6789.", | ||
) | ||
], | ||
) | ||
|
||
class Meta: | ||
model = Portfolio | ||
fields = [ | ||
"address_line1", | ||
"address_line2", | ||
"city", | ||
"state_territory", | ||
"zipcode", | ||
# "urbanization", | ||
] | ||
error_messages = { | ||
"address_line1": {"required": "Enter the street address of your organization."}, | ||
"city": {"required": "Enter the city where your organization is located."}, | ||
"state_territory": { | ||
"required": "Select the state, territory, or military post where your organization is located." | ||
}, | ||
} | ||
widgets = { | ||
# We need to set the required attributed for State/territory | ||
# because for this fields we are creating an individual | ||
# instance of the Select. For the other fields we use the for loop to set | ||
# the class's required attribute to true. | ||
"address_line1": forms.TextInput, | ||
"address_line2": forms.TextInput, | ||
"city": forms.TextInput, | ||
"state_territory": forms.Select( | ||
attrs={ | ||
"required": True, | ||
}, | ||
choices=DomainInformation.StateTerritoryChoices.choices, | ||
), | ||
# "urbanization": forms.TextInput, | ||
} | ||
|
||
# the database fields have blank=True so ModelForm doesn't create | ||
# required fields by default. Use this list in __init__ to mark each | ||
# of these fields as required | ||
required = ["address_line1", "city", "state_territory", "zipcode"] | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
for field_name in self.required: | ||
self.fields[field_name].required = True | ||
self.fields["state_territory"].widget.attrs.pop("maxlength", None) | ||
self.fields["zipcode"].widget.attrs.pop("maxlength", None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,64 @@ | ||
{% extends 'portfolio_base.html' %} | ||
{% load static field_helpers%} | ||
|
||
{% block title %}Organization mailing address | {{ portfolio.name }} | {% endblock %} | ||
|
||
{% load static %} | ||
|
||
{% block portfolio_content %} | ||
<h1>Organization</h1> | ||
<div class="grid-row grid-gap"> | ||
<div class="tablet:grid-col-3"> | ||
<p class="font-body-md margin-top-0 margin-bottom-2 | ||
text-primary-darker text-semibold" | ||
> | ||
<span class="usa-sr-only"> Portfolio name:</span> {{ portfolio }} | ||
</p> | ||
|
||
{% include 'portfolio_organization_sidebar.html' %} | ||
</div> | ||
|
||
<div class="tablet:grid-col-9"> | ||
|
||
<h1>Organization</h1> | ||
|
||
<p>The name of your federal agency will be publicly listed as the domain registrant.</p> | ||
|
||
<p> | ||
The federal agency for your organization can’t be updated here. | ||
To suggest an update, email <a href="mailto:[email protected]" class="usa-link">[email protected]</a>. | ||
</p> | ||
|
||
{% include "includes/form_errors.html" with form=form %} | ||
|
||
{% include "includes/required_fields.html" %} | ||
|
||
<form class="usa-form usa-form--large" method="post" novalidate id="form-container"> | ||
{% csrf_token %} | ||
|
||
<p> | ||
<strong class="text-primary display-block margin-bottom-1">Federal agency</strong> | ||
{{ portfolio }} | ||
</p> | ||
|
||
{% input_with_errors form.address_line1 %} | ||
|
||
{% input_with_errors form.address_line2 %} | ||
|
||
{% input_with_errors form.city %} | ||
|
||
{% input_with_errors form.state_territory %} | ||
|
||
{% with add_class="usa-input--small" %} | ||
{% input_with_errors form.zipcode %} | ||
{% endwith %} | ||
|
||
<button | ||
type="submit" | ||
class="usa-button" | ||
> | ||
Save | ||
</button> | ||
</form> | ||
</div> | ||
</div> | ||
{% endblock %} |
23 changes: 23 additions & 0 deletions
23
src/registrar/templates/portfolio_organization_sidebar.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{% load static url_helpers %} | ||
|
||
<div class="margin-bottom-4 tablet:margin-bottom-0"> | ||
<nav aria-label="Domain sections"> | ||
<ul class="usa-sidenav"> | ||
<li class="usa-sidenav__item"> | ||
{% url 'portfolio-organization' portfolio_id=portfolio.id as url %} | ||
<a href="{{ url }}" | ||
{% if request.path == url %}class="usa-current"{% endif %} | ||
> | ||
Organization | ||
</a> | ||
</li> | ||
|
||
<li class="usa-sidenav__item"> | ||
<a href="#" | ||
> | ||
Senior official | ||
</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters