Update admin.py

This commit is contained in:
zandercymatics 2024-02-23 10:45:54 -07:00
parent 8b56d97712
commit ec44f8fe58
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7

View file

@ -1159,7 +1159,14 @@ class DomainAdmin(ListHeaderAdmin):
if object_id is not None: if object_id is not None:
domain = Domain.objects.get(pk=object_id) domain = Domain.objects.get(pk=object_id)
years_to_extend_by = self._get_calculated_years_for_exp_date(domain) years_to_extend_by = self._get_calculated_years_for_exp_date(domain)
curr_exp_date = domain.registry_expiration_date
try:
curr_exp_date = domain.registry_expiration_date
except KeyError:
# No expiration date was found. Return none.
extra_context["extended_expiration_date"] = None
return super().changeform_view(request, object_id, form_url, extra_context)
if curr_exp_date < date.today(): if curr_exp_date < date.today():
extra_context["extended_expiration_date"] = date.today() + relativedelta(years=years_to_extend_by) extra_context["extended_expiration_date"] = date.today() + relativedelta(years=years_to_extend_by)
else: else: