mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-26 04:28:39 +02:00
cleaned up working code for review
This commit is contained in:
parent
be00e8249c
commit
d50628f14d
2 changed files with 67 additions and 105 deletions
|
@ -22,96 +22,79 @@
|
||||||
|
|
||||||
<p>Enter the values given by your DNS provider for DS Data.</p>
|
<p>Enter the values given by your DNS provider for DS Data.</p>
|
||||||
|
|
||||||
{% comment %} {% if not dnssec_ds_confirmed %}
|
{% include "includes/required_fields.html" %}
|
||||||
<p>Required fields are marked with an asterisk (<abbr
|
|
||||||
title="required"
|
|
||||||
class="usa-hint usa-hint--required"
|
|
||||||
>*</abbr>).</p>
|
|
||||||
<form class="usa-form usa-form--large" method="post" novalidate id="form-container">
|
|
||||||
{% csrf_token %}
|
|
||||||
<button type="submit" class="usa-button usa-button--unstyled display-block" name="confirm-ds">
|
|
||||||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
|
|
||||||
<use xlink:href="{%static 'img/sprite.svg'%}#add_circle"></use>
|
|
||||||
</svg><span class="margin-left-05">Add new record</span>
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
{% else %} {% endcomment %}
|
|
||||||
{% include "includes/required_fields.html" %}
|
|
||||||
|
|
||||||
<form class="usa-form usa-form--extra-large" method="post" novalidate id="form-container">
|
<form class="usa-form usa-form--extra-large" method="post" novalidate id="form-container">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ formset.management_form }}
|
{{ formset.management_form }}
|
||||||
|
|
||||||
{% for form in formset %}
|
{% for form in formset %}
|
||||||
<fieldset class="ds-record">
|
<fieldset class="ds-record">
|
||||||
|
|
||||||
<legend class="sr-only">DS Data record {{forloop.counter}}</legend>
|
<legend class="sr-only">DS Data record {{forloop.counter}}</legend>
|
||||||
|
|
||||||
<h2 class="margin-top-0">DS Data record {{forloop.counter}}</h2>
|
<h2 class="margin-top-0">DS Data record {{forloop.counter}}</h2>
|
||||||
|
|
||||||
<div class="grid-row grid-gap-2 flex-end">
|
<div class="grid-row grid-gap-2 flex-end">
|
||||||
<div class="tablet:grid-col-4">
|
<div class="tablet:grid-col-4">
|
||||||
{% with attr_required=True add_group_class="usa-form-group--unstyled-error" %}
|
{% with attr_required=True add_group_class="usa-form-group--unstyled-error" %}
|
||||||
{% input_with_errors form.key_tag %}
|
{% input_with_errors form.key_tag %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</div>
|
|
||||||
<div class="tablet:grid-col-4">
|
|
||||||
{% with attr_required=True add_group_class="usa-form-group--unstyled-error" %}
|
|
||||||
{% input_with_errors form.algorithm %}
|
|
||||||
{% endwith %}
|
|
||||||
</div>
|
|
||||||
<div class="tablet:grid-col-4">
|
|
||||||
{% with attr_required=True add_group_class="usa-form-group--unstyled-error" %}
|
|
||||||
{% input_with_errors form.digest_type %}
|
|
||||||
{% endwith %}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tablet:grid-col-4">
|
||||||
<div class="grid-row">
|
{% with attr_required=True add_group_class="usa-form-group--unstyled-error" %}
|
||||||
<div class="grid-col">
|
{% input_with_errors form.algorithm %}
|
||||||
{% with attr_required=True add_group_class="usa-form-group--unstyled-error" %}
|
{% endwith %}
|
||||||
{% input_with_errors form.digest %}
|
|
||||||
{% endwith %}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tablet:grid-col-4">
|
||||||
<div class="grid-row margin-top-1">
|
{% with attr_required=True add_group_class="usa-form-group--unstyled-error" %}
|
||||||
<div class="grid-col">
|
{% input_with_errors form.digest_type %}
|
||||||
<button type="button" class="usa-button usa-button--unstyled display-block float-right-tablet delete-record">
|
{% endwith %}
|
||||||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
|
|
||||||
<use xlink:href="{%static 'img/sprite.svg'%}#delete"></use>
|
|
||||||
</svg><span class="margin-left-05">Delete</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</fieldset>
|
<div class="grid-row">
|
||||||
{% endfor %}
|
<div class="grid-col">
|
||||||
|
{% with attr_required=True add_group_class="usa-form-group--unstyled-error" %}
|
||||||
|
{% input_with_errors form.digest %}
|
||||||
|
{% endwith %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<button type="button" class="usa-button usa-button--unstyled display-block margin-bottom-2" id="add-ds-form">
|
<div class="grid-row margin-top-1">
|
||||||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
|
<div class="grid-col">
|
||||||
<use xlink:href="{%static 'img/sprite.svg'%}#add_circle"></use>
|
<button type="button" class="usa-button usa-button--unstyled display-block float-right-tablet delete-record">
|
||||||
</svg><span class="margin-left-05">Add new record</span>
|
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
|
||||||
</button>
|
<use xlink:href="{%static 'img/sprite.svg'%}#delete"></use>
|
||||||
|
</svg><span class="margin-left-05">Delete</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<button
|
</fieldset>
|
||||||
id="save-ds-data"
|
{% endfor %}
|
||||||
type="submit"
|
|
||||||
class="usa-button"
|
|
||||||
>Save
|
|
||||||
</button>
|
|
||||||
<!-- </form>
|
|
||||||
|
|
||||||
<form aria-label="form to undo changes to the DS records"> -->
|
<button type="button" class="usa-button usa-button--unstyled display-block margin-bottom-2" id="add-ds-form">
|
||||||
<button
|
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
|
||||||
type="submit"
|
<use xlink:href="{%static 'img/sprite.svg'%}#add_circle"></use>
|
||||||
class="usa-button usa-button--outline"
|
</svg><span class="margin-left-05">Add new record</span>
|
||||||
name="btn-cancel-click"
|
</button>
|
||||||
aria-label="Reset the data in the DS records to the registry state (undo changes)"
|
|
||||||
>Cancel
|
<button
|
||||||
</button>
|
id="save-ds-data"
|
||||||
</form>
|
type="submit"
|
||||||
{% comment %} {% endif %} {% endcomment %}
|
class="usa-button"
|
||||||
|
>Save
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
class="usa-button usa-button--outline"
|
||||||
|
name="btn-cancel-click"
|
||||||
|
aria-label="Reset the data in the DS records to the registry state (undo changes)"
|
||||||
|
>Cancel
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
{% if trigger_modal %}
|
{% if trigger_modal %}
|
||||||
<a
|
<a
|
||||||
|
|
|
@ -324,16 +324,6 @@ class DomainDsDataView(DomainPermissionView, FormMixin):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
# use "formset" instead of "form" for the key
|
# use "formset" instead of "form" for the key
|
||||||
context["formset"] = context.pop("form")
|
context["formset"] = context.pop("form")
|
||||||
|
|
||||||
# Create HTML for the modal button
|
|
||||||
modal_button = (
|
|
||||||
'<button type="submit" '
|
|
||||||
'class="usa-button usa-button--secondary" '
|
|
||||||
'name="disable-override-click">Disable DNSSEC</button>'
|
|
||||||
)
|
|
||||||
|
|
||||||
# context to back out of a broken form on all fields delete
|
|
||||||
context["modal_button"] = modal_button
|
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
@ -342,30 +332,22 @@ class DomainDsDataView(DomainPermissionView, FormMixin):
|
||||||
self.object = self.get_object()
|
self.object = self.get_object()
|
||||||
formset = self.get_form()
|
formset = self.get_form()
|
||||||
override = False
|
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
|
# 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:
|
if "btn-cancel-click" in request.POST:
|
||||||
logger.info(">>>>>>>clicked cancel")
|
|
||||||
url = self.get_success_url()
|
url = self.get_success_url()
|
||||||
return HttpResponseRedirect(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:
|
if "disable-override-click" in request.POST:
|
||||||
logger.info(">>>>>>>>clicked disable")
|
|
||||||
override = True
|
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
|
# 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 = super().get_context_data(form=formset)
|
||||||
context["trigger_modal"] = True
|
context["trigger_modal"] = True
|
||||||
# Create HTML for the modal button
|
# Create HTML for the modal button
|
||||||
|
@ -387,7 +369,6 @@ class DomainDsDataView(DomainPermissionView, FormMixin):
|
||||||
def form_valid(self, formset, **kwargs):
|
def form_valid(self, formset, **kwargs):
|
||||||
"""The formset is valid, perform something with it."""
|
"""The formset is valid, perform something with it."""
|
||||||
|
|
||||||
logger.info("form_valid is called")
|
|
||||||
# Set the dnssecdata from the formset
|
# Set the dnssecdata from the formset
|
||||||
dnssecdata = extensions.DNSSECExtension()
|
dnssecdata = extensions.DNSSECExtension()
|
||||||
|
|
||||||
|
@ -411,9 +392,7 @@ class DomainDsDataView(DomainPermissionView, FormMixin):
|
||||||
pass
|
pass
|
||||||
domain = self.get_object()
|
domain = self.get_object()
|
||||||
try:
|
try:
|
||||||
logger.debug("attempting to set dnssecdata")
|
|
||||||
domain.dnssecdata = dnssecdata
|
domain.dnssecdata = dnssecdata
|
||||||
logger.debug("successfully set the dnssecdata")
|
|
||||||
except RegistryError as err:
|
except RegistryError as err:
|
||||||
errmsg = "Error updating DNSSEC data in the registry."
|
errmsg = "Error updating DNSSEC data in the registry."
|
||||||
logger.error(errmsg)
|
logger.error(errmsg)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue