Change entitlement sorting to sort *valid* entitlements by reverse expiration time
With this change, if all entitlements are valid, we sort to show the entitlement that will expire the farthest in the future, as that defines the point at which the user must act before the license becomes invalid.
This commit is contained in:
parent
f229f375b5
commit
d506279892
2 changed files with 106 additions and 2 deletions
|
@ -187,6 +187,14 @@ class EntitlementValidationResult(object):
|
|||
return self.get_status() == EntitlementStatus.met
|
||||
|
||||
def __lt__(self, rhs):
|
||||
# If this result has the same status as another, return the result with an expiration date
|
||||
# further in the future, as it will be more relevant. The results may expire, but so long as
|
||||
# this result is valid, so will the entitlement.
|
||||
if self.get_status() == rhs.get_status():
|
||||
return (self.entitlement.expiration.expiration_date >
|
||||
rhs.entitlement.expiration.expiration_date)
|
||||
|
||||
# Otherwise, sort lexically by status.
|
||||
return self.get_status() < rhs.get_status()
|
||||
|
||||
def __repr__(self):
|
||||
|
|
Reference in a new issue