Skip to content

Commit a98cbbd

Browse files
committed
Added is_active filter Model methods
1 parent 8be945c commit a98cbbd

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pyodoo/v12/model.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ def get_many(self,
201201
return results
202202

203203
def all(self,
204+
is_active: ActiveStatusChoice = ActiveStatusChoice.NOT_SET,
204205
fields: tuple[str, ...] = None,
205206
options: dict[str, Any] = None,
206207
limit: Optional[int] = None,
@@ -209,6 +210,7 @@ def all(self,
209210
"""
210211
Get all the objects
211212
213+
:param is_active: Additional filter for active field
212214
:param fields: Fields to include in the response
213215
:param options: Dictionary with options to use
214216
:param limit: Maximum number of results count
@@ -217,6 +219,7 @@ def all(self,
217219
:return: List of dictionaries with the requested fields
218220
"""
219221
return self.filter(filters=[],
222+
is_active=is_active,
220223
fields=fields,
221224
options=options,
222225
limit=limit,
@@ -270,6 +273,7 @@ def find(self,
270273

271274
def filter(self,
272275
filters: list[Union[BooleanOperator, Filter]],
276+
is_active: ActiveStatusChoice = ActiveStatusChoice.NOT_SET,
273277
fields: tuple[str, ...] = None,
274278
options: dict[str, Any] = None,
275279
limit: Optional[int] = None,
@@ -279,13 +283,17 @@ def filter(self,
279283
Find some rows from a model using some filters
280284
281285
:param filters: List of filters used for searching the data
286+
:param is_active: Additional filter for active field
282287
:param fields: Tuple with the fields to include in the response
283288
:param options: Dictionary with options to use
284289
:param limit: Maximum number of results count
285290
:param offset: Starting record number to fetch the data
286291
:param order: Ordering clause
287292
:return: List of dictionaries with the requested fields
288293
"""
294+
# Filter for active status
295+
self._set_active(filters=filters,
296+
is_active=is_active)
289297
# Set options
290298
if options is None:
291299
options = {}
@@ -308,14 +316,20 @@ def filter(self,
308316

309317
def count(self,
310318
filters: list[Union[BooleanOperator, Filter]],
319+
is_active: ActiveStatusChoice = ActiveStatusChoice.NOT_SET,
311320
options: dict[str, Any] = None) -> int:
312321
"""
313322
Get the rows count from a model using some filters
314323
315324
:param filters: List of filters used for searching the data
325+
:param is_active: Additional filter for active field
316326
:param options: Dictionary with options to use
317327
:return: Rows count
318328
"""
329+
# Filter for active status
330+
self._set_active(filters=filters,
331+
is_active=is_active)
332+
# Set options
319333
if options is None:
320334
options = {}
321335
# Request data and get results
@@ -325,6 +339,7 @@ def count(self,
325339

326340
def search(self,
327341
filters: list[Union[BooleanOperator, Filter]],
342+
is_active: ActiveStatusChoice = ActiveStatusChoice.NOT_SET,
328343
options: dict[str, Any] = None,
329344
limit: Optional[int] = None,
330345
offset: Optional[int] = None,
@@ -333,12 +348,16 @@ def search(self,
333348
Find rows list from a list of filters
334349
335350
:param filters: List of filters used for searching the data
351+
:param is_active: Additional filter for active field
336352
:param options: Dictionary with options to use
337353
:param limit: Maximum number of results count
338354
:param offset: Starting record number to fetch the data
339355
:param order: Ordering clause
340356
:return: List of ID for the objects found
341357
"""
358+
# Filter for active status
359+
self._set_active(filters=filters,
360+
is_active=is_active)
342361
# Set options
343362
if options is None:
344363
options = {}

0 commit comments

Comments
 (0)