mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-24 11:38:39 +02:00
Cleanup content
Move to another PR
This commit is contained in:
parent
5879afa94b
commit
59b8962eee
10 changed files with 19 additions and 141 deletions
|
@ -1950,34 +1950,3 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||
showInputOnErrorFields();
|
||||
|
||||
})();
|
||||
|
||||
/**
|
||||
* An IIFE that adds the default selection on comboboxes to the input field.
|
||||
* This is because this action doesn't get fired by the time the page loads
|
||||
* TODO: Will be refined in #2352
|
||||
*/
|
||||
(function loadInitialValuesForComboBoxes() {
|
||||
document.addEventListener('DOMContentLoaded', (event) => {
|
||||
const comboBoxElements = document.querySelectorAll('.usa-combo-box');
|
||||
comboBoxElements.forEach(comboBox => {
|
||||
const select = comboBox.querySelector('select');
|
||||
const input = comboBox.querySelector('input');
|
||||
|
||||
// Find the selected option
|
||||
const selectedOption = select.querySelector('option[selected]');
|
||||
|
||||
// If there's a selected option, set its text as the input value.
|
||||
// If the default name is "------", then this indicates that the field is blank.
|
||||
// Don't populate in this case.
|
||||
if (selectedOption) {
|
||||
// Check to make sure the value isn't just a line of dashes.
|
||||
// Caveat: we can't have any suborgs named "------". This is OK.
|
||||
const isEmptyValue = /^-+$/.test(selectedOption.textContent);
|
||||
if (!isEmptyValue) {
|
||||
input.value = selectedOption.textContent;
|
||||
comboBox.classList.add('usa-combo-box--pristine');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -182,11 +182,12 @@ urlpatterns = [
|
|||
views.DomainOrgNameAddressView.as_view(),
|
||||
name="domain-org-name-address",
|
||||
),
|
||||
path(
|
||||
"domain/<int:pk>/suborganization",
|
||||
views.DomainSubOrganizationView.as_view(),
|
||||
name="domain-suborganization",
|
||||
),
|
||||
# TODO - uncomment in #2352
|
||||
# path(
|
||||
# "domain/<int:pk>/suborganization",
|
||||
# views.DomainSubOrganizationView.as_view(),
|
||||
# name="domain-suborganization",
|
||||
# ),
|
||||
path(
|
||||
"domain/<int:pk>/senior-official",
|
||||
views.DomainSeniorOfficialView.as_view(),
|
||||
|
|
|
@ -508,37 +508,6 @@ class DomainOrgNameAddressForm(forms.ModelForm):
|
|||
return old_value == new_value
|
||||
|
||||
|
||||
# TODO: Will be refined in #2352
|
||||
class DomainSuborganizationForm(forms.ModelForm):
|
||||
"""Form for updating the suborganization"""
|
||||
|
||||
sub_organization = forms.ModelChoiceField(
|
||||
queryset=Suborganization.objects.none(),
|
||||
required=True,
|
||||
widget=forms.Select(),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = DomainInformation
|
||||
fields = [
|
||||
"sub_organization",
|
||||
]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
if self.instance and self.instance.portfolio:
|
||||
self.fields["sub_organization"].queryset = Suborganization.objects.filter(portfolio=self.instance.portfolio)
|
||||
|
||||
# Set custom form label
|
||||
self.fields["sub_organization"].label = "Suborganization name"
|
||||
|
||||
# Use the combobox rather than the regular select widget
|
||||
self.fields["sub_organization"].widget.template_name = "django/forms/widgets/combobox.html"
|
||||
|
||||
# TODO: Remove in #2352
|
||||
DomainHelper.disable_field(self.fields["sub_organization"], disable_required=True)
|
||||
|
||||
|
||||
class DomainDnssecForm(forms.Form):
|
||||
"""Form for enabling and disabling dnssec"""
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{% comment %} Will be used in #2354 {% endcomment %}
|
||||
<div class="usa-combo-box">
|
||||
{% include "django/forms/widgets/select.html" %}
|
||||
</div>
|
||||
|
|
|
@ -54,8 +54,10 @@
|
|||
{% endif %}
|
||||
|
||||
{% if portfolio %}
|
||||
{% comment %} TODO - uncomment in #2352 and add to edit_link
|
||||
{% 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=domain.is_editable %}
|
||||
{% endcomment %}
|
||||
{% include "includes/summary_item.html" with title='Suborganization' value=domain.domain_info.sub_organization edit_link="#" editable=domain.is_editable %}
|
||||
{% else %}
|
||||
{% url 'domain-org-name-address' pk=domain.id as url %}
|
||||
{% include "includes/summary_item.html" with title='Organization name and mailing address' value=domain.domain_info address='true' edit_link=url editable=domain.is_editable %}
|
||||
|
|
|
@ -9,7 +9,12 @@
|
|||
{% endwith %}
|
||||
|
||||
{% if portfolio %}
|
||||
{% with url_name="domain-suborganization" %}
|
||||
{% comment %} TODO - uncomment in #2352
|
||||
{% with url_name="domain-suborganization" %}
|
||||
{% include "includes/domain_sidenav_item.html" with item_text="Suborganization" %}
|
||||
{% endwith %}
|
||||
{% endcomment %}
|
||||
{% with url="#" %}
|
||||
{% include "includes/domain_sidenav_item.html" with item_text="Suborganization" %}
|
||||
{% endwith %}
|
||||
{% else %}
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
{% 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>
|
||||
|
||||
{% if suborganization_is_editable %}
|
||||
{% include "includes/required_fields.html" %}
|
||||
{% endif %}
|
||||
|
||||
<form class="usa-form usa-form--large" method="post" novalidate id="form-container">
|
||||
{% csrf_token %}
|
||||
{% input_with_errors form.sub_organization %}
|
||||
{% if suborganization_is_editable %}
|
||||
<button type="submit" class="usa-button">Save</button>
|
||||
{% endif %}
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
|
@ -1,5 +1,7 @@
|
|||
<li class="usa-sidenav__item">
|
||||
{% url url_name pk=domain.id as url %}
|
||||
{% if url_name %}
|
||||
{% url url_name pk=domain.id as url %}
|
||||
{% endif %}
|
||||
<a href="{{ url }}"
|
||||
{% if request.path == url %}class="usa-current"{% endif %}
|
||||
>
|
||||
|
|
|
@ -3,7 +3,6 @@ from .domain import (
|
|||
DomainView,
|
||||
DomainSeniorOfficialView,
|
||||
DomainOrgNameAddressView,
|
||||
DomainSubOrganizationView,
|
||||
DomainDNSView,
|
||||
DomainNameserversView,
|
||||
DomainDNSSECView,
|
||||
|
|
|
@ -16,7 +16,6 @@ from django.urls import reverse
|
|||
from django.views.generic.edit import FormMixin
|
||||
from django.conf import settings
|
||||
|
||||
from registrar.forms.domain import DomainSuborganizationForm
|
||||
from registrar.models import (
|
||||
Domain,
|
||||
DomainRequest,
|
||||
|
@ -27,7 +26,6 @@ from registrar.models import (
|
|||
)
|
||||
from registrar.models.portfolio import Portfolio
|
||||
from registrar.models.public_contact import PublicContact
|
||||
from registrar.models.utility.domain_helper import DomainHelper
|
||||
from registrar.utility.enums import DefaultEmail
|
||||
from registrar.utility.errors import (
|
||||
GenericError,
|
||||
|
@ -224,44 +222,6 @@ class DomainOrgNameAddressView(DomainFormBaseView):
|
|||
return super().form_valid(form)
|
||||
|
||||
|
||||
# TODO: Edit will be added in #2352
|
||||
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)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Adds custom context."""
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
# TODO: Switch to True #2352
|
||||
suborganization_is_editable = False
|
||||
context["suborganization_is_editable"] = suborganization_is_editable
|
||||
return context
|
||||
|
||||
|
||||
class DomainSeniorOfficialView(DomainFormBaseView):
|
||||
"""Domain senior official editing view."""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue