Make PoP start and end dates inclusive.

Also removes the clock class.

Makes PoP date ranges inclusive such that a task order with:
-  a start date on or after the current date
and
- an end date on or before the current date
should be considered valid.

This commit also removes the Clock class. This class had two methods as
shortcuts for common uses of pendlum functions. But it wasn't being used
in very many places, and it took up about the same space as

    from pendulum import today()
    ...
    today(tz="UTC").date()

If we want to add this back in, it might be a good idea to extend it for
other time functions we have sprinkled around, like the random date
functions in our tests
This commit is contained in:
graham-dds
2019-12-30 13:43:59 -05:00
parent f4e1b668f2
commit aabedbcac4
4 changed files with 24 additions and 24 deletions

View File

@@ -9,7 +9,7 @@ from atst.models.base import Base
import atst.models.types as types
import atst.models.mixins as mixins
from atst.models.attachment import Attachment
from atst.utils.clock import Clock
from pendulum import today
class Status(Enum):
@@ -117,17 +117,17 @@ class TaskOrder(Base, mixins.TimestampsMixin):
@property
def status(self):
today = Clock.today()
todays_date = today(tz="UTC").date()
if not self.is_completed and not self.is_signed:
return Status.DRAFT
elif self.is_completed and not self.is_signed:
return Status.UNSIGNED
elif today < self.start_date:
elif todays_date < self.start_date:
return Status.UPCOMING
elif today >= self.end_date:
elif todays_date > self.end_date:
return Status.EXPIRED
elif self.start_date <= today < self.end_date:
elif self.start_date <= todays_date <= self.end_date:
return Status.ACTIVE
@property
@@ -141,7 +141,7 @@ class TaskOrder(Base, mixins.TimestampsMixin):
@property
def days_to_expiration(self):
if self.end_date:
return (self.end_date - Clock.today()).days
return (self.end_date - today(tz="UTC").date()).days
@property
def total_obligated_funds(self):