Reset this logic, it's broken for tests, will fix in another PR
@@ -506,10 +506,19 @@ def post_revision_commit(sender, instance, **kwargs):
authorization.authorizer = authorizer
authorization.partner = instance.partner
+ # If this is a proxy partner, and the requested_access_duration
+ # field is set to false, set (or reset) the expiry date
+ # to one year from now
+ if (
+ instance.partner.authorization_method == Partner.PROXY
+ and instance.requested_access_duration is None
+ ):
+ one_year_from_now = date.today() + timedelta(days=365)
+ authorization.date_expires = one_year_from_now
# If this is a proxy partner, and the requested_access_duration
# field is set to true, set (or reset) the expiry date
# to 1, 3, 6 or 12 months from today based on user input
- if (
+ elif (
instance.partner.authorization_method == Partner.PROXY
and instance.partner.requested_access_duration is True
):
@@ -517,14 +526,6 @@ def post_revision_commit(sender, instance, **kwargs):
months=instance.requested_access_duration
)
authorization.date_expires = custom_expiry_date
- # Our admin validation shouldn't allow this to be the case, but
- # just in case, we'll default to a one-year access period.
- elif (
- instance.partner.authorization_method == Partner.PROXY
- and instance.requested_access_duration is None
- ):
- one_year_from_now = date.today() + timedelta(days=365)
- authorization.date_expires = one_year_from_now
# Alternatively, if this partner has a specified account_length,
# we'll use that to set the expiry.
elif instance.partner.account_length:
