From 46ed1f0e719161fe2990fd1b517b4252cdaf6fcc Mon Sep 17 00:00:00 2001 From: graham-dds Date: Mon, 30 Dec 2019 13:45:39 -0500 Subject: [PATCH] Remove / refactor TO class properties This commit removes properties that weren't be used anywhere in the code base. It also refactors two properties to use sum() with a generator comprehension instead of a for loop. --- atst/models/task_order.py | 41 ++++----------------------------------- 1 file changed, 4 insertions(+), 37 deletions(-) diff --git a/atst/models/task_order.py b/atst/models/task_order.py index 6cf4df0f..36ba905e 100644 --- a/atst/models/task_order.py +++ b/atst/models/task_order.py @@ -83,26 +83,10 @@ class TaskOrder(Base, mixins.TimestampsMixin): def is_active(self): return self.status == Status.ACTIVE - @property - def is_upcoming(self): - return self.status == Status.UPCOMING - @property def is_expired(self): return self.status == Status.EXPIRED - @property - def is_unsigned(self): - return self.status == Status.UNSIGNED - - @property - def has_begun(self): - return self.start_date is not None and Clock.today() >= self.start_date - - @property - def has_ended(self): - return self.start_date is not None and Clock.today() >= self.end_date - @property def clins_are_completed(self): return all([len(self.clins), (clin.is_completed for clin in self.clins)]) @@ -145,30 +129,13 @@ class TaskOrder(Base, mixins.TimestampsMixin): @property def total_obligated_funds(self): - total = 0 - for clin in self.clins: - if clin.obligated_amount is not None: - total += clin.obligated_amount - return total + return sum( + (clin.obligated_amount for clin in self.clins if clin.obligated_amount) + ) @property def total_contract_amount(self): - total = 0 - for clin in self.clins: - if clin.total_amount is not None: - total += clin.total_amount - return total - - @property - # TODO delete when we delete task_order_review flow - def budget(self): - return 100000 - - @property - def balance(self): - # TODO: fix task order -- reimplement using CLINs - # Faked for display purposes - return 50 + return sum((clin.total_amount for clin in self.clins if clin.total_amount)) @property def invoiced_funds(self):