Skip to content

Commit

Permalink
Merge pull request #176 from tzumainn/offer-claim-default-max-time
Browse files Browse the repository at this point in the history
Enforce default and max lease length times when offer is claimed
  • Loading branch information
tzumainn authored Oct 8, 2024
2 parents 726ea20 + 3cc8d10 commit 9436150
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions esi_leap/api/controllers/v1/offer.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,21 @@ def claim(self, offer_uuid, new_lease):
if "end_time" not in lease_dict:
q = offer.get_next_lease_start_time(lease_dict["start_time"])
if q is None:
lease_dict["end_time"] = offer.end_time
max_end_time = offer.end_time
else:
lease_dict["end_time"] = q.start_time
max_end_time = q.start_time
default_end_time = lease_dict["start_time"] + datetime.timedelta(
days=CONF.api.default_lease_time
)
end_time = min([default_end_time, max_end_time])
lease_dict["end_time"] = end_time
else:
utils.check_lease_length(
cdict,
lease_dict["start_time"],
lease_dict["end_time"],
CONF.api.max_lease_time,
)

new_lease = lease_obj.Lease(**lease_dict)
new_lease.create(request)
Expand Down

0 comments on commit 9436150

Please sign in to comment.