Logic clean up

This commit is contained in:
Rebecca Hsieh 2024-06-14 09:35:59 -07:00
parent b4c1045690
commit ddce50a471
No known key found for this signature in database
3 changed files with 9 additions and 7 deletions

View file

@ -13,6 +13,6 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name="domain", model_name="domain",
name="dsdata_last_change", name="dsdata_last_change",
field=models.TextField(blank=True, help_text="Most recent time that ds data was updated", null=True), field=models.TextField(blank=True, help_text="Record of the last change event for ds data", null=True),
), ),
] ]

View file

@ -681,11 +681,13 @@ class Domain(TimeStampedModel, DomainHelper):
user_email = user_domain_role.user.email if user_domain_role else "unknown user" user_email = user_domain_role.user.email if user_domain_role else "unknown user"
try: try:
if "dsData" in _addDnssecdata and _addDnssecdata["dsData"] is not None: added_record = "dsData" in _addDnssecdata and _addDnssecdata["dsData"] is not None
deleted_record = "dsData" in _remDnssecdata and _remDnssecdata["dsData"] is not None
if added_record:
registry.send(addRequest, cleaned=True) registry.send(addRequest, cleaned=True)
dsdata_change_log = f"{user_email} added a DS data record" dsdata_change_log = f"{user_email} added a DS data record"
if "dsData" in _remDnssecdata and _remDnssecdata["dsData"] is not None: if deleted_record:
registry.send(remRequest, cleaned=True)
if dsdata_change_log != "": # if they add and remove a record at same time if dsdata_change_log != "": # if they add and remove a record at same time
dsdata_change_log = f"{user_email} added and deleted a DS data record" dsdata_change_log = f"{user_email} added and deleted a DS data record"
else: else:
@ -1077,7 +1079,7 @@ class Domain(TimeStampedModel, DomainHelper):
dsdata_last_change = TextField( dsdata_last_change = TextField(
null=True, null=True,
blank=True, blank=True,
help_text="Most recent time that ds data was updated", help_text="Record of the last change event for ds data",
) )
def isActive(self): def isActive(self):

View file

@ -2166,7 +2166,7 @@ class TestRegistrantDNSSEC(MockEppLib):
domain = Domain.objects.get(name="dnssec-dsdata.gov") domain = Domain.objects.get(name="dnssec-dsdata.gov")
self.assertIsNotNone(domain.dsdata_last_change) self.assertIsNotNone(domain.dsdata_last_change)
initial_change_time = domain.dsdata_last_change initial_change = domain.dsdata_last_change
# Remove dnssec data # Remove dnssec data
domain.dnssecdata = self.dnssecExtensionRemovingDsData domain.dnssecdata = self.dnssecExtensionRemovingDsData
@ -2175,7 +2175,7 @@ class TestRegistrantDNSSEC(MockEppLib):
domain = Domain.objects.get(name="dnssec-dsdata.gov") domain = Domain.objects.get(name="dnssec-dsdata.gov")
self.assertIsNotNone(domain.dsdata_last_change) self.assertIsNotNone(domain.dsdata_last_change)
self.assertNotEqual(domain.dsdata_last_change, initial_change_time) self.assertNotEqual(domain.dsdata_last_change, initial_change)
# get the DNS SEC extension added to the UpdateDomain command and # get the DNS SEC extension added to the UpdateDomain command and
# verify that it is properly sent # verify that it is properly sent