Coverage for src/paperap/models/storage_path/model.py: 95%

1"""

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

3

4 METADATA:

5

6 File: storage_path.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 from datetime import datetime

25 from typing import TYPE_CHECKING, Any

26

27 from paperap.models.abstract.model import StandardModel

28 from paperap.models.mixins.models import MatcherMixin

29 from paperap.models.storage_path.queryset import StoragePathQuerySet

30

31 if TYPE_CHECKING:

32 from paperap.models.document import Document, DocumentQuerySet

33

34

35 class StoragePath(StandardModel, MatcherMixin):

36 """

37 Represents a storage path in Paperless-NgX.

38 """

39

40 name: str

41 slug: str | None = None

42 path: str | None = None

43 document_count: int = 0

44 owner: int | None = None

45 user_can_change: bool | None = None

46

47 class Meta(StandardModel.Meta):

48 # Fields that should not be modified

49 read_only_fields = {"slug", "document_count"}

50 queryset = StoragePathQuerySet

51

52 @property

53 def documents(self) -> "DocumentQuerySet":

54 """

55 Get documents in this storage path.

56 """

57 return self._client.documents().all().storage_path_id(self.id)