home · contact · privacy
Refactor BaseModel sorting from GET handlers into class definitions.
[plomtask] / plomtask / conditions.py
index b60d0af53c534c4672241bb8f853c3f537d55ecb..15dcb9df623c60378485632ce3bebc4c30f03d47 100644 (file)
@@ -12,6 +12,8 @@ class Condition(BaseModel[int]):
     to_save_versioned = ['title', 'description']
     to_search = ['title.newest', 'description.newest']
     can_create_by_id = True
+    sorters = {'is_active': lambda c: c.is_active,
+               'title': lambda c: c.title.newest}
 
     def __init__(self, id_: int | None, is_active: bool = False) -> None:
         super().__init__(id_)