simplifying code
This commit is contained in:
parent
e4e5bc056b
commit
2a2499a929
|
@ -8,8 +8,6 @@
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
import arrow
|
import arrow
|
||||||
import pytz
|
|
||||||
import datetime
|
|
||||||
from cryptography import x509
|
from cryptography import x509
|
||||||
from cryptography.hazmat.primitives.asymmetric import rsa
|
from cryptography.hazmat.primitives.asymmetric import rsa
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
@ -323,12 +321,8 @@ class Certificate(db.Model):
|
||||||
|
|
||||||
@hybrid_property
|
@hybrid_property
|
||||||
def expired(self):
|
def expired(self):
|
||||||
if isinstance(self.not_after, datetime.datetime):
|
|
||||||
# can't compare offset-naive and offset-aware datetimes
|
# can't compare offset-naive and offset-aware datetimes
|
||||||
if self.not_after.replace(tzinfo=pytz.UTC) <= arrow.utcnow():
|
if arrow.Arrow.fromdatetime(self.not_after) <= arrow.utcnow():
|
||||||
return True
|
|
||||||
else:
|
|
||||||
if self.not_after <= arrow.utcnow():
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@expired.expression
|
@expired.expression
|
||||||
|
|
Loading…
Reference in New Issue