mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-23 03:06:01 +02:00
added comments, removed empty lines, and renamed methods for code legibility
This commit is contained in:
parent
f94363a836
commit
181cfccfc5
6 changed files with 30 additions and 28 deletions
|
@ -315,9 +315,17 @@ function prepareDeleteButtons() {
|
|||
// Attach click event listener on the delete buttons of the existing forms
|
||||
prepareDeleteButtons();
|
||||
|
||||
// Attack click event listener on the add button
|
||||
if (addButton)
|
||||
addButton.addEventListener('click', addForm);
|
||||
|
||||
/*
|
||||
* Add a formset to the end of the form.
|
||||
* For each element in the added formset, name the elements with the prefix,
|
||||
* form-{#}-{element_name} where # is the index of the formset and element_name
|
||||
* is the element's name.
|
||||
* Additionally, update the form element's metadata, including totalForms' value.
|
||||
*/
|
||||
function addForm(e){
|
||||
let forms = document.querySelectorAll(".ds-record");
|
||||
let formNum = forms.length;
|
||||
|
|
|
@ -97,12 +97,12 @@ urlpatterns = [
|
|||
),
|
||||
path(
|
||||
"domain/<int:pk>/dns/dnssec/dsdata",
|
||||
views.DomainDsdataView.as_view(),
|
||||
views.DomainDsDataView.as_view(),
|
||||
name="domain-dns-dnssec-dsdata",
|
||||
),
|
||||
path(
|
||||
"domain/<int:pk>/dns/dnssec/keydata",
|
||||
views.DomainKeydataView.as_view(),
|
||||
views.DomainKeyDataView.as_view(),
|
||||
name="domain-dns-dnssec-keydata",
|
||||
),
|
||||
path(
|
||||
|
|
|
@ -16,14 +16,12 @@ from .common import (
|
|||
|
||||
|
||||
class DomainAddUserForm(forms.Form):
|
||||
|
||||
"""Form for adding a user to a domain."""
|
||||
|
||||
email = forms.EmailField(label="Email")
|
||||
|
||||
|
||||
class DomainNameserverForm(forms.Form):
|
||||
|
||||
"""Form for changing nameservers."""
|
||||
|
||||
server = forms.CharField(label="Name server", strip=True)
|
||||
|
@ -37,7 +35,6 @@ NameserverFormset = formset_factory(
|
|||
|
||||
|
||||
class ContactForm(forms.ModelForm):
|
||||
|
||||
"""Form for updating contacts."""
|
||||
|
||||
class Meta:
|
||||
|
@ -68,14 +65,12 @@ class ContactForm(forms.ModelForm):
|
|||
|
||||
|
||||
class DomainSecurityEmailForm(forms.Form):
|
||||
|
||||
"""Form for adding or editing a security email to a domain."""
|
||||
|
||||
security_email = forms.EmailField(label="Security email", required=False)
|
||||
|
||||
|
||||
class DomainOrgNameAddressForm(forms.ModelForm):
|
||||
|
||||
"""Form for updating the organization name and mailing address."""
|
||||
|
||||
zipcode = forms.CharField(
|
||||
|
@ -149,12 +144,10 @@ class DomainOrgNameAddressForm(forms.ModelForm):
|
|||
|
||||
|
||||
class DomainDnssecForm(forms.Form):
|
||||
|
||||
"""Form for enabling and disabling dnssec"""
|
||||
|
||||
|
||||
class DomainDsdataForm(forms.Form):
|
||||
|
||||
"""Form for adding or editing DNSSEC DS Data to a domain."""
|
||||
|
||||
key_tag = forms.IntegerField(
|
||||
|
@ -198,7 +191,6 @@ DomainDsdataFormset = formset_factory(
|
|||
|
||||
|
||||
class DomainKeydataForm(forms.Form):
|
||||
|
||||
"""Form for adding or editing DNSSEC Key Data to a domain."""
|
||||
|
||||
flag = forms.TypedChoiceField(
|
||||
|
|
|
@ -458,11 +458,21 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
|
||||
@Cache
|
||||
def dnssecdata(self) -> Optional[extensions.DNSSECExtension]:
|
||||
"""
|
||||
Get a complete list of dnssecdata extensions for this domain.
|
||||
|
||||
dnssecdata are provided as a list of DNSSECExtension objects.
|
||||
|
||||
A DNSSECExtension object includes:
|
||||
maxSigLife: Optional[int]
|
||||
dsData: Optional[Sequence[DSData]]
|
||||
keyData: Optional[Sequence[DNSSECKeyData]]
|
||||
|
||||
"""
|
||||
try:
|
||||
return self._get_property("dnssecdata")
|
||||
except Exception as err:
|
||||
# Don't throw error as this is normal for a new domain
|
||||
# TODO - 433 error handling ticket should address this
|
||||
logger.info("Domain does not have dnssec data defined %s" % err)
|
||||
return None
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ from .domain import (
|
|||
DomainDNSView,
|
||||
DomainNameserversView,
|
||||
DomainDNSSECView,
|
||||
DomainDsdataView,
|
||||
DomainKeydataView,
|
||||
DomainDsDataView,
|
||||
DomainKeyDataView,
|
||||
DomainYourContactInformationView,
|
||||
DomainSecurityEmailView,
|
||||
DomainUsersView,
|
||||
|
|
|
@ -51,7 +51,6 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class DomainView(DomainPermissionView):
|
||||
|
||||
"""Domain detail overview page."""
|
||||
|
||||
template_name = "domain_detail.html"
|
||||
|
@ -113,7 +112,6 @@ class DomainOrgNameAddressView(DomainPermissionView, FormMixin):
|
|||
|
||||
|
||||
class DomainAuthorizingOfficialView(DomainPermissionView, FormMixin):
|
||||
|
||||
"""Domain authorizing official editing view."""
|
||||
|
||||
model = Domain
|
||||
|
@ -156,14 +154,12 @@ class DomainAuthorizingOfficialView(DomainPermissionView, FormMixin):
|
|||
|
||||
|
||||
class DomainDNSView(DomainPermissionView):
|
||||
|
||||
"""DNS Information View."""
|
||||
|
||||
template_name = "domain_dns.html"
|
||||
|
||||
|
||||
class DomainNameserversView(DomainPermissionView, FormMixin):
|
||||
|
||||
"""Domain nameserver editing view."""
|
||||
|
||||
template_name = "domain_nameservers.html"
|
||||
|
@ -242,15 +238,15 @@ class DomainNameserversView(DomainPermissionView, FormMixin):
|
|||
|
||||
|
||||
class DomainDNSSECView(DomainPermissionView, FormMixin):
|
||||
|
||||
"""Domain DNSSEC editing view."""
|
||||
|
||||
template_name = "domain_dnssec.html"
|
||||
form_class = DomainDnssecForm
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
"""The initial value for the form (which is a formset here)."""
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
self.domain = self.get_object()
|
||||
|
||||
has_dnssec_records = self.domain.dnssecdata is not None
|
||||
|
@ -294,8 +290,7 @@ class DomainDNSSECView(DomainPermissionView, FormMixin):
|
|||
return self.form_valid(form)
|
||||
|
||||
|
||||
class DomainDsdataView(DomainPermissionView, FormMixin):
|
||||
|
||||
class DomainDsDataView(DomainPermissionView, FormMixin):
|
||||
"""Domain DNSSEC ds data editing view."""
|
||||
|
||||
template_name = "domain_dsdata.html"
|
||||
|
@ -395,7 +390,9 @@ class DomainDsdataView(DomainPermissionView, FormMixin):
|
|||
dnssecdata.dsData = []
|
||||
dnssecdata.dsData.append(common.DSData(**dsrecord))
|
||||
except KeyError:
|
||||
# no server information in this field, skip it
|
||||
# no cleaned_data provided for this form, but passed
|
||||
# as valid; this can happen if form has been added but
|
||||
# not been interacted with; in that case, want to ignore
|
||||
pass
|
||||
domain = self.get_object()
|
||||
try:
|
||||
|
@ -414,8 +411,7 @@ class DomainDsdataView(DomainPermissionView, FormMixin):
|
|||
return super().form_valid(formset)
|
||||
|
||||
|
||||
class DomainKeydataView(DomainPermissionView, FormMixin):
|
||||
|
||||
class DomainKeyDataView(DomainPermissionView, FormMixin):
|
||||
"""Domain DNSSEC key data editing view."""
|
||||
|
||||
template_name = "domain_keydata.html"
|
||||
|
@ -536,7 +532,6 @@ class DomainKeydataView(DomainPermissionView, FormMixin):
|
|||
|
||||
|
||||
class DomainYourContactInformationView(DomainPermissionView, FormMixin):
|
||||
|
||||
"""Domain your contact information editing view."""
|
||||
|
||||
template_name = "domain_your_contact_information.html"
|
||||
|
@ -577,7 +572,6 @@ class DomainYourContactInformationView(DomainPermissionView, FormMixin):
|
|||
|
||||
|
||||
class DomainSecurityEmailView(DomainPermissionView, FormMixin):
|
||||
|
||||
"""Domain security email editing view."""
|
||||
|
||||
template_name = "domain_security_email.html"
|
||||
|
@ -639,14 +633,12 @@ class DomainSecurityEmailView(DomainPermissionView, FormMixin):
|
|||
|
||||
|
||||
class DomainUsersView(DomainPermissionView):
|
||||
|
||||
"""User management page in the domain details."""
|
||||
|
||||
template_name = "domain_users.html"
|
||||
|
||||
|
||||
class DomainAddUserView(DomainPermissionView, FormMixin):
|
||||
|
||||
"""Inside of a domain's user management, a form for adding users.
|
||||
|
||||
Multiple inheritance is used here for permissions, form handling, and
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue