From d50628f14d0fde24fd90bfc865078dec59d3d513 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Mon, 23 Oct 2023 18:32:22 -0400 Subject: [PATCH] cleaned up working code for review --- src/registrar/templates/domain_dsdata.html | 139 +++++++++------------ src/registrar/views/domain.py | 33 +---- 2 files changed, 67 insertions(+), 105 deletions(-) diff --git a/src/registrar/templates/domain_dsdata.html b/src/registrar/templates/domain_dsdata.html index afe230376..832361f6e 100644 --- a/src/registrar/templates/domain_dsdata.html +++ b/src/registrar/templates/domain_dsdata.html @@ -22,96 +22,79 @@

Enter the values given by your DNS provider for DS Data.

- {% comment %} {% if not dnssec_ds_confirmed %} -

Required fields are marked with an asterisk (*).

-
- {% csrf_token %} - -
- {% else %} {% endcomment %} - {% include "includes/required_fields.html" %} + {% include "includes/required_fields.html" %} -
- {% csrf_token %} - {{ formset.management_form }} + + {% csrf_token %} + {{ formset.management_form }} - {% for form in formset %} -
+ {% for form in formset %} +
- DS Data record {{forloop.counter}} + DS Data record {{forloop.counter}} -

DS Data record {{forloop.counter}}

+

DS Data record {{forloop.counter}}

-
-
- {% with attr_required=True add_group_class="usa-form-group--unstyled-error" %} - {% input_with_errors form.key_tag %} - {% endwith %} -
-
- {% with attr_required=True add_group_class="usa-form-group--unstyled-error" %} - {% input_with_errors form.algorithm %} - {% endwith %} -
-
- {% with attr_required=True add_group_class="usa-form-group--unstyled-error" %} - {% input_with_errors form.digest_type %} - {% endwith %} -
+
+
+ {% with attr_required=True add_group_class="usa-form-group--unstyled-error" %} + {% input_with_errors form.key_tag %} + {% endwith %}
- -
-
- {% with attr_required=True add_group_class="usa-form-group--unstyled-error" %} - {% input_with_errors form.digest %} - {% endwith %} -
+
+ {% with attr_required=True add_group_class="usa-form-group--unstyled-error" %} + {% input_with_errors form.algorithm %} + {% endwith %}
- -
-
- -
+
+ {% with attr_required=True add_group_class="usa-form-group--unstyled-error" %} + {% input_with_errors form.digest_type %} + {% endwith %}
+
-
- {% endfor %} +
+
+ {% with attr_required=True add_group_class="usa-form-group--unstyled-error" %} + {% input_with_errors form.digest %} + {% endwith %} +
+
- +
+
+ +
+
- - - - - {% comment %} {% endif %} {% endcomment %} + + + + + + {% if trigger_modal %} Disable DNSSEC' - ) - - # context to back out of a broken form on all fields delete - context["modal_button"] = modal_button return context @@ -342,30 +332,22 @@ class DomainDsDataView(DomainPermissionView, FormMixin): self.object = self.get_object() formset = self.get_form() override = False - - # log the context and the formset - logger.info("==================FORMSET================") - logger.info(formset) - logger.info("=======>>>>>>CONTEXT<<<<<<===========") - logger.info(self.get_context_data(**kwargs)) - logger.info("========^^^^^^^CONTEXT^^^^^^^^========") - # This is called by the form cancel button, and also by the modal's X and cancel buttons if "btn-cancel-click" in request.POST: - logger.info(">>>>>>>clicked cancel") url = self.get_success_url() return HttpResponseRedirect(url) - #return reverse("domain-dns-dnssec-dsdata", kwargs={"pk": self.object.pk}) - # return redirect("domain-dns-dnssec-dsdata", kwargs={"pk": self.object.pk}) + # This is called by the Disable DNSSEC modal to override if "disable-override-click" in request.POST: - logger.info(">>>>>>>>clicked disable") override = True - if len(formset) == 0 and formset.initial != [{}] and override == False: + # This is called when all DNSSEC data has been deleted and the + # Save button is pressed + if len(formset) == 0 and formset.initial == [{}] and override == False: # trigger the modal - logger.info(">>>>>>>>clicked save") + # get context data from super() rather than self + # to preserve the context["form"] context = super().get_context_data(form=formset) context["trigger_modal"] = True # Create HTML for the modal button @@ -387,7 +369,6 @@ class DomainDsDataView(DomainPermissionView, FormMixin): def form_valid(self, formset, **kwargs): """The formset is valid, perform something with it.""" - logger.info("form_valid is called") # Set the dnssecdata from the formset dnssecdata = extensions.DNSSECExtension() @@ -411,9 +392,7 @@ class DomainDsDataView(DomainPermissionView, FormMixin): pass domain = self.get_object() try: - logger.debug("attempting to set dnssecdata") domain.dnssecdata = dnssecdata - logger.debug("successfully set the dnssecdata") except RegistryError as err: errmsg = "Error updating DNSSEC data in the registry." logger.error(errmsg)