mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-25 12:08:40 +02:00
Fix expiration date bug
This commit is contained in:
parent
018eb4f1f6
commit
ed902ccfe3
1 changed files with 5 additions and 2 deletions
|
@ -84,6 +84,9 @@ class Command(BaseCommand):
|
||||||
is_idempotent = self.idempotence_check(domain, extension_amount)
|
is_idempotent = self.idempotence_check(domain, extension_amount)
|
||||||
if not disable_idempotence and not is_idempotent:
|
if not disable_idempotence and not is_idempotent:
|
||||||
self.update_skipped.append(domain.name)
|
self.update_skipped.append(domain.name)
|
||||||
|
logger.info(
|
||||||
|
f"{TerminalColors.YELLOW}" f"Skipping update for {domain}" f"{TerminalColors.ENDC}"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self.extend_expiration_date_on_domain(domain, extension_amount, debug)
|
self.extend_expiration_date_on_domain(domain, extension_amount, debug)
|
||||||
|
|
||||||
|
@ -113,14 +116,14 @@ class Command(BaseCommand):
|
||||||
# == Helper functions == #
|
# == Helper functions == #
|
||||||
def idempotence_check(self, domain, extension_amount):
|
def idempotence_check(self, domain, extension_amount):
|
||||||
"""Determines if the proposed operation violates idempotency"""
|
"""Determines if the proposed operation violates idempotency"""
|
||||||
proposed_date = self.add_years(domain.expiration_date, extension_amount)
|
proposed_date = self.add_years(domain.registry_expiration_date, extension_amount)
|
||||||
# Because our migration data had a hard stop date, we can determine if our change
|
# Because our migration data had a hard stop date, we can determine if our change
|
||||||
# is valid simply checking if adding two years to our current date yields a greater date
|
# is valid simply checking if adding two years to our current date yields a greater date
|
||||||
# than the proposed.
|
# than the proposed.
|
||||||
# CAVEAT: This check stops working after a year has elapsed between when this script
|
# CAVEAT: This check stops working after a year has elapsed between when this script
|
||||||
# was ran, and when it was ran again. This is good enough for now, but a more robust
|
# was ran, and when it was ran again. This is good enough for now, but a more robust
|
||||||
# solution would be a DB flag.
|
# solution would be a DB flag.
|
||||||
extension_from_today = self.add_years(date.today(), extension_amount + 2)
|
extension_from_today = self.add_years(date.today(), extension_amount + 1)
|
||||||
is_idempotent = proposed_date < extension_from_today
|
is_idempotent = proposed_date < extension_from_today
|
||||||
return is_idempotent
|
return is_idempotent
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue