mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-15 17:17:02 +02:00
Basic view
This commit is contained in:
parent
cfd6248fc3
commit
2c9916b214
7 changed files with 110 additions and 10 deletions
|
@ -182,6 +182,11 @@ urlpatterns = [
|
||||||
views.DomainOrgNameAddressView.as_view(),
|
views.DomainOrgNameAddressView.as_view(),
|
||||||
name="domain-org-name-address",
|
name="domain-org-name-address",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"domain/<int:pk>/suborganization",
|
||||||
|
views.DomainSubOrganizationView.as_view(),
|
||||||
|
name="domain-suborganization",
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
"domain/<int:pk>/senior-official",
|
"domain/<int:pk>/senior-official",
|
||||||
views.DomainSeniorOfficialView.as_view(),
|
views.DomainSeniorOfficialView.as_view(),
|
||||||
|
|
|
@ -16,7 +16,7 @@ from registrar.utility.errors import (
|
||||||
SecurityEmailErrorCodes,
|
SecurityEmailErrorCodes,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ..models import Contact, DomainInformation, Domain, User
|
from ..models import Contact, DomainInformation, Domain, User, Suborganization
|
||||||
from .common import (
|
from .common import (
|
||||||
ALGORITHM_CHOICES,
|
ALGORITHM_CHOICES,
|
||||||
DIGEST_TYPE_CHOICES,
|
DIGEST_TYPE_CHOICES,
|
||||||
|
@ -508,6 +508,41 @@ class DomainOrgNameAddressForm(forms.ModelForm):
|
||||||
return old_value == new_value
|
return old_value == new_value
|
||||||
|
|
||||||
|
|
||||||
|
class DomainSuborganizationForm(forms.ModelForm):
|
||||||
|
"""Form for updating the suborganization"""
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = DomainInformation
|
||||||
|
fields = [
|
||||||
|
"sub_organization",
|
||||||
|
]
|
||||||
|
error_messages = {
|
||||||
|
"sub_organization": {"required": "Select a suborganization."},
|
||||||
|
}
|
||||||
|
widgets = {
|
||||||
|
"sub_organization": forms.Select(
|
||||||
|
attrs={
|
||||||
|
"required": False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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 = ["sub_organization"]
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.fields["sub_organization"].required = False
|
||||||
|
if self.instance and self.instance.portfolio:
|
||||||
|
self.fields['sub_organization'].queryset = Suborganization.objects.filter(
|
||||||
|
portfolio=self.instance.portfolio
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self.fields['sub_organization'].queryset = Suborganization.objects.none()
|
||||||
|
|
||||||
|
|
||||||
class DomainDnssecForm(forms.Form):
|
class DomainDnssecForm(forms.Form):
|
||||||
"""Form for enabling and disabling dnssec"""
|
"""Form for enabling and disabling dnssec"""
|
||||||
|
|
||||||
|
|
|
@ -54,15 +54,12 @@
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li class="usa-sidenav__item">
|
{% if is_org_user %}
|
||||||
{% url 'domain-org-name-address' pk=domain.id as url %}
|
{% include "includes/domain_sidenav_item.html" with url_name="domain-suborganization" item_text="Suborganization"%}
|
||||||
<a href="{{ url }}"
|
{% else %}
|
||||||
{% if request.path == url %}class="usa-current"{% endif %}
|
{% include "includes/domain_sidenav_item.html" with url_name="domain-org-name-address" item_text="Organization name and mailing address"%}
|
||||||
>
|
{% endif %}
|
||||||
Organization name and mailing address
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li class="usa-sidenav__item">
|
<li class="usa-sidenav__item">
|
||||||
{% url 'domain-senior-official' pk=domain.id as url %}
|
{% url 'domain-senior-official' pk=domain.id as url %}
|
||||||
|
|
25
src/registrar/templates/domain_suborganization.html
Normal file
25
src/registrar/templates/domain_suborganization.html
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
{% extends "domain_base.html" %}
|
||||||
|
{% load static field_helpers%}
|
||||||
|
|
||||||
|
{% block title %}Suborganization{% endblock %}
|
||||||
|
|
||||||
|
{% block domain_content %}
|
||||||
|
{# this is right after the messages block in the parent template #}
|
||||||
|
{% include "includes/form_errors.html" with form=form %}
|
||||||
|
|
||||||
|
<h1>Organization name and mailing address </h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The name of your suborganization will be publicly listed as the domain registrant.
|
||||||
|
This list of suborganizations has been populated the .gov program.
|
||||||
|
If you believe there is an error please contact <a href="mailto:help@get.gov" class="usa-link">help@get.gov</a>.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{% include "includes/required_fields.html" %}
|
||||||
|
<form class="usa-form usa-form--large" method="post" novalidate id="form-container">
|
||||||
|
{% csrf_token %}
|
||||||
|
{% input_with_errors form.sub_organization %}
|
||||||
|
<button type="submit" class="usa-button">Save</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,8 @@
|
||||||
|
<li class="usa-sidenav__item">
|
||||||
|
{% url url_name pk=domain.id as url %}
|
||||||
|
<a href="{{ url }}"
|
||||||
|
{% if request.path == url %}class="usa-current"{% endif %}
|
||||||
|
>
|
||||||
|
{{ item_text }}
|
||||||
|
</a>
|
||||||
|
</li>
|
|
@ -3,6 +3,7 @@ from .domain import (
|
||||||
DomainView,
|
DomainView,
|
||||||
DomainSeniorOfficialView,
|
DomainSeniorOfficialView,
|
||||||
DomainOrgNameAddressView,
|
DomainOrgNameAddressView,
|
||||||
|
DomainSubOrganizationView,
|
||||||
DomainDNSView,
|
DomainDNSView,
|
||||||
DomainNameserversView,
|
DomainNameserversView,
|
||||||
DomainDNSSECView,
|
DomainDNSSECView,
|
||||||
|
|
|
@ -16,6 +16,7 @@ from django.urls import reverse
|
||||||
from django.views.generic.edit import FormMixin
|
from django.views.generic.edit import FormMixin
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
from registrar.forms.domain import DomainSuborganizationForm
|
||||||
from registrar.models import (
|
from registrar.models import (
|
||||||
Domain,
|
Domain,
|
||||||
DomainRequest,
|
DomainRequest,
|
||||||
|
@ -221,6 +222,34 @@ class DomainOrgNameAddressView(DomainFormBaseView):
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
|
||||||
|
class DomainSubOrganizationView(DomainFormBaseView):
|
||||||
|
"""Suborganization view"""
|
||||||
|
|
||||||
|
model = Domain
|
||||||
|
template_name = "domain_suborganization.html"
|
||||||
|
context_object_name = "domain"
|
||||||
|
form_class = DomainSuborganizationForm
|
||||||
|
|
||||||
|
def get_form_kwargs(self, *args, **kwargs):
|
||||||
|
"""Add domain_info.organization_name instance to make a bound form."""
|
||||||
|
form_kwargs = super().get_form_kwargs(*args, **kwargs)
|
||||||
|
form_kwargs["instance"] = self.object.domain_info
|
||||||
|
return form_kwargs
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
"""Redirect to the overview page for the domain."""
|
||||||
|
return reverse("domain-suborganization", kwargs={"pk": self.object.pk})
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
"""The form is valid, save the organization name and mailing address."""
|
||||||
|
form.save()
|
||||||
|
|
||||||
|
messages.success(self.request, "The suborganization name for this domain has been updated.")
|
||||||
|
|
||||||
|
# superclass has the redirect
|
||||||
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
|
||||||
class DomainSeniorOfficialView(DomainFormBaseView):
|
class DomainSeniorOfficialView(DomainFormBaseView):
|
||||||
"""Domain senior official editing view."""
|
"""Domain senior official editing view."""
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue