wbcompliance 2.2.1__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wbcompliance/__init__.py +1 -0
- wbcompliance/admin/__init__.py +16 -0
- wbcompliance/admin/compliance_form.py +56 -0
- wbcompliance/admin/compliance_task.py +135 -0
- wbcompliance/admin/compliance_type.py +8 -0
- wbcompliance/admin/risk_management/__init__.py +3 -0
- wbcompliance/admin/risk_management/checks.py +7 -0
- wbcompliance/admin/risk_management/incidents.py +50 -0
- wbcompliance/admin/risk_management/rules.py +63 -0
- wbcompliance/admin/utils.py +46 -0
- wbcompliance/apps.py +14 -0
- wbcompliance/factories/__init__.py +21 -0
- wbcompliance/factories/compliance.py +246 -0
- wbcompliance/factories/risk_management/__init__.py +12 -0
- wbcompliance/factories/risk_management/backends.py +42 -0
- wbcompliance/factories/risk_management/checks.py +12 -0
- wbcompliance/factories/risk_management/incidents.py +84 -0
- wbcompliance/factories/risk_management/rules.py +100 -0
- wbcompliance/filters/__init__.py +2 -0
- wbcompliance/filters/compliances.py +189 -0
- wbcompliance/filters/risk_management/__init__.py +3 -0
- wbcompliance/filters/risk_management/checks.py +22 -0
- wbcompliance/filters/risk_management/incidents.py +113 -0
- wbcompliance/filters/risk_management/rules.py +110 -0
- wbcompliance/filters/risk_management/tables.py +112 -0
- wbcompliance/filters/risk_management/utils.py +3 -0
- wbcompliance/management/__init__.py +10 -0
- wbcompliance/migrations/0001_initial_squashed_squashed_0010_alter_checkedobjectincidentrelationship_resolved_by_and_more.py +1744 -0
- wbcompliance/migrations/0011_alter_riskrule_parameters.py +21 -0
- wbcompliance/migrations/0012_alter_compliancetype_options.py +20 -0
- wbcompliance/migrations/0013_alter_riskrule_unique_together.py +16 -0
- wbcompliance/migrations/0014_alter_reviewcompliancetask_year.py +27 -0
- wbcompliance/migrations/0015_auto_20240103_0957.py +43 -0
- wbcompliance/migrations/0016_checkedobjectincidentrelationship_report_details_and_more.py +37 -0
- wbcompliance/migrations/0017_alter_rulebackend_incident_report_template.py +20 -0
- wbcompliance/migrations/0018_alter_rulecheckedobjectrelationship_unique_together.py +39 -0
- wbcompliance/migrations/0019_rulegroup_riskrule_activation_date_and_more.py +60 -0
- wbcompliance/migrations/__init__.py +0 -0
- wbcompliance/models/__init__.py +20 -0
- wbcompliance/models/compliance_form.py +626 -0
- wbcompliance/models/compliance_task.py +800 -0
- wbcompliance/models/compliance_type.py +133 -0
- wbcompliance/models/enums.py +13 -0
- wbcompliance/models/risk_management/__init__.py +4 -0
- wbcompliance/models/risk_management/backend.py +139 -0
- wbcompliance/models/risk_management/checks.py +194 -0
- wbcompliance/models/risk_management/dispatch.py +41 -0
- wbcompliance/models/risk_management/incidents.py +619 -0
- wbcompliance/models/risk_management/mixins.py +115 -0
- wbcompliance/models/risk_management/rules.py +654 -0
- wbcompliance/permissions.py +32 -0
- wbcompliance/serializers/__init__.py +30 -0
- wbcompliance/serializers/compliance_form.py +320 -0
- wbcompliance/serializers/compliance_task.py +463 -0
- wbcompliance/serializers/compliance_type.py +26 -0
- wbcompliance/serializers/risk_management/__init__.py +19 -0
- wbcompliance/serializers/risk_management/checks.py +53 -0
- wbcompliance/serializers/risk_management/incidents.py +227 -0
- wbcompliance/serializers/risk_management/rules.py +158 -0
- wbcompliance/tasks.py +112 -0
- wbcompliance/tests/__init__.py +0 -0
- wbcompliance/tests/conftest.py +63 -0
- wbcompliance/tests/disable_signals.py +82 -0
- wbcompliance/tests/mixins.py +17 -0
- wbcompliance/tests/risk_management/__init__.py +0 -0
- wbcompliance/tests/risk_management/models/__init__.py +0 -0
- wbcompliance/tests/risk_management/models/test_backends.py +0 -0
- wbcompliance/tests/risk_management/models/test_checks.py +55 -0
- wbcompliance/tests/risk_management/models/test_incidents.py +327 -0
- wbcompliance/tests/risk_management/models/test_rules.py +255 -0
- wbcompliance/tests/signals.py +89 -0
- wbcompliance/tests/test_filters.py +23 -0
- wbcompliance/tests/test_models.py +57 -0
- wbcompliance/tests/test_serializers.py +48 -0
- wbcompliance/tests/test_views.py +377 -0
- wbcompliance/tests/tests.py +21 -0
- wbcompliance/urls.py +238 -0
- wbcompliance/viewsets/__init__.py +40 -0
- wbcompliance/viewsets/buttons/__init__.py +9 -0
- wbcompliance/viewsets/buttons/compliance_form.py +78 -0
- wbcompliance/viewsets/buttons/compliance_task.py +149 -0
- wbcompliance/viewsets/buttons/risk_managment/__init__.py +3 -0
- wbcompliance/viewsets/buttons/risk_managment/checks.py +11 -0
- wbcompliance/viewsets/buttons/risk_managment/incidents.py +51 -0
- wbcompliance/viewsets/buttons/risk_managment/rules.py +35 -0
- wbcompliance/viewsets/compliance_form.py +425 -0
- wbcompliance/viewsets/compliance_task.py +513 -0
- wbcompliance/viewsets/compliance_type.py +38 -0
- wbcompliance/viewsets/display/__init__.py +22 -0
- wbcompliance/viewsets/display/compliance_form.py +317 -0
- wbcompliance/viewsets/display/compliance_task.py +453 -0
- wbcompliance/viewsets/display/compliance_type.py +22 -0
- wbcompliance/viewsets/display/risk_managment/__init__.py +11 -0
- wbcompliance/viewsets/display/risk_managment/checks.py +46 -0
- wbcompliance/viewsets/display/risk_managment/incidents.py +155 -0
- wbcompliance/viewsets/display/risk_managment/rules.py +146 -0
- wbcompliance/viewsets/display/risk_managment/tables.py +51 -0
- wbcompliance/viewsets/endpoints/__init__.py +27 -0
- wbcompliance/viewsets/endpoints/compliance_form.py +207 -0
- wbcompliance/viewsets/endpoints/compliance_task.py +193 -0
- wbcompliance/viewsets/endpoints/compliance_type.py +9 -0
- wbcompliance/viewsets/endpoints/risk_managment/__init__.py +12 -0
- wbcompliance/viewsets/endpoints/risk_managment/checks.py +16 -0
- wbcompliance/viewsets/endpoints/risk_managment/incidents.py +36 -0
- wbcompliance/viewsets/endpoints/risk_managment/rules.py +32 -0
- wbcompliance/viewsets/endpoints/risk_managment/tables.py +14 -0
- wbcompliance/viewsets/menu/__init__.py +17 -0
- wbcompliance/viewsets/menu/compliance_form.py +49 -0
- wbcompliance/viewsets/menu/compliance_task.py +130 -0
- wbcompliance/viewsets/menu/compliance_type.py +17 -0
- wbcompliance/viewsets/menu/risk_management.py +56 -0
- wbcompliance/viewsets/risk_management/__init__.py +21 -0
- wbcompliance/viewsets/risk_management/checks.py +49 -0
- wbcompliance/viewsets/risk_management/incidents.py +204 -0
- wbcompliance/viewsets/risk_management/mixins.py +52 -0
- wbcompliance/viewsets/risk_management/rules.py +179 -0
- wbcompliance/viewsets/risk_management/tables.py +96 -0
- wbcompliance/viewsets/titles/__init__.py +17 -0
- wbcompliance/viewsets/titles/compliance_form.py +101 -0
- wbcompliance/viewsets/titles/compliance_task.py +60 -0
- wbcompliance/viewsets/titles/compliance_type.py +13 -0
- wbcompliance/viewsets/titles/risk_managment/__init__.py +1 -0
- wbcompliance/viewsets/titles/risk_managment/checks.py +0 -0
- wbcompliance/viewsets/titles/risk_managment/incidents.py +0 -0
- wbcompliance/viewsets/titles/risk_managment/rules.py +0 -0
- wbcompliance/viewsets/titles/risk_managment/tables.py +7 -0
- wbcompliance-2.2.1.dist-info/METADATA +7 -0
- wbcompliance-2.2.1.dist-info/RECORD +129 -0
- wbcompliance-2.2.1.dist-info/WHEEL +5 -0
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
from datetime import timedelta
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
from django.utils.translation import gettext as _
|
|
5
|
+
from wbcompliance.models import (
|
|
6
|
+
ComplianceAction,
|
|
7
|
+
ComplianceEvent,
|
|
8
|
+
ComplianceTaskGroup,
|
|
9
|
+
ComplianceTaskInstance,
|
|
10
|
+
ReviewComplianceTask,
|
|
11
|
+
)
|
|
12
|
+
from wbcompliance.models.enums import IncidentSeverity
|
|
13
|
+
from wbcore.enums import Unit
|
|
14
|
+
from wbcore.metadata.configs import display as dp
|
|
15
|
+
from wbcore.metadata.configs.display.instance_display.shortcuts import (
|
|
16
|
+
Display,
|
|
17
|
+
create_simple_display,
|
|
18
|
+
create_simple_section,
|
|
19
|
+
)
|
|
20
|
+
from wbcore.metadata.configs.display.instance_display.utils import repeat_field
|
|
21
|
+
from wbcore.metadata.configs.display.view_config import DisplayViewConfig
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def get_legends(model=None):
|
|
25
|
+
"""
|
|
26
|
+
Dynamically create the activity legend based on Activity Enum
|
|
27
|
+
"""
|
|
28
|
+
list_format = []
|
|
29
|
+
if model:
|
|
30
|
+
for _status, color in model.Status.get_color_map():
|
|
31
|
+
list_format.append(dp.LegendItem(icon=color, label=_status.label, value=_status.value))
|
|
32
|
+
return [dp.Legend(key="status", items=list_format)]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_list_formatting(model=None):
|
|
36
|
+
"""
|
|
37
|
+
Dynamically create the activity list formatting based on Activity Enum
|
|
38
|
+
"""
|
|
39
|
+
color_conditions = []
|
|
40
|
+
if model:
|
|
41
|
+
for _status, color in model.Status.get_color_map():
|
|
42
|
+
color_conditions.append(
|
|
43
|
+
dp.FormattingRule(condition=("==", _status.name), style={"backgroundColor": color})
|
|
44
|
+
)
|
|
45
|
+
return [
|
|
46
|
+
dp.Formatting(column="status", formatting_rules=color_conditions),
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class ComplianceTaskGroupDisplayConfig(DisplayViewConfig):
|
|
51
|
+
def get_list_display(self) -> Optional[dp.ListDisplay]:
|
|
52
|
+
return dp.ListDisplay(
|
|
53
|
+
fields=[
|
|
54
|
+
dp.Field(key="name", label=_("Name")),
|
|
55
|
+
dp.Field(key="order", label=_("Order")),
|
|
56
|
+
]
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
def get_instance_display(self) -> Display:
|
|
60
|
+
return create_simple_display(
|
|
61
|
+
[["name", "order"], [repeat_field(2, "compliancetask_section")]],
|
|
62
|
+
[
|
|
63
|
+
create_simple_section(
|
|
64
|
+
"compliancetask_section", _("Indicators"), [["compliancetask"]], "compliancetask", collapsed=False
|
|
65
|
+
)
|
|
66
|
+
],
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class ComplianceTaskDisplayConfig(DisplayViewConfig):
|
|
71
|
+
def get_list_display(self) -> Optional[dp.ListDisplay]:
|
|
72
|
+
color_conditions = []
|
|
73
|
+
list_format = []
|
|
74
|
+
for _type, color in IncidentSeverity.get_color_map():
|
|
75
|
+
color_conditions.append(dp.FormattingRule(condition=("==", _type.name), style={"backgroundColor": color}))
|
|
76
|
+
list_format.append(dp.LegendItem(icon=color, label=_type.label, value=_type.value))
|
|
77
|
+
|
|
78
|
+
return dp.ListDisplay(
|
|
79
|
+
fields=[
|
|
80
|
+
dp.Field(key="title", label=_("Title"), width=Unit.PIXEL(600)),
|
|
81
|
+
dp.Field(key="occurrence", label=_("Occurrence")),
|
|
82
|
+
dp.Field(key="risk_level", label=_("Risk Level")),
|
|
83
|
+
dp.Field(key="active", label=_("Active")),
|
|
84
|
+
dp.Field(key="group", label=_("Group"), width=Unit.PIXEL(350)),
|
|
85
|
+
dp.Field(key="type", label=_("Administrator")),
|
|
86
|
+
dp.Field(key="review", label=_("Indicator Reports"), width=Unit.PIXEL(300)),
|
|
87
|
+
],
|
|
88
|
+
legends=[dp.Legend(key="risk_level", items=list_format)],
|
|
89
|
+
formatting=[
|
|
90
|
+
dp.Formatting(column="risk_level", formatting_rules=color_conditions),
|
|
91
|
+
],
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
def get_instance_display(self) -> Display:
|
|
95
|
+
return create_simple_display(
|
|
96
|
+
[
|
|
97
|
+
["title", "title", "type"],
|
|
98
|
+
["occurrence", "risk_level", "active"],
|
|
99
|
+
["review", "review", "group"],
|
|
100
|
+
[repeat_field(3, "description")],
|
|
101
|
+
[repeat_field(3, "remarks")],
|
|
102
|
+
[repeat_field(3, "compliancetaskinstance_section")],
|
|
103
|
+
],
|
|
104
|
+
[
|
|
105
|
+
create_simple_section(
|
|
106
|
+
"compliancetaskinstance_section",
|
|
107
|
+
_("Instances"),
|
|
108
|
+
[["compliancetaskinstance"]],
|
|
109
|
+
"compliancetaskinstance",
|
|
110
|
+
collapsed=True,
|
|
111
|
+
)
|
|
112
|
+
],
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class ComplianceTaskReviewDisplayConfig(ComplianceTaskDisplayConfig):
|
|
117
|
+
def get_list_display(self) -> Optional[dp.ListDisplay]:
|
|
118
|
+
color_conditions = []
|
|
119
|
+
list_format = []
|
|
120
|
+
for _type, color in IncidentSeverity.get_color_map():
|
|
121
|
+
color_conditions.append(dp.FormattingRule(condition=("==", _type.name), style={"backgroundColor": color}))
|
|
122
|
+
list_format.append(dp.LegendItem(icon=color, label=_type.label, value=_type.value))
|
|
123
|
+
|
|
124
|
+
return dp.ListDisplay(
|
|
125
|
+
fields=[
|
|
126
|
+
dp.Field(key="title", label=_("Title"), width=Unit.PIXEL(400)),
|
|
127
|
+
dp.Field(key="description", label=_("Description"), width=Unit.PIXEL(400)),
|
|
128
|
+
dp.Field(key="occurrence", label=_("Occurrence"), width=Unit.PIXEL(150)),
|
|
129
|
+
dp.Field(key="risk_level", label=_("Risk level"), width=Unit.PIXEL(150)),
|
|
130
|
+
dp.Field(key="remarks", label=_("Remarks"), width=Unit.PIXEL(250)),
|
|
131
|
+
dp.Field(key="group", label=_("Group"), width=Unit.PIXEL(250)),
|
|
132
|
+
dp.Field(key="type", label=_("Administrator"), width=Unit.PIXEL(160)),
|
|
133
|
+
],
|
|
134
|
+
legends=[dp.Legend(key="risk_level", items=list_format)],
|
|
135
|
+
formatting=[
|
|
136
|
+
dp.Formatting(column="risk_level", formatting_rules=color_conditions),
|
|
137
|
+
],
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
class ComplianceTaskInstanceDisplayConfig(DisplayViewConfig):
|
|
142
|
+
def get_list_display(self) -> Optional[dp.ListDisplay]:
|
|
143
|
+
return dp.ListDisplay(
|
|
144
|
+
fields=[
|
|
145
|
+
dp.Field(key="task", label=_("Indicators")),
|
|
146
|
+
dp.Field(key="occured", label=_("Occured")),
|
|
147
|
+
dp.Field(key="status", label=_("Status")),
|
|
148
|
+
dp.Field(key="type_name", label=_("Administrator")),
|
|
149
|
+
dp.Field(key="group_name", label=_("Group")),
|
|
150
|
+
dp.Field(key="review", label=_("Indicator Instance Report")),
|
|
151
|
+
],
|
|
152
|
+
legends=get_legends(ComplianceTaskInstance),
|
|
153
|
+
formatting=get_list_formatting(ComplianceTaskInstance),
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
def get_instance_display(self) -> Display:
|
|
157
|
+
return create_simple_display(
|
|
158
|
+
[
|
|
159
|
+
[repeat_field(2, "type_name")],
|
|
160
|
+
["task", "review"],
|
|
161
|
+
["status", "occured"],
|
|
162
|
+
[repeat_field(2, "text")],
|
|
163
|
+
[repeat_field(2, "summary_text")],
|
|
164
|
+
]
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
class ComplianceTaskInstanceComplianceTaskDisplayConfig(DisplayViewConfig):
|
|
169
|
+
def get_list_display(self) -> Optional[dp.ListDisplay]:
|
|
170
|
+
return dp.ListDisplay(
|
|
171
|
+
fields=[
|
|
172
|
+
dp.Field(key="occured", label=_("Occured")),
|
|
173
|
+
dp.Field(key="status", label=_("Status")),
|
|
174
|
+
dp.Field(key="type_name", label=_("Administrator")),
|
|
175
|
+
dp.Field(key="group_name", label=_("Group")),
|
|
176
|
+
dp.Field(key="review", label=_("Indicator Instance Report")),
|
|
177
|
+
],
|
|
178
|
+
legends=get_legends(ComplianceTaskInstance),
|
|
179
|
+
formatting=get_list_formatting(ComplianceTaskInstance),
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
def get_instance_display(self) -> Display:
|
|
183
|
+
return create_simple_display(
|
|
184
|
+
[
|
|
185
|
+
[repeat_field(2, "type_name")],
|
|
186
|
+
[repeat_field(2, "review")],
|
|
187
|
+
["status", "occured"],
|
|
188
|
+
[repeat_field(2, "text")],
|
|
189
|
+
[repeat_field(2, "summary_text")],
|
|
190
|
+
]
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
class ComplianceTaskInstanceReviewDisplayConfig(DisplayViewConfig):
|
|
195
|
+
def get_list_display(self) -> Optional[dp.ListDisplay]:
|
|
196
|
+
return dp.ListDisplay(
|
|
197
|
+
fields=[
|
|
198
|
+
dp.Field(key="occured", label=_("Occured"), width=Unit.PIXEL(90)),
|
|
199
|
+
dp.Field(key="task_title", label=_("Indicators"), width=Unit.PIXEL(380)),
|
|
200
|
+
dp.Field(key="status", label=_("Status"), width=Unit.PIXEL(200)),
|
|
201
|
+
dp.Field(key="text", label=_("Text"), width=Unit.PIXEL(500)),
|
|
202
|
+
dp.Field(key="summary_text", label=_("Summary Text"), width=Unit.PIXEL(400)),
|
|
203
|
+
dp.Field(key="type_name", label=_("Administrator"), width=Unit.PIXEL(100)),
|
|
204
|
+
],
|
|
205
|
+
legends=get_legends(ComplianceTaskInstance),
|
|
206
|
+
formatting=get_list_formatting(ComplianceTaskInstance),
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
def get_instance_display(self) -> Display:
|
|
210
|
+
return create_simple_display(
|
|
211
|
+
[
|
|
212
|
+
[repeat_field(2, "type_name")],
|
|
213
|
+
[repeat_field(2, "review")],
|
|
214
|
+
["status", "occured"],
|
|
215
|
+
[repeat_field(2, "text")],
|
|
216
|
+
[repeat_field(2, "summary_text")],
|
|
217
|
+
]
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
class ComplianceTaskMatrixPandasDisplayConfig(DisplayViewConfig):
|
|
222
|
+
def get_list_display(self) -> Optional[dp.ListDisplay]:
|
|
223
|
+
_color_conditions = []
|
|
224
|
+
for _status, color in ComplianceTaskInstance.Status.get_color_map():
|
|
225
|
+
_color_conditions.append(
|
|
226
|
+
dp.FormattingRule(condition=("==", _status.label), style={"backgroundColor": color})
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
_fields = [
|
|
230
|
+
dp.Field(key="type_name", label=_("Administrator"), width=Unit.PIXEL(100)),
|
|
231
|
+
dp.Field(key="group_name", label=_("Group"), width=Unit.PIXEL(200)),
|
|
232
|
+
dp.Field(
|
|
233
|
+
key="task_title",
|
|
234
|
+
label=_("Indicator"),
|
|
235
|
+
width=Unit.PIXEL(270),
|
|
236
|
+
formatting_rules=[dp.FormattingRule(condition=("!=", ""), style={"font-weight": "bold"})],
|
|
237
|
+
),
|
|
238
|
+
]
|
|
239
|
+
if _dict := ComplianceTaskInstance.get_dict_max_count_task():
|
|
240
|
+
qs_occured = (
|
|
241
|
+
ComplianceTaskInstance.objects.filter(task=_dict.get("task"))
|
|
242
|
+
.order_by("-occured")
|
|
243
|
+
.values_list("occured", flat=True)
|
|
244
|
+
.distinct()[:12]
|
|
245
|
+
)
|
|
246
|
+
for date in qs_occured:
|
|
247
|
+
date_str = date.strftime("%Y-%m-%d")
|
|
248
|
+
covered_month = (date - timedelta(days=1)).strftime("%Y-%h")
|
|
249
|
+
_fields.append(
|
|
250
|
+
dp.Field(
|
|
251
|
+
key=date_str, label=covered_month, formatting_rules=_color_conditions, width=Unit.PIXEL(150)
|
|
252
|
+
)
|
|
253
|
+
)
|
|
254
|
+
return dp.ListDisplay(fields=_fields)
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
class ComplianceActionDisplayConfig(DisplayViewConfig):
|
|
258
|
+
def get_list_display(self) -> Optional[dp.ListDisplay]:
|
|
259
|
+
return dp.ListDisplay(
|
|
260
|
+
fields=[
|
|
261
|
+
dp.Field(key="title", label=_("Title")),
|
|
262
|
+
dp.Field(key="status", label=_("Status")),
|
|
263
|
+
dp.Field(key="deadline", label=_("Deadline")),
|
|
264
|
+
dp.Field(key="progress", label=_("Progress")),
|
|
265
|
+
dp.Field(key="active", label=_("Active")),
|
|
266
|
+
dp.Field(key="type", label="Administrator"),
|
|
267
|
+
dp.Field(key="creator", label="Creator"),
|
|
268
|
+
dp.Field(key="changer", label="Changer"),
|
|
269
|
+
dp.Field(key="last_modified", label="Changed"),
|
|
270
|
+
],
|
|
271
|
+
legends=get_legends(ComplianceAction),
|
|
272
|
+
formatting=get_list_formatting(ComplianceAction),
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
def get_instance_display(self) -> Display:
|
|
276
|
+
return create_simple_display(
|
|
277
|
+
[
|
|
278
|
+
[repeat_field(2, "title")],
|
|
279
|
+
[repeat_field(2, "type")],
|
|
280
|
+
["active", "deadline"],
|
|
281
|
+
["status", "progress"],
|
|
282
|
+
["creator", "created"],
|
|
283
|
+
["changer", "last_modified"],
|
|
284
|
+
[repeat_field(2, "description")],
|
|
285
|
+
[repeat_field(2, "summary_description")],
|
|
286
|
+
]
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
class ComplianceEventDisplayConfig(DisplayViewConfig):
|
|
291
|
+
def get_list_display(self) -> Optional[dp.ListDisplay]:
|
|
292
|
+
color_conditions = []
|
|
293
|
+
list_format = []
|
|
294
|
+
for _type, color in ComplianceEvent.Type.get_color_map():
|
|
295
|
+
color_conditions.append(dp.FormattingRule(condition=("==", _type.name), style={"backgroundColor": color}))
|
|
296
|
+
list_format.append(dp.LegendItem(icon=color, label=_type.label, value=_type.value))
|
|
297
|
+
|
|
298
|
+
return dp.ListDisplay(
|
|
299
|
+
fields=[
|
|
300
|
+
dp.Field(key="title", label="Title"),
|
|
301
|
+
dp.Field(key="type_event", label="Type Event"),
|
|
302
|
+
dp.Field(key="level", label="Level"),
|
|
303
|
+
dp.Field(key="active", label="Active"),
|
|
304
|
+
dp.Field(key="type", label="Administrator"),
|
|
305
|
+
dp.Field(key="creator", label="Creator"),
|
|
306
|
+
dp.Field(key="changer", label="Changer"),
|
|
307
|
+
dp.Field(key="last_modified", label="Changed"),
|
|
308
|
+
dp.Field(key="confidential", label="Confidential"),
|
|
309
|
+
],
|
|
310
|
+
legends=[dp.Legend(key="type_event", items=list_format)],
|
|
311
|
+
formatting=[
|
|
312
|
+
dp.Formatting(column="type_event", formatting_rules=color_conditions),
|
|
313
|
+
],
|
|
314
|
+
)
|
|
315
|
+
|
|
316
|
+
def get_instance_display(self) -> Display:
|
|
317
|
+
return create_simple_display(
|
|
318
|
+
[
|
|
319
|
+
[repeat_field(2, "title")],
|
|
320
|
+
[repeat_field(2, "type")],
|
|
321
|
+
["active", "confidential"],
|
|
322
|
+
["type_event", "level"],
|
|
323
|
+
["creator", "created"],
|
|
324
|
+
["changer", "last_modified"],
|
|
325
|
+
[repeat_field(2, "exec_summary")],
|
|
326
|
+
[repeat_field(2, "exec_summary_board")],
|
|
327
|
+
[repeat_field(2, "description")],
|
|
328
|
+
[repeat_field(2, "actions_taken")],
|
|
329
|
+
[repeat_field(2, "consequences")],
|
|
330
|
+
[repeat_field(2, "future_suggestions")],
|
|
331
|
+
]
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
class ReviewComplianceTaskDisplayConfig(DisplayViewConfig):
|
|
336
|
+
def get_list_display(self) -> Optional[dp.ListDisplay]:
|
|
337
|
+
return dp.ListDisplay(
|
|
338
|
+
fields=[
|
|
339
|
+
dp.Field(key="year", label="Year"),
|
|
340
|
+
dp.Field(key="occured", label="Occured Instance"),
|
|
341
|
+
dp.Field(key="title", label="Title"),
|
|
342
|
+
dp.Field(key="from_date", label="From"),
|
|
343
|
+
dp.Field(key="to_date", label="To"),
|
|
344
|
+
dp.Field(key="status", label="Status"),
|
|
345
|
+
dp.Field(key="occurrence", label="Occurrence"),
|
|
346
|
+
dp.Field(key="changer", label="Changer"),
|
|
347
|
+
dp.Field(key="changed", label="Changed"),
|
|
348
|
+
dp.Field(key="type", label="Administrator"),
|
|
349
|
+
dp.Field(key="review_task", label="Main Indicator Report"),
|
|
350
|
+
],
|
|
351
|
+
legends=get_legends(ReviewComplianceTask),
|
|
352
|
+
formatting=get_list_formatting(ReviewComplianceTask),
|
|
353
|
+
)
|
|
354
|
+
|
|
355
|
+
def get_instance_display(self) -> Display:
|
|
356
|
+
nb_columns = 3
|
|
357
|
+
fields = [
|
|
358
|
+
["title", "type", "review_task"],
|
|
359
|
+
["from_date", "to_date", "status"],
|
|
360
|
+
["is_instance", "occurrence", "occured"],
|
|
361
|
+
[repeat_field(nb_columns, "description")],
|
|
362
|
+
]
|
|
363
|
+
|
|
364
|
+
sections = []
|
|
365
|
+
if self.view.kwargs.get("pk", None):
|
|
366
|
+
instance = self.view.get_object()
|
|
367
|
+
if not instance.is_instance:
|
|
368
|
+
if instance.status == ReviewComplianceTask.Status.DRAFT:
|
|
369
|
+
fields.append([repeat_field(nb_columns, "task_group_section")])
|
|
370
|
+
sections.append(
|
|
371
|
+
create_simple_section(
|
|
372
|
+
"task_group_section", _("Groups Indicator"), [["task_group"]], "task_group", collapsed=True
|
|
373
|
+
)
|
|
374
|
+
)
|
|
375
|
+
|
|
376
|
+
group_ids = instance.get_task_group_ids_from_review()
|
|
377
|
+
no_group_ids = instance.get_task_group_ids_from_review(task_with_group=False)
|
|
378
|
+
total = len(group_ids)
|
|
379
|
+
if (
|
|
380
|
+
no_group_ids and instance.status != ReviewComplianceTask.Status.DRAFT
|
|
381
|
+
) or instance.status == ReviewComplianceTask.Status.DRAFT:
|
|
382
|
+
total += 1
|
|
383
|
+
for count, group_id in enumerate(group_ids):
|
|
384
|
+
group = ComplianceTaskGroup.objects.get(id=group_id)
|
|
385
|
+
key = f"taskgroup{group.id}"
|
|
386
|
+
fields.append([repeat_field(nb_columns, f"{key}_section")])
|
|
387
|
+
sections.append(
|
|
388
|
+
create_simple_section(
|
|
389
|
+
f"{key}_section", f"({count + 1}/{total}). {group.name}", [[key]], key, collapsed=True
|
|
390
|
+
)
|
|
391
|
+
)
|
|
392
|
+
|
|
393
|
+
if (
|
|
394
|
+
no_group_ids and instance.status != ReviewComplianceTask.Status.DRAFT
|
|
395
|
+
) or instance.status == ReviewComplianceTask.Status.DRAFT:
|
|
396
|
+
fields.append([repeat_field(nb_columns, "task_no_group_section")])
|
|
397
|
+
sections.append(
|
|
398
|
+
create_simple_section(
|
|
399
|
+
"task_no_group_section",
|
|
400
|
+
f'({total}/{total}). {_("No Indicator Group")}',
|
|
401
|
+
[["task_no_group"]],
|
|
402
|
+
"task_no_group",
|
|
403
|
+
collapsed=True,
|
|
404
|
+
)
|
|
405
|
+
)
|
|
406
|
+
|
|
407
|
+
else:
|
|
408
|
+
group_ids = instance.get_task_group_ids_from_review(through_task=False)
|
|
409
|
+
no_group_ids = instance.get_task_group_ids_from_review(through_task=False, task_with_group=False)
|
|
410
|
+
total = len(group_ids) + 2 # We add 2 to the total number to include Actions and events
|
|
411
|
+
if no_group_ids:
|
|
412
|
+
total += 1
|
|
413
|
+
for count, group_id in enumerate(group_ids):
|
|
414
|
+
group = ComplianceTaskGroup.objects.get(id=group_id)
|
|
415
|
+
key = f"taskinstancegroup{group.id}"
|
|
416
|
+
fields.append([repeat_field(nb_columns, f"{key}_section")])
|
|
417
|
+
sections.append(
|
|
418
|
+
create_simple_section(
|
|
419
|
+
f"{key}_section", f"({count + 1}/{total}). {group.name}", [[key]], key, collapsed=True
|
|
420
|
+
)
|
|
421
|
+
)
|
|
422
|
+
|
|
423
|
+
if no_group_ids:
|
|
424
|
+
fields.append([repeat_field(nb_columns, "taskinstance_no_group_section")])
|
|
425
|
+
sections.append(
|
|
426
|
+
create_simple_section(
|
|
427
|
+
"taskinstance_no_group_section",
|
|
428
|
+
f'({count + 2}/{total}). {_("No Indicator Group")}',
|
|
429
|
+
[["taskinstance_no_group"]],
|
|
430
|
+
"taskinstance_no_group",
|
|
431
|
+
collapsed=True,
|
|
432
|
+
)
|
|
433
|
+
)
|
|
434
|
+
|
|
435
|
+
fields.append([repeat_field(nb_columns, "actions_section")])
|
|
436
|
+
sections.append(
|
|
437
|
+
create_simple_section(
|
|
438
|
+
"actions_section",
|
|
439
|
+
f'({total - 1}/{total}). {_("Actions")}',
|
|
440
|
+
[["actions"]],
|
|
441
|
+
"actions",
|
|
442
|
+
collapsed=True,
|
|
443
|
+
)
|
|
444
|
+
)
|
|
445
|
+
|
|
446
|
+
fields.append([repeat_field(nb_columns, "events_section")])
|
|
447
|
+
sections.append(
|
|
448
|
+
create_simple_section(
|
|
449
|
+
"events_section", f'({total}/{total}). {_("Events")}', [["events"]], "events", collapsed=True
|
|
450
|
+
)
|
|
451
|
+
)
|
|
452
|
+
|
|
453
|
+
return create_simple_display(fields, sections)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from django.utils.translation import gettext as _
|
|
4
|
+
from wbcore.metadata.configs import display as dp
|
|
5
|
+
from wbcore.metadata.configs.display.instance_display.shortcuts import (
|
|
6
|
+
Display,
|
|
7
|
+
create_simple_display,
|
|
8
|
+
)
|
|
9
|
+
from wbcore.metadata.configs.display.view_config import DisplayViewConfig
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ComplianceTypeDisplayConfig(DisplayViewConfig):
|
|
13
|
+
def get_list_display(self) -> Optional[dp.ListDisplay]:
|
|
14
|
+
return dp.ListDisplay(
|
|
15
|
+
fields=[
|
|
16
|
+
dp.Field(key="name", label=_("Name")),
|
|
17
|
+
dp.Field(key="in_charge", label=_("Group of administrators")),
|
|
18
|
+
]
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
def get_instance_display(self) -> Display:
|
|
22
|
+
return create_simple_display([["name", "description", "in_charge", "administrators"]])
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from .checks import RiskCheckDisplayConfig
|
|
2
|
+
from .incidents import (
|
|
3
|
+
CheckedObjectIncidentRelationshipRiskRuleDisplayConfig,
|
|
4
|
+
RiskIncidentDisplayConfig,
|
|
5
|
+
)
|
|
6
|
+
from .rules import (
|
|
7
|
+
RiskRuleDisplayConfig,
|
|
8
|
+
RuleCheckedObjectRelationshipRiskRuleDisplayConfig,
|
|
9
|
+
RuleThresholdRiskRuleDisplayConfig,
|
|
10
|
+
)
|
|
11
|
+
from .tables import RiskManagementIncidentTableDisplayConfig
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from django.utils.translation import gettext as _
|
|
4
|
+
from wbcompliance.models.risk_management.checks import RiskCheck
|
|
5
|
+
from wbcore.metadata.configs import display as dp
|
|
6
|
+
from wbcore.metadata.configs.display.instance_display.shortcuts import (
|
|
7
|
+
Display,
|
|
8
|
+
create_simple_display,
|
|
9
|
+
)
|
|
10
|
+
from wbcore.metadata.configs.display.instance_display.utils import repeat_field
|
|
11
|
+
from wbcore.metadata.configs.display.view_config import DisplayViewConfig
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class RiskCheckDisplayConfig(DisplayViewConfig):
|
|
15
|
+
def get_list_display(self) -> Optional[dp.ListDisplay]:
|
|
16
|
+
return dp.ListDisplay(
|
|
17
|
+
fields=[
|
|
18
|
+
dp.Field(key="rule_repr", label=_("Rule")),
|
|
19
|
+
dp.Field(key="evaluation_date", label=_("Evaluation Date")),
|
|
20
|
+
dp.Field(key="creation_datetime", label=_("Creation Time")),
|
|
21
|
+
dp.Field(
|
|
22
|
+
key="status_icon",
|
|
23
|
+
label=_("Status"),
|
|
24
|
+
formatting_rules=[
|
|
25
|
+
dp.FormattingRule(
|
|
26
|
+
style={"color": RiskCheck.CheckStatus[value].color},
|
|
27
|
+
condition=("==", RiskCheck.CheckStatus[value].icon),
|
|
28
|
+
)
|
|
29
|
+
for value in RiskCheck.CheckStatus.values
|
|
30
|
+
],
|
|
31
|
+
),
|
|
32
|
+
],
|
|
33
|
+
legends=[
|
|
34
|
+
dp.Legend(
|
|
35
|
+
items=[
|
|
36
|
+
dp.LegendItem(icon=RiskCheck.CheckStatus[value].icon, label=RiskCheck.CheckStatus[value].label)
|
|
37
|
+
for value in RiskCheck.CheckStatus.values
|
|
38
|
+
]
|
|
39
|
+
)
|
|
40
|
+
],
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def get_instance_display(self) -> Display:
|
|
44
|
+
return create_simple_display(
|
|
45
|
+
[[repeat_field(3, "status")], ["rule_checked_object_relationship", "evaluation_date", "creation_datetime"]]
|
|
46
|
+
)
|