Coverage for src/paperap/models/saved_view/model.py: 100%

1"""

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

3

4 METADATA:

5

6 File: saved_view.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 typing import Any, Optional

25

26 from pydantic import Field

27

28 from paperap.models.abstract.model import StandardModel

29 from paperap.models.saved_view.queryset import SavedViewQuerySet

30

31 DEFAULT_DISPLAY_FIELDS = [

32 "title",

33 "created",

34 "tag",

35 "correspondent",

36 "documenttype",

37 "storagepath",

38 "note",

39 "owner",

40 "shared",

41 "pagecount",

42]

43

44

45 class SavedView(StandardModel):

46 """

47 Represents a saved view in Paperless-NgX.

48 """

49

50 name: str

51 show_on_dashboard: bool | None = None

52 show_in_sidebar: bool | None = None

53 sort_field: str | None = None

54 sort_reverse: bool | None = None

55 filter_rules: list[dict[str, Any]] = Field(default_factory=list)

56 page_size: int | None = None

57 display_mode: str | None = None

58 display_fields: list[str] = Field(default_factory=list)

59 owner: int | None = None

60 user_can_change: bool | None = None

61

62 class Meta(StandardModel.Meta):

63 # Fields that should not be modified

64 read_only_fields = {"owner", "user_can_change"}

65 queryset = SavedViewQuerySet