Coverage for src/paperap/models/ui_settings/queryset.py: 88%

1"""

2----------------------------------------------------------------------------

3

4 METADATA:

5

6 File: queryset.py

7 Project: paperap

8 Created: 2025-03-04

9 Version: 0.0.5

10 Author: Jess Mann

11 Email: jess@jmann.me

12 Copyright (c) 2025 Jess Mann

13

14----------------------------------------------------------------------------

15

16 LAST MODIFIED:

17

18 2025-03-04 By Jess Mann

19

20"""

21

22 from __future__ import annotations

23

24 import logging

25 from typing import TYPE_CHECKING, Any, Self

26

27 from paperap.models.abstract.queryset import BaseQuerySet, StandardQuerySet

28

29 if TYPE_CHECKING:

30 from paperap.models.ui_settings.model import UISettings

31

32 logger = logging.getLogger(__name__)

33

34

35 class UISettingsQuerySet(StandardQuerySet["UISettings"]):

36 """

37 A lazy-loaded, chainable query interface for Paperless NGX resources.

38

39 BaseQuerySet provides pagination, filtering, and caching functionality similar to Django's BaseQuerySet.

40 It's designed to be lazy - only fetching data when it's actually needed.

41 """

42

43 def has_permission(self, value: str) -> Self:

44 """

45 Filter UI settings by permissions.

46

47 Args:

48 value (str): The permissions to filter by

49

50 Returns:

51 UISettingsQuerySet: The filtered queryset

52

53 """

54 return self.filter(permissions__contains=value)