File: workflow.py

package info (click to toggle)
pypaperless 5.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,440 kB
  • sloc: python: 5,607; sh: 26; makefile: 3
file content (155 lines) | stat: -rw-r--r-- 4,934 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
"""Workflow snapshot."""

# mypy: ignore-errors

DATA_WORKFLOWS = {
    "count": 3,
    "next": None,
    "previous": None,
    "all": [1, 2, 3],
    "results": [
        {
            "id": 1,
            "name": "Importordner Template",
            "order": 1,
            "enabled": True,
            "triggers": [
                {
                    "id": 1,
                    "sources": [1],
                    "type": 1,
                    "filter_path": None,
                    "filter_filename": "*.pdf",
                    "filter_mailrule": None,
                    "matching_algorithm": 0,
                    "match": "",
                    "is_insensitive": None,
                    "filter_has_tags": [],
                    "filter_has_correspondent": None,
                    "filter_has_document_type": None,
                }
            ],
            "actions": [
                {
                    "id": 1,
                    "type": 1,
                    "assign_title": "Some workflow title",
                    "assign_tags": [4],
                    "assign_correspondent": 9,
                    "assign_document_type": 8,
                    "assign_storage_path": 2,
                    "assign_owner": 3,
                    "assign_view_users": [],
                    "assign_view_groups": [],
                    "assign_change_users": [],
                    "assign_change_groups": [],
                    "assign_custom_fields": [2],
                }
            ],
        },
        {
            "id": 2,
            "name": "API Upload Template",
            "order": 2,
            "enabled": True,
            "triggers": [
                {
                    "id": 2,
                    "sources": [1, 2],
                    "type": 1,
                    "filter_path": "/api/*",
                    "filter_filename": "*.pdf",
                    "filter_mailrule": None,
                    "matching_algorithm": 0,
                    "match": "",
                    "is_insensitive": None,
                    "filter_has_tags": [],
                    "filter_has_correspondent": None,
                    "filter_has_document_type": None,
                }
            ],
            "actions": [
                {
                    "id": 2,
                    "type": 1,
                    "assign_title": "API",
                    "assign_tags": [4],
                    "assign_correspondent": 9,
                    "assign_document_type": 12,
                    "assign_storage_path": 2,
                    "assign_owner": 3,
                    "assign_view_users": [],
                    "assign_view_groups": [],
                    "assign_change_users": [],
                    "assign_change_groups": [],
                    "assign_custom_fields": [5],
                }
            ],
        },
        {
            "id": 3,
            "name": "Email Template",
            "order": 3,
            "enabled": False,
            "triggers": [
                {
                    "id": 3,
                    "sources": [3],
                    "type": 1,
                    "filter_path": "/mail/*",
                    "filter_filename": "*.eml",
                    "filter_mailrule": 1,
                    "matching_algorithm": 0,
                    "match": "",
                    "is_insensitive": True,
                    "filter_has_tags": [],
                    "filter_has_correspondent": None,
                    "filter_has_document_type": None,
                }
            ],
            "actions": [
                {
                    "id": 3,
                    "type": 1,
                    "assign_title": None,
                    "assign_tags": [],
                    "assign_correspondent": None,
                    "assign_document_type": None,
                    "assign_storage_path": None,
                    "assign_owner": 2,
                    "assign_view_users": [3, 7],
                    "assign_view_groups": [1],
                    "assign_change_users": [6],
                    "assign_change_groups": [],
                    "assign_custom_fields": [],
                }
            ],
        },
    ],
}

DATA_WORKFLOW_ACTIONS = {
    "count": 0,
    "next": None,
    "previous": None,
    "all": [],
    "results": [],
}
for wf in DATA_WORKFLOWS["results"]:
    DATA_WORKFLOW_ACTIONS["count"] += 1
    for act in wf["actions"]:
        DATA_WORKFLOW_ACTIONS["all"].append(act["id"])
        DATA_WORKFLOW_ACTIONS["results"].append(act)

DATA_WORKFLOW_TRIGGERS = {
    "count": 0,
    "next": None,
    "previous": None,
    "all": [],
    "results": [],
}
for wf in DATA_WORKFLOWS["results"]:
    DATA_WORKFLOW_TRIGGERS["count"] += 1
    for act in wf["triggers"]:
        DATA_WORKFLOW_TRIGGERS["all"].append(act["id"])
        DATA_WORKFLOW_TRIGGERS["results"].append(act)