added comments, removed empty lines, and renamed methods for code legibility

This commit is contained in:
David Kennedy 2023-10-17 13:20:48 -04:00
parent f94363a836
commit 181cfccfc5
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
6 changed files with 30 additions and 28 deletions

View file

@ -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;

View file

@ -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(

View file

@ -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(

View file

@ -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

View file

@ -6,8 +6,8 @@ from .domain import (
DomainDNSView,
DomainNameserversView,
DomainDNSSECView,
DomainDsdataView,
DomainKeydataView,
DomainDsDataView,
DomainKeyDataView,
DomainYourContactInformationView,
DomainSecurityEmailView,
DomainUsersView,

View file

@ -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