Making more things work better for agreement status.

Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
Cliff Hill
2024-04-25 19:58:04 -04:00
parent 280bd86268
commit aef5064738
2 changed files with 5 additions and 3 deletions

View File

@@ -206,6 +206,7 @@ class AgreementStatus(StrEnum):
WAITING = "waiting"
ACTIVE = "active"
EXPIRED = "expired"
UNKNOWN = "unknown"
class StatisticsType(StrEnum):

View File

@@ -2332,8 +2332,8 @@ class Agreement(db.Model):
@hybrid_property
def status(self):
current_time = datetime.utcnow()
def status(self) -> AgreementStatus:
current_time = datetime.datetime.now(datetime.UTC)
if self.start_time and self.end_time:
if current_time < self.start_time:
return AgreementStatus.WAITING
@@ -2341,7 +2341,8 @@ class Agreement(db.Model):
return AgreementStatus.EXPIRED
else:
return AgreementStatus.ACTIVE
return None
# Likely one or both are None.
return AgreementStatus.UNKNOWN
def serialize(self):