mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-25 03:58:39 +02:00
Backend stuff
This commit is contained in:
parent
055d163c3f
commit
2891391382
2 changed files with 32 additions and 8 deletions
|
@ -239,22 +239,25 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
To update the expiration date, use renew_domain method."""
|
||||
raise NotImplementedError()
|
||||
|
||||
def renew_domain(self, length: int = 1, unit: epp.Unit = epp.Unit.YEAR):
|
||||
def renew_domain(self, length: int = 1, date_to_extend = None, unit: epp.Unit = epp.Unit.YEAR):
|
||||
"""
|
||||
Renew the domain to a length and unit of time relative to the current
|
||||
expiration date.
|
||||
|
||||
Default length and unit of time are 1 year.
|
||||
"""
|
||||
# if no expiration date from registry, set to today
|
||||
try:
|
||||
cur_exp_date = self.registry_expiration_date
|
||||
except KeyError:
|
||||
logger.warning("current expiration date not set; setting to today")
|
||||
cur_exp_date = date.today()
|
||||
|
||||
# If no date is specified, grab the registry_expiration_date
|
||||
if date_to_extend is None:
|
||||
try:
|
||||
date_to_extend = self.registry_expiration_date
|
||||
except KeyError:
|
||||
# if no expiration date from registry, set it to today
|
||||
logger.warning("current expiration date not set; setting to today")
|
||||
date_to_extend = date.today()
|
||||
|
||||
# create RenewDomain request
|
||||
request = commands.RenewDomain(name=self.name, cur_exp_date=cur_exp_date, period=epp.Period(length, unit))
|
||||
request = commands.RenewDomain(name=self.name, cur_exp_date=date_to_extend, period=epp.Period(length, unit))
|
||||
|
||||
try:
|
||||
# update expiration date in registry, and set the updated
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue