mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-05 01:11:55 +02:00
removed js for hide and show on dnssec main page; handling flags in app with session variables rather than model attributes
This commit is contained in:
parent
b899b35285
commit
a6cfd343e8
5 changed files with 54 additions and 59 deletions
|
@ -376,23 +376,3 @@ function prepareDeleteButtons() {
|
|||
}
|
||||
|
||||
})();
|
||||
|
||||
function toggleElements() {
|
||||
let element1 = document.getElementById("enable-dnssec");
|
||||
let element2 = document.getElementById("add-records");
|
||||
element1.classList.toggle("display-none");
|
||||
element2.classList.toggle("display-none");
|
||||
}
|
||||
|
||||
/**
|
||||
* An IIFE that attaches a click handler to toggle the DNSSEC warning on the DNSSEC landing page
|
||||
*
|
||||
*/
|
||||
(function toggleDNSSECWarning() {
|
||||
let toggle1 = document.getElementById("enable_dnssec");
|
||||
if (toggle1)
|
||||
toggle1.addEventListener("click", toggleElements);
|
||||
let toggle2 = document.getElementById("cancel_dnssec");
|
||||
if (toggle2)
|
||||
toggle2.addEventListener("click", toggleElements);
|
||||
})();
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
{% block domain_content %}
|
||||
|
||||
<h1>DNSSEC</h1>
|
||||
<h1>{% if dnssec_enabled %}Set up {% endif %}DNSSEC</h1>
|
||||
|
||||
<p>DNSSEC, or DNS Security Extensions, is additional security layer to protect your website. Enabling DNSSEC ensures that when someone visits your website, they can be certain that it's connecting to the correct server, preventing potential hijacking or tampering with your domain's records. <a href="https://www.icann.org/resources/pages/dnssec-what-is-it-why-important-2019-03-05-en">Read more about DNSSEC and why it is important.</a></p>
|
||||
<p>DNSSEC, or DNS Security Extensions, is additional security layer to protect your website. Enabling DNSSEC ensures that when someone visits your website, they can be certain that it's connecting to the correct server, preventing potential hijacking or tampering with your domain's records.</p>
|
||||
|
||||
<form class="usa-form usa-form--large" method="post">
|
||||
{% csrf_token %}
|
||||
|
@ -24,6 +24,21 @@
|
|||
data-open-modal
|
||||
>Disable DNSSEC</a
|
||||
>
|
||||
{% elif dnssec_enabled %}
|
||||
<div id="add-records">
|
||||
<h2> Add DS Records </h2>
|
||||
<p>In order to enable DNSSEC and add Delegation Signer (DS) records, you must first configure it with your DNS hosting service. Your configuration will determine whether you need to add DS Data or Key Data. Contact your DNS hosting provider if you are unsure which record type to add.</p>
|
||||
<p>
|
||||
<a href="{% url 'domain-dns-dnssec-dsdata' pk=domain.id %}" class="usa-button usa-button--outline">Add DS Data</a>
|
||||
<a href="{% url 'domain-dns-dnssec-keydata' pk=domain.id %}" class="usa-button usa-button--outline">Add Key Data</a>
|
||||
<button
|
||||
type="submit"
|
||||
class="usa-button usa-button--unstyled"
|
||||
name="cancel_dnssec"
|
||||
id="cancel_dnssec"
|
||||
>Cancel</button>
|
||||
</p>
|
||||
</div>
|
||||
{% else %}
|
||||
<div id="enable-dnssec">
|
||||
<div class="usa-alert usa-alert--info usa-alert--slim margin-bottom-3">
|
||||
|
@ -32,28 +47,12 @@
|
|||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
type="submit"
|
||||
class="usa-button"
|
||||
name="enable_dnssec"
|
||||
id="enable_dnssec"
|
||||
>Enable DNSSEC</button>
|
||||
</div>
|
||||
|
||||
{% comment %} display: none is sufficient on hidden elements for accessibility (removes accessibility tree) {% endcomment %}
|
||||
<div id="add-records" class="display-none">
|
||||
<h2> Add DS Records </h2>
|
||||
<p>In order to enable DNSSEC and add Delegation Signer (DS) records, you must first configure it with your DNS hosting service. Your configuration will determine whether you need to add DS Data or Key Data. Contact your DNS hosting provider if you are unsure which record type to add.</p>
|
||||
<p>
|
||||
<a href="{% url 'domain-dns-dnssec-dsdata' pk=domain.id %}" class="usa-button usa-button--outline">Add DS Data</a>
|
||||
<a href="{% url 'domain-dns-dnssec-keydata' pk=domain.id %}" class="usa-button usa-button--outline">Add Key Data</a>
|
||||
<button
|
||||
type="button"
|
||||
class="usa-button usa-button--unstyled"
|
||||
name="cancel_dnssec"
|
||||
id="cancel_dnssec"
|
||||
>Cancel</button>
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</form>
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{% elif not domain.dnssec_ds_confirmed %}
|
||||
{% elif not dnssec_ds_confirmed %}
|
||||
<p>In order to enable DNSSEC and add DS records, you must first configure it with your DNS hosting service. Your configuration will determine whether you need to add DS Data or Key Data. Contact your DNS hosting provider if you are unsure which record type to add.</p>
|
||||
<form class="usa-form usa-form--large" method="post" novalidate id="form-container">
|
||||
{% csrf_token %}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{% elif not domain.dnssec_key_confirmed %}
|
||||
{% elif not dnssec_key_confirmed %}
|
||||
<p>In order to enable DNSSEC and add DS records, you must first configure it with your DNS hosting service. Your configuration will determine whether you need to add DS Data or Key Data. Contact your DNS hosting provider if you are unsure which record type to add.</p>
|
||||
<form class="usa-form usa-form--large" method="post" novalidate id="form-container">
|
||||
{% csrf_token %}
|
||||
|
|
|
@ -233,7 +233,6 @@ class DomainDNSSECView(DomainPermissionView, FormMixin):
|
|||
|
||||
template_name = "domain_dnssec.html"
|
||||
form_class = DomainDnssecForm
|
||||
clicked_enable_dns = False
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
@ -242,20 +241,13 @@ class DomainDNSSECView(DomainPermissionView, FormMixin):
|
|||
|
||||
has_dnssec_records = self.domain.dnssecdata is not None
|
||||
|
||||
# if does_not_have_dnssec_records and self.clicked_enable_dns == False:
|
||||
# logger.debug(f"clicked_enable_dns {self.clicked_enable_dns}")
|
||||
# self.domain.dnssec_enabled = False
|
||||
# self.domain.dnssec_ds_confirmed = False
|
||||
# self.domain.dnssec_key_confirmed = False
|
||||
# self.domain.save()
|
||||
|
||||
# Create HTML for the buttons
|
||||
modal_button = '<button type="submit" class="usa-button" name="disable_dnssec">Disable DNSSEC</button>'
|
||||
|
||||
context['modal_button'] = modal_button
|
||||
context['has_dnssec_records'] = has_dnssec_records
|
||||
# context['domain'] = self.domain
|
||||
|
||||
context['dnssec_enabled'] = self.request.session.pop('dnssec_enabled', False)
|
||||
|
||||
return context
|
||||
|
||||
def get_success_url(self):
|
||||
|
@ -277,9 +269,12 @@ class DomainDNSSECView(DomainPermissionView, FormMixin):
|
|||
messages.error(
|
||||
self.request, errmsg
|
||||
)
|
||||
self.domain.dnssec_ds_confirmed = False
|
||||
self.domain.dnssec_key_confirmed = False
|
||||
self.domain.save()
|
||||
request.session['dnssec_ds_confirmed'] = False
|
||||
request.session['dnssec_key_confirmed'] = False
|
||||
elif 'enable_dnssec' in request.POST:
|
||||
request.session['dnssec_enabled'] = True
|
||||
request.session['dnssec_ds_confirmed'] = False
|
||||
request.session['dnssec_key_confirmed'] = False
|
||||
|
||||
return self.form_valid(form)
|
||||
|
||||
|
@ -323,6 +318,17 @@ class DomainDsdataView(DomainPermissionView, FormMixin):
|
|||
context = super().get_context_data(**kwargs)
|
||||
# use "formset" instead of "form" for the key
|
||||
context["formset"] = context.pop("form")
|
||||
|
||||
# set the dnssec_ds_confirmed flag in the context for this view
|
||||
# based either on the existence of DS Data in the domain,
|
||||
# or on the flag stored in the session
|
||||
domain = self.get_object()
|
||||
dnssecdata: extensions.DNSSECExtension = domain.dnssecdata
|
||||
|
||||
if dnssecdata is not None and dnssecdata.dsData is not None:
|
||||
self.request.session['dnssec_ds_confirmed'] = True
|
||||
|
||||
context['dnssec_ds_confirmed'] = self.request.session.get('dnssec_ds_confirmed', False)
|
||||
return context
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
|
@ -331,9 +337,8 @@ class DomainDsdataView(DomainPermissionView, FormMixin):
|
|||
formset = self.get_form()
|
||||
|
||||
if 'confirm-ds' in request.POST:
|
||||
self.object.dnssec_ds_confirmed = True
|
||||
self.object.dnssec_key_confirmed = False
|
||||
self.object.save()
|
||||
request.session['dnssec_ds_confirmed'] = True
|
||||
request.session['dnssec_key_confirmed'] = False
|
||||
return super().form_valid(formset)
|
||||
|
||||
if 'btn-cancel-click' in request.POST:
|
||||
|
@ -425,6 +430,17 @@ class DomainKeydataView(DomainPermissionView, FormMixin):
|
|||
context = super().get_context_data(**kwargs)
|
||||
# use "formset" instead of "form" for the key
|
||||
context["formset"] = context.pop("form")
|
||||
|
||||
# set the dnssec_key_confirmed flag in the context for this view
|
||||
# based either on the existence of Key Data in the domain,
|
||||
# or on the flag stored in the session
|
||||
domain = self.get_object()
|
||||
dnssecdata: extensions.DNSSECExtension = domain.dnssecdata
|
||||
|
||||
if dnssecdata is not None and dnssecdata.keyData is not None:
|
||||
self.request.session['dnssec_key_confirmed'] = True
|
||||
|
||||
context['dnssec_key_confirmed'] = self.request.session.get('dnssec_key_confirmed', False)
|
||||
return context
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
|
@ -433,8 +449,8 @@ class DomainKeydataView(DomainPermissionView, FormMixin):
|
|||
formset = self.get_form()
|
||||
|
||||
if 'confirm-key' in request.POST:
|
||||
self.object.dnssec_key_confirmed = True
|
||||
self.object.dnssec_ds_confirmed = False
|
||||
request.session['dnssec_key_confirmed'] = True
|
||||
request.session['dnssec_ds_confirmed'] = False
|
||||
self.object.save()
|
||||
return super().form_valid(formset)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue