add a sorted_clins property for clin sorting logic
CLINS have a special ordering: - First, they are sorted by the last three digits - Then, they are sorted by the first digit Trying to add CLIN sorting logic to the relationship field in the task order proved to be more challenging than expected. So, a separate property was defined in order to access the clins in sorted order.
This commit is contained in:
@@ -38,7 +38,7 @@ class CLIN(Base, mixins.TimestampsMixin):
|
||||
@property
|
||||
def type(self):
|
||||
return "Base" if self.number[0] == "0" else "Option"
|
||||
|
||||
|
||||
@property
|
||||
def is_completed(self):
|
||||
return all(
|
||||
|
@@ -47,6 +47,10 @@ class TaskOrder(Base, mixins.TimestampsMixin):
|
||||
"CLIN", back_populates="task_order", cascade="all, delete-orphan"
|
||||
)
|
||||
|
||||
@property
|
||||
def sorted_clins(self):
|
||||
return sorted(self.clins, key=lambda clin: (clin.number[1:], clin.number[0]))
|
||||
|
||||
@hybrid_property
|
||||
def pdf(self):
|
||||
return self._pdf
|
||||
|
Reference in New Issue
Block a user