mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-26 04:28:39 +02:00
working wip
This commit is contained in:
parent
8bf2432b15
commit
be00e8249c
3 changed files with 35 additions and 8 deletions
|
@ -100,12 +100,12 @@
|
||||||
class="usa-button"
|
class="usa-button"
|
||||||
>Save
|
>Save
|
||||||
</button>
|
</button>
|
||||||
</form>
|
<!-- </form>
|
||||||
|
|
||||||
<form aria-label="form to undo changes to the DS records">
|
<form aria-label="form to undo changes to the DS records"> -->
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
class="usa-button usa-button--outline btn-cancel"
|
class="usa-button usa-button--outline"
|
||||||
name="btn-cancel-click"
|
name="btn-cancel-click"
|
||||||
aria-label="Reset the data in the DS records to the registry state (undo changes)"
|
aria-label="Reset the data in the DS records to the registry state (undo changes)"
|
||||||
>Cancel
|
>Cancel
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
<form method="post">
|
<form method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="submit"
|
||||||
class="usa-button usa-modal__close"
|
class="usa-button usa-modal__close"
|
||||||
aria-label="Close this window"
|
aria-label="Close this window"
|
||||||
name="btn-cancel-click"
|
name="btn-cancel-click"
|
||||||
|
|
|
@ -10,6 +10,7 @@ import logging
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.messages.views import SuccessMessageMixin
|
from django.contrib.messages.views import SuccessMessageMixin
|
||||||
from django.db import IntegrityError
|
from django.db import IntegrityError
|
||||||
|
from django.http import HttpResponseRedirect
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
@ -342,20 +343,43 @@ class DomainDsDataView(DomainPermissionView, FormMixin):
|
||||||
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:
|
||||||
return redirect("domain-dns-dnssec-dsdata", {"formset": formset}, RequestContext(request))
|
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})
|
||||||
|
|
||||||
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:
|
if len(formset) == 0 and formset.initial != [{}] and override == False:
|
||||||
# trigger the modal
|
# trigger the modal
|
||||||
context = self.get_context_data(**kwargs)
|
logger.info(">>>>>>>>clicked save")
|
||||||
|
context = super().get_context_data(form=formset)
|
||||||
context["trigger_modal"] = True
|
context["trigger_modal"] = True
|
||||||
|
# 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 self.render_to_response(context)
|
return self.render_to_response(context)
|
||||||
|
|
||||||
if formset.is_valid():
|
if formset.is_valid() or override:
|
||||||
return self.form_valid(formset)
|
return self.form_valid(formset)
|
||||||
else:
|
else:
|
||||||
return self.form_invalid(formset)
|
return self.form_invalid(formset)
|
||||||
|
@ -363,6 +387,7 @@ 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()
|
||||||
|
|
||||||
|
@ -386,7 +411,9 @@ 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