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
wbcompliance/urls.py
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
from django.urls import include, path
|
|
2
|
+
from wbcompliance import viewsets
|
|
3
|
+
from wbcore.routers import WBCoreRouter
|
|
4
|
+
|
|
5
|
+
router = WBCoreRouter()
|
|
6
|
+
router.register(
|
|
7
|
+
r"complianceformrepresentation",
|
|
8
|
+
viewsets.ComplianceFormRepresentationViewSet,
|
|
9
|
+
basename="complianceformrepresentation",
|
|
10
|
+
)
|
|
11
|
+
router.register(
|
|
12
|
+
r"complianceformsectionrepresentation",
|
|
13
|
+
viewsets.ComplianceFormSectionRepresentationViewSet,
|
|
14
|
+
basename="complianceformsectionrepresentation",
|
|
15
|
+
)
|
|
16
|
+
router.register(
|
|
17
|
+
r"complianceformsignaturesectionrepresentation",
|
|
18
|
+
viewsets.ComplianceFormSignatureSectionRepresentationViewSet,
|
|
19
|
+
basename="complianceformsignaturesectionrepresentation",
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
router.register(
|
|
23
|
+
r"complianceformtyperepresentation",
|
|
24
|
+
viewsets.ComplianceFormTypeRepresentationViewSet,
|
|
25
|
+
basename="complianceformtyperepresentation",
|
|
26
|
+
)
|
|
27
|
+
router.register(r"complianceformtype", viewsets.ComplianceFormTypeViewSet, basename="complianceformtype")
|
|
28
|
+
|
|
29
|
+
router.register(r"complianceform", viewsets.ComplianceFormModelViewSet)
|
|
30
|
+
router.register(
|
|
31
|
+
r"complianceformsignature", viewsets.ComplianceFormSignatureModelViewSet, basename="complianceformsignature"
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
router.register(r"complianceformsection", viewsets.ComplianceFormSectionViewSet, basename="complianceformsection")
|
|
35
|
+
|
|
36
|
+
router.register(r"complianceformrule", viewsets.ComplianceFormRuleViewSet, basename="complianceformrule")
|
|
37
|
+
|
|
38
|
+
router.register(
|
|
39
|
+
r"compliancetaskrepresentation",
|
|
40
|
+
viewsets.ComplianceTaskRepresentationViewSet,
|
|
41
|
+
basename="compliancetaskrepresentation",
|
|
42
|
+
)
|
|
43
|
+
router.register(r"compliancetask", viewsets.ComplianceTaskModelViewSet, basename="compliancetask")
|
|
44
|
+
router.register(
|
|
45
|
+
r"compliancetaskinstance", viewsets.ComplianceTaskInstanceModelViewSet, basename="compliancetaskinstance"
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
router.register(r"complianceaction", viewsets.ComplianceActionModelViewSet, basename="complianceaction")
|
|
49
|
+
router.register(r"complianceevent", viewsets.ComplianceEventModelViewSet, basename="complianceevent")
|
|
50
|
+
|
|
51
|
+
router.register(
|
|
52
|
+
r"compliancetyperepresentation",
|
|
53
|
+
viewsets.ComplianceTypeRepresentationViewSet,
|
|
54
|
+
basename="compliancetyperepresentation",
|
|
55
|
+
)
|
|
56
|
+
router.register(r"compliancetype", viewsets.ComplianceTypeModelViewSet, basename="compliancetype")
|
|
57
|
+
|
|
58
|
+
router.register(
|
|
59
|
+
r"reviewcompliancetaskrepresentation",
|
|
60
|
+
viewsets.ReviewComplianceTaskRepresentationViewSet,
|
|
61
|
+
basename="reviewcompliancetaskrepresentation",
|
|
62
|
+
)
|
|
63
|
+
router.register(r"reviewcompliancetask", viewsets.ReviewComplianceTaskModelViewSet, basename="reviewcompliancetask")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
router.register(
|
|
67
|
+
r"compliancetaskgrouprepresentation",
|
|
68
|
+
viewsets.ComplianceTaskGroupRepresentationViewSet,
|
|
69
|
+
basename="compliancetaskgrouprepresentation",
|
|
70
|
+
)
|
|
71
|
+
router.register(r"compliancetaskgroup", viewsets.ComplianceTaskGroupModelViewSet, basename="compliancetaskgroup")
|
|
72
|
+
|
|
73
|
+
# Subrouter for compliance type
|
|
74
|
+
compliance_type_router = WBCoreRouter()
|
|
75
|
+
compliance_type_router.register(
|
|
76
|
+
r"complianceaction",
|
|
77
|
+
viewsets.TypeComplianceActionModelViewSet,
|
|
78
|
+
basename="type-complianceaction",
|
|
79
|
+
)
|
|
80
|
+
compliance_type_router.register(
|
|
81
|
+
r"complianceevent",
|
|
82
|
+
viewsets.TypeComplianceEventModelViewSet,
|
|
83
|
+
basename="type-complianceevent",
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
# Subrouter for forms to be signed of a Compliance Form
|
|
88
|
+
compliance_form_router = WBCoreRouter()
|
|
89
|
+
compliance_form_router.register(
|
|
90
|
+
r"signatures",
|
|
91
|
+
viewsets.CFComplianceFormSignatureModelViewSet,
|
|
92
|
+
basename="complianceform-signatures",
|
|
93
|
+
)
|
|
94
|
+
# Subrouter for the section of a Compliance Form
|
|
95
|
+
compliance_form_router.register(
|
|
96
|
+
r"sections",
|
|
97
|
+
viewsets.ComplianceFormSectionComplianceFormViewSet,
|
|
98
|
+
basename="complianceform-sections",
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
# Subrouter for the rules of a section
|
|
103
|
+
section_router = WBCoreRouter()
|
|
104
|
+
section_router.register(
|
|
105
|
+
r"rules",
|
|
106
|
+
viewsets.ComplianceFormSectionRuleViewSet,
|
|
107
|
+
basename="complianceformsection-rules",
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
section_router.register(
|
|
111
|
+
r"signauturerules",
|
|
112
|
+
viewsets.ComplianceFormSignatureSectionRuleViewSet,
|
|
113
|
+
basename="complianceformsignaturesection-rules",
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
# Subrouter for the compliance task of a group
|
|
118
|
+
taskgroup_router = WBCoreRouter()
|
|
119
|
+
taskgroup_router.register(
|
|
120
|
+
r"compliancetaskgroup",
|
|
121
|
+
viewsets.ComplianceTaskComplianceTaskGroupModelViewSet,
|
|
122
|
+
basename="compliancetaskgroup-compliancetask",
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
task_router = WBCoreRouter()
|
|
126
|
+
task_router.register(
|
|
127
|
+
r"compliancetask",
|
|
128
|
+
viewsets.ComplianceTaskInstanceComplianceTaskModelViewSet,
|
|
129
|
+
basename="compliancetask-compliancetaskinstance",
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
# Subrouter for the compliance task of a review
|
|
134
|
+
review_router = WBCoreRouter()
|
|
135
|
+
review_router.register(
|
|
136
|
+
r"compliancetasknogroup",
|
|
137
|
+
viewsets.ComplianceTaskReviewNoGroupModelViewSet,
|
|
138
|
+
basename="review-compliancetasknogroup",
|
|
139
|
+
)
|
|
140
|
+
review_router.register(
|
|
141
|
+
r"compliancetaskinstancenogroup",
|
|
142
|
+
viewsets.ComplianceTaskInstanceReviewNoGroupModelViewSet,
|
|
143
|
+
basename="review-compliancetaskinstancenogroup",
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
# Subrouter for the compliance task of a group of a review
|
|
147
|
+
review_group_router = WBCoreRouter()
|
|
148
|
+
review_group_router.register(
|
|
149
|
+
r"compliancetaskgroup",
|
|
150
|
+
viewsets.ComplianceTaskReviewGroupModelViewSet,
|
|
151
|
+
basename="review-compliancetaskgroup",
|
|
152
|
+
)
|
|
153
|
+
review_group_router.register(
|
|
154
|
+
r"compliancetaskinstancegroup",
|
|
155
|
+
viewsets.ComplianceTaskInstanceReviewGroupModelViewSet,
|
|
156
|
+
basename="review-compliancetaskinstancegroup",
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
# Risk Management url routing
|
|
160
|
+
|
|
161
|
+
router.register("riskcheckrepresentation", viewsets.RiskCheckRepresentationViewSet, basename="riskcheckrepresentation")
|
|
162
|
+
router.register("rulegrouprepresentation", viewsets.RuleGroupRepresentationViewSet, basename="rulegrouprepresentation")
|
|
163
|
+
router.register(
|
|
164
|
+
"riskincidentrepresentation", viewsets.RiskIncidentRepresentationViewSet, basename="riskincidentrepresentation"
|
|
165
|
+
)
|
|
166
|
+
router.register(
|
|
167
|
+
"riskincidenttyperepresentation",
|
|
168
|
+
viewsets.RiskIncidentTypeRepresentationViewSet,
|
|
169
|
+
basename="riskincidenttyperepresentation",
|
|
170
|
+
)
|
|
171
|
+
router.register(
|
|
172
|
+
"checkedobjectincidentrelationshiprepresentation",
|
|
173
|
+
viewsets.CheckedObjectIncidentRelationshipRepresentationViewSet,
|
|
174
|
+
basename="checkedobjectincidentrelationshiprepresentation",
|
|
175
|
+
)
|
|
176
|
+
router.register(
|
|
177
|
+
"rulechecked_objectrelationshiprepresentation",
|
|
178
|
+
viewsets.RuleCheckedObjectRelationshipRepresentationViewSet,
|
|
179
|
+
basename="rulechecked_objectrelationshiprepresentation",
|
|
180
|
+
)
|
|
181
|
+
router.register(
|
|
182
|
+
"rulebackendrepresentation", viewsets.RuleBackendRepresentationViewSet, basename="rulebackendrepresentation"
|
|
183
|
+
)
|
|
184
|
+
router.register(
|
|
185
|
+
"rulethresholdrepresentation", viewsets.RuleThresholdRepresentationViewSet, basename="rulethresholdrepresentation"
|
|
186
|
+
)
|
|
187
|
+
router.register("riskrulerepresentation", viewsets.RiskRuleRepresentationViewSet, basename="riskrulerepresentation")
|
|
188
|
+
router.register("riskincident", viewsets.RiskIncidentModelViewSet, basename="riskincident")
|
|
189
|
+
router.register(
|
|
190
|
+
"checkedobjectincidentrelationship",
|
|
191
|
+
viewsets.CheckedObjectIncidentRelationshipModelViewSet,
|
|
192
|
+
basename="checkedobjectincidentrelationship",
|
|
193
|
+
)
|
|
194
|
+
router.register("riskcheck", viewsets.RiskCheckModelViewSet, basename="riskcheck")
|
|
195
|
+
router.register("riskrule", viewsets.RiskRuleModelViewSet, basename="riskrule")
|
|
196
|
+
|
|
197
|
+
rule_group_router = WBCoreRouter()
|
|
198
|
+
rule_group_router.register(
|
|
199
|
+
r"incident",
|
|
200
|
+
viewsets.RiskIncidentRiskRuleModelViewSet,
|
|
201
|
+
basename="riskrule-incident",
|
|
202
|
+
)
|
|
203
|
+
rule_group_router.register(
|
|
204
|
+
r"relationship",
|
|
205
|
+
viewsets.RuleCheckedObjectRelationshipRiskRuleModelViewSet,
|
|
206
|
+
basename="riskrule-relationship",
|
|
207
|
+
)
|
|
208
|
+
rule_group_router.register(
|
|
209
|
+
r"threshold",
|
|
210
|
+
viewsets.RuleThresholdRiskRuleModelViewSet,
|
|
211
|
+
basename="riskrule-threshold",
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
incident_group_router = WBCoreRouter()
|
|
215
|
+
incident_group_router.register(
|
|
216
|
+
r"relationship",
|
|
217
|
+
viewsets.CheckedObjectIncidentRelationshipRiskRuleModelViewSet,
|
|
218
|
+
basename="riskincident-relationship",
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
# Pandas ViewSet
|
|
222
|
+
router.register("compliancetaskmatrix", viewsets.ComplianceTaskMatrixPandasViewSet, basename="compliancetaskmatrix")
|
|
223
|
+
router.register(
|
|
224
|
+
"riskmanagementincidenttable", viewsets.RiskManagementIncidentTableView, basename="riskmanagementincidenttable"
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
urlpatterns = [
|
|
228
|
+
path("", include(router.urls)),
|
|
229
|
+
path("riskrule/<int:rule_id>/", include(rule_group_router.urls)),
|
|
230
|
+
path("riskincident/<int:incident_id>/", include(incident_group_router.urls)),
|
|
231
|
+
path("complianceform/<int:compliance_form_id>/", include(compliance_form_router.urls)),
|
|
232
|
+
path("section/<int:section_id>/", include(section_router.urls)),
|
|
233
|
+
path("taskgroup/<int:group_id>/", include(taskgroup_router.urls)),
|
|
234
|
+
path("task/<int:task_id>/", include(task_router.urls)),
|
|
235
|
+
path("review/<int:review_id>/", include(review_router.urls)),
|
|
236
|
+
path("review/<int:review_id>/group/<int:group_id>/", include(review_group_router.urls)),
|
|
237
|
+
path("type/<int:type_id>/", include(compliance_type_router.urls)),
|
|
238
|
+
]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from .compliance_form import (
|
|
2
|
+
CFComplianceFormSignatureModelViewSet,
|
|
3
|
+
ComplianceFormModelViewSet,
|
|
4
|
+
ComplianceFormRepresentationViewSet,
|
|
5
|
+
ComplianceFormRuleViewSet,
|
|
6
|
+
ComplianceFormSectionComplianceFormViewSet,
|
|
7
|
+
ComplianceFormSectionRepresentationViewSet,
|
|
8
|
+
ComplianceFormSectionRuleViewSet,
|
|
9
|
+
ComplianceFormSectionViewSet,
|
|
10
|
+
ComplianceFormSignatureModelViewSet,
|
|
11
|
+
ComplianceFormSignatureSectionRepresentationViewSet,
|
|
12
|
+
ComplianceFormSignatureSectionRuleViewSet,
|
|
13
|
+
ComplianceFormTypeRepresentationViewSet,
|
|
14
|
+
ComplianceFormTypeViewSet,
|
|
15
|
+
)
|
|
16
|
+
from .compliance_task import (
|
|
17
|
+
ComplianceActionModelViewSet,
|
|
18
|
+
ComplianceEventModelViewSet,
|
|
19
|
+
ComplianceTaskComplianceTaskGroupModelViewSet,
|
|
20
|
+
ComplianceTaskGroupModelViewSet,
|
|
21
|
+
ComplianceTaskGroupRepresentationViewSet,
|
|
22
|
+
ComplianceTaskInstanceComplianceTaskModelViewSet,
|
|
23
|
+
ComplianceTaskInstanceModelViewSet,
|
|
24
|
+
ComplianceTaskInstanceReviewGroupModelViewSet,
|
|
25
|
+
ComplianceTaskInstanceReviewNoGroupModelViewSet,
|
|
26
|
+
ComplianceTaskMatrixPandasViewSet,
|
|
27
|
+
ComplianceTaskModelViewSet,
|
|
28
|
+
ComplianceTaskRepresentationViewSet,
|
|
29
|
+
ComplianceTaskReviewGroupModelViewSet,
|
|
30
|
+
ComplianceTaskReviewNoGroupModelViewSet,
|
|
31
|
+
ReviewComplianceTaskModelViewSet,
|
|
32
|
+
ReviewComplianceTaskRepresentationViewSet,
|
|
33
|
+
TypeComplianceActionModelViewSet,
|
|
34
|
+
TypeComplianceEventModelViewSet,
|
|
35
|
+
)
|
|
36
|
+
from .compliance_type import (
|
|
37
|
+
ComplianceTypeModelViewSet,
|
|
38
|
+
ComplianceTypeRepresentationViewSet,
|
|
39
|
+
)
|
|
40
|
+
from .risk_management import *
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
from django.utils.translation import gettext as _
|
|
2
|
+
from wbcompliance.serializers import ComplianceFormSignatureModelSerializer
|
|
3
|
+
from wbcore import serializers as wb_serializers
|
|
4
|
+
from wbcore.contrib.icons import WBIcon
|
|
5
|
+
from wbcore.enums import RequestType
|
|
6
|
+
from wbcore.metadata.configs import buttons as bt
|
|
7
|
+
from wbcore.metadata.configs.buttons.view_config import ButtonViewConfig
|
|
8
|
+
from wbcore.metadata.configs.display.instance_display.shortcuts import (
|
|
9
|
+
create_simple_display,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class AbstractComplianceDocumentButtonConfig:
|
|
14
|
+
@classmethod
|
|
15
|
+
def _get_compliance_document_button(cls) -> bt.ActionButton:
|
|
16
|
+
class ComplianceDocumentSerializer(wb_serializers.Serializer):
|
|
17
|
+
send_email = wb_serializers.BooleanField(default=False, label=_("Email me the document"))
|
|
18
|
+
|
|
19
|
+
return bt.ActionButton(
|
|
20
|
+
method=RequestType.PATCH,
|
|
21
|
+
key="regenerate_document",
|
|
22
|
+
action_label=_("Regenerate Document"),
|
|
23
|
+
title=_("Regenerate Document"),
|
|
24
|
+
label=_("Regenerate Document"),
|
|
25
|
+
icon=WBIcon.DOCUMENT.icon,
|
|
26
|
+
serializer=ComplianceDocumentSerializer,
|
|
27
|
+
instance_display=create_simple_display([["send_email"]]),
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# COMPLIANCE FORM
|
|
32
|
+
class ComplianceFormButtonConfig(ButtonViewConfig):
|
|
33
|
+
CUSTOM_INSTANCE_BUTTONS = CUSTOM_LIST_INSTANCE_BUTTONS = {
|
|
34
|
+
bt.ActionButton(
|
|
35
|
+
method=RequestType.PATCH,
|
|
36
|
+
identifiers=("wbcompliance:compliance_form",),
|
|
37
|
+
key="send_compliance_form_notification",
|
|
38
|
+
action_label=_("Send signature reminder notification"),
|
|
39
|
+
title=_("Send signature reminder notification"),
|
|
40
|
+
label=_("Send signature reminder notification"),
|
|
41
|
+
icon=WBIcon.FEEDBACK.icon,
|
|
42
|
+
description_fields=_(
|
|
43
|
+
"""<p> <b>{{_form_type.name}} :</b> {{title}}</p>
|
|
44
|
+
<p>Do you want to send a Compliance Form reminder notification ? </p>"""
|
|
45
|
+
),
|
|
46
|
+
confirm_config=bt.ButtonConfig(label=_("Confirm")),
|
|
47
|
+
cancel_config=bt.ButtonConfig(label=_("Cancel")),
|
|
48
|
+
),
|
|
49
|
+
bt.WidgetButton(key="signatures", label=_("List all signatures"), icon=WBIcon.VIEW.icon),
|
|
50
|
+
AbstractComplianceDocumentButtonConfig._get_compliance_document_button(),
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# COMPLIANCE FORM SIGNATURE
|
|
55
|
+
class ComplianceFormSignatureButtonConfig(ButtonViewConfig):
|
|
56
|
+
CUSTOM_INSTANCE_BUTTONS = CUSTOM_LIST_INSTANCE_BUTTONS = {
|
|
57
|
+
bt.ActionButton(
|
|
58
|
+
method=RequestType.PATCH,
|
|
59
|
+
identifiers=("wbcompliance:complianceformsignature",),
|
|
60
|
+
key="signature",
|
|
61
|
+
action_label=_("Signature"),
|
|
62
|
+
title=_("Signature Compliance Form"),
|
|
63
|
+
label=_("Signature"),
|
|
64
|
+
icon=WBIcon.CONFIRM.icon,
|
|
65
|
+
description_fields=_(
|
|
66
|
+
"""
|
|
67
|
+
<p> <b>{{_compliance_form.form_type}} : <span>{{_compliance_form.title}}</span></b></p>
|
|
68
|
+
<p>Version : {{version}}</p> <p><br/><br/>Do you want to sign <b>{{_compliance_form.title}}</b> ? </p>
|
|
69
|
+
<p><span style='color:red'>This action is not reversible</span></p>
|
|
70
|
+
"""
|
|
71
|
+
),
|
|
72
|
+
serializer=ComplianceFormSignatureModelSerializer,
|
|
73
|
+
confirm_config=bt.ButtonConfig(label=_("Confirm")),
|
|
74
|
+
cancel_config=bt.ButtonConfig(label=_("Cancel")),
|
|
75
|
+
instance_display=create_simple_display([["remark"]]),
|
|
76
|
+
),
|
|
77
|
+
AbstractComplianceDocumentButtonConfig._get_compliance_document_button(),
|
|
78
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
from django.apps import apps
|
|
2
|
+
from django.contrib.contenttypes.models import ContentType
|
|
3
|
+
from django.db.models import Q
|
|
4
|
+
from django.utils.translation import gettext as _
|
|
5
|
+
from rest_framework.reverse import reverse
|
|
6
|
+
from wbcompliance.models import ComplianceType, ReviewComplianceTask
|
|
7
|
+
from wbcompliance.viewsets.buttons.compliance_form import (
|
|
8
|
+
AbstractComplianceDocumentButtonConfig,
|
|
9
|
+
)
|
|
10
|
+
from wbcore import serializers as wb_serializers
|
|
11
|
+
from wbcore.contrib.icons import WBIcon
|
|
12
|
+
from wbcore.enums import RequestType
|
|
13
|
+
from wbcore.metadata.configs import buttons as bt
|
|
14
|
+
from wbcore.metadata.configs.buttons.view_config import ButtonViewConfig
|
|
15
|
+
from wbcore.metadata.configs.display.instance_display.shortcuts import (
|
|
16
|
+
create_simple_display,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def get_custom_report(_request, review: ReviewComplianceTask):
|
|
21
|
+
try:
|
|
22
|
+
content_type = ContentType.objects.get(app_label="wbcompliance", model="reviewcompliancetask")
|
|
23
|
+
ReportVersion = apps.get_model("wbreport", "ReportVersion")
|
|
24
|
+
BUTTTONS = []
|
|
25
|
+
versions = ReportVersion.objects.filter(
|
|
26
|
+
version_date=review.to_date, report__content_type=content_type, report__is_active=True
|
|
27
|
+
).filter(Q(parameters__type=review.type.name) | Q(parameters__type=review.type.id))
|
|
28
|
+
for version in versions:
|
|
29
|
+
BUTTTONS.append(
|
|
30
|
+
bt.HyperlinkButton(
|
|
31
|
+
endpoint=reverse("report:reportversion-html", args=[version.id], request=_request),
|
|
32
|
+
label=_("Show {}").format(version.title),
|
|
33
|
+
icon=WBIcon.DOCUMENT.icon,
|
|
34
|
+
)
|
|
35
|
+
)
|
|
36
|
+
if not version.lock:
|
|
37
|
+
BUTTTONS.append(
|
|
38
|
+
bt.ActionButton(
|
|
39
|
+
method=RequestType.GET,
|
|
40
|
+
identifiers=("wbreport:reportversion",),
|
|
41
|
+
endpoint=reverse("wbreport:reportversion-updatecontext", args=[version.id], request=_request),
|
|
42
|
+
label=_("Update {}").format(version.title),
|
|
43
|
+
description_fields=_(
|
|
44
|
+
"""
|
|
45
|
+
<p>Update and actualize context</p>
|
|
46
|
+
"""
|
|
47
|
+
),
|
|
48
|
+
icon=WBIcon.REGENERATE.icon,
|
|
49
|
+
action_label=_("Update Context {}").format(version.title),
|
|
50
|
+
title=_("Update {}").format(version.title),
|
|
51
|
+
),
|
|
52
|
+
)
|
|
53
|
+
if BUTTTONS:
|
|
54
|
+
return {
|
|
55
|
+
bt.DropDownButton(
|
|
56
|
+
label=_("Report"),
|
|
57
|
+
icon=WBIcon.UNFOLD.icon,
|
|
58
|
+
buttons=tuple(BUTTTONS),
|
|
59
|
+
),
|
|
60
|
+
}
|
|
61
|
+
except LookupError:
|
|
62
|
+
pass
|
|
63
|
+
|
|
64
|
+
return set()
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class ComplianceTaskButtonConfig(ButtonViewConfig):
|
|
68
|
+
def get_custom_instance_buttons(self):
|
|
69
|
+
class OccuredSerializer(wb_serializers.Serializer):
|
|
70
|
+
occured = wb_serializers.DateField(required=True)
|
|
71
|
+
|
|
72
|
+
BUTTONS = []
|
|
73
|
+
if self.view.kwargs.get("pk", None) and self.request.user.is_superuser:
|
|
74
|
+
review = self.view.get_object()
|
|
75
|
+
if review.active:
|
|
76
|
+
BUTTONS += [
|
|
77
|
+
bt.ActionButton(
|
|
78
|
+
method=RequestType.PATCH,
|
|
79
|
+
identifiers=("wbcompliance:compliancetask",),
|
|
80
|
+
key="generateinstance",
|
|
81
|
+
action_label=_("Generate Instance"),
|
|
82
|
+
title=_("Generate Instance "),
|
|
83
|
+
label=_("Generate Instance"),
|
|
84
|
+
icon=WBIcon.ADD.icon,
|
|
85
|
+
serializer=OccuredSerializer,
|
|
86
|
+
instance_display=create_simple_display([["occured"]]),
|
|
87
|
+
)
|
|
88
|
+
]
|
|
89
|
+
return {*BUTTONS}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class ReviewComplianceTaskButtonConfig(ButtonViewConfig):
|
|
93
|
+
def get_custom_instance_buttons(self):
|
|
94
|
+
class LinkedTypeSerializer(wb_serializers.Serializer):
|
|
95
|
+
type = wb_serializers.ChoiceField(
|
|
96
|
+
required=True, choices=ComplianceType.objects.all().values_list("name", flat=True)
|
|
97
|
+
)
|
|
98
|
+
operation = wb_serializers.ChoiceField(
|
|
99
|
+
choices=[("ADD", "Add existing indicators"), ("REMOVE", "Remove existing Indicators")],
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
BUTTONS = []
|
|
103
|
+
if self.view.kwargs.get("pk", None) and self.request.user.has_perm("wbcompliance.administrate_compliance"):
|
|
104
|
+
review = self.view.get_object()
|
|
105
|
+
if review.is_instance:
|
|
106
|
+
BUTTONS = get_custom_report(_request=self.request, review=review)
|
|
107
|
+
else:
|
|
108
|
+
if review.status == ReviewComplianceTask.Status.VALIDATED:
|
|
109
|
+
BUTTONS += [AbstractComplianceDocumentButtonConfig._get_compliance_document_button()]
|
|
110
|
+
|
|
111
|
+
if self.request.user.has_perm("wbcompliance.administrate_compliance"):
|
|
112
|
+
BUTTONS += [
|
|
113
|
+
bt.ActionButton(
|
|
114
|
+
method=RequestType.PATCH,
|
|
115
|
+
identifiers=("wbcompliance:reviewcompliancetask",),
|
|
116
|
+
key="generate_instance",
|
|
117
|
+
action_label="Generate Instance Report Indicator",
|
|
118
|
+
title="Generate Instance Report Indicator",
|
|
119
|
+
label="Generate Instance Report Indicator",
|
|
120
|
+
icon=WBIcon.ADD.icon,
|
|
121
|
+
confirm_config=bt.ButtonConfig(label=_("Confirm")),
|
|
122
|
+
cancel_config=bt.ButtonConfig(label=_("Cancel")),
|
|
123
|
+
),
|
|
124
|
+
]
|
|
125
|
+
|
|
126
|
+
if review.status == ReviewComplianceTask.Status.DRAFT and self.request.user.is_superuser:
|
|
127
|
+
BUTTONS += [
|
|
128
|
+
bt.ActionButton(
|
|
129
|
+
method=RequestType.PATCH,
|
|
130
|
+
identifiers=("wbcompliance:reviewcompliancetask",),
|
|
131
|
+
key="link_tasks",
|
|
132
|
+
action_label=_("Add/Remove Indicators of a Type"),
|
|
133
|
+
title=_("Add/Remove existing indicators"),
|
|
134
|
+
label=_("Add/Remove existing indicators"),
|
|
135
|
+
icon=WBIcon.LINK.icon,
|
|
136
|
+
description_fields=_(
|
|
137
|
+
"""
|
|
138
|
+
<p> <b>Indicators Report : <span>{{title}} </span></b><br/><br/>
|
|
139
|
+
Linking Indicators of type
|
|
140
|
+
"""
|
|
141
|
+
),
|
|
142
|
+
serializer=LinkedTypeSerializer,
|
|
143
|
+
instance_display=create_simple_display([["type"], ["operation"]]),
|
|
144
|
+
confirm_config=bt.ButtonConfig(label=_("Confirm")),
|
|
145
|
+
cancel_config=bt.ButtonConfig(label=_("Cancel")),
|
|
146
|
+
),
|
|
147
|
+
]
|
|
148
|
+
|
|
149
|
+
return {*BUTTONS}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from django.utils.translation import gettext as _
|
|
2
|
+
from wbcore.contrib.icons import WBIcon
|
|
3
|
+
from wbcore.metadata.configs import buttons as bt
|
|
4
|
+
from wbcore.metadata.configs.buttons.view_config import ButtonViewConfig
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class RiskCheckButtonConfig(ButtonViewConfig):
|
|
8
|
+
def get_custom_list_instance_buttons(self):
|
|
9
|
+
return {
|
|
10
|
+
bt.WidgetButton(key="incidents", label=_("Incidents"), icon=WBIcon.WARNING.icon),
|
|
11
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from django.utils.translation import gettext as _
|
|
2
|
+
from rest_framework.reverse import reverse
|
|
3
|
+
from wbcompliance.models.risk_management import RiskIncident
|
|
4
|
+
from wbcore import serializers as wb_serializers
|
|
5
|
+
from wbcore.enums import RequestType
|
|
6
|
+
from wbcore.metadata.configs import buttons as bt
|
|
7
|
+
from wbcore.metadata.configs.buttons.view_config import ButtonViewConfig
|
|
8
|
+
from wbcore.metadata.configs.display.instance_display.shortcuts import (
|
|
9
|
+
create_simple_display,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class RiskIncidentButtonConfig(ButtonViewConfig):
|
|
14
|
+
def get_custom_buttons(self):
|
|
15
|
+
if not self.view.kwargs.get("pk", None) and RiskIncident.can_manage(self.request.user):
|
|
16
|
+
|
|
17
|
+
class RiskRuleTypeSerializer(wb_serializers.Serializer):
|
|
18
|
+
resolve_status = wb_serializers.ChoiceField(
|
|
19
|
+
label=_("Rule Type"),
|
|
20
|
+
choices=[
|
|
21
|
+
(RiskIncident.Status.RESOLVED.name, RiskIncident.Status.RESOLVED.label),
|
|
22
|
+
(RiskIncident.Status.IGNORED.name, RiskIncident.Status.IGNORED.label),
|
|
23
|
+
],
|
|
24
|
+
default=RiskIncident.Status.RESOLVED,
|
|
25
|
+
)
|
|
26
|
+
comment = wb_serializers.TextField(default="", label=_("Comment"))
|
|
27
|
+
|
|
28
|
+
endpoint = reverse("wbcompliance:riskincident-resolveallincidents", args=[], request=self.request)
|
|
29
|
+
queryset = RiskIncident.objects.all()
|
|
30
|
+
if rule_id := self.view.kwargs.get("rule_id", None):
|
|
31
|
+
queryset = queryset.filter(rule=rule_id)
|
|
32
|
+
endpoint += f"?rule_id={rule_id}"
|
|
33
|
+
return {
|
|
34
|
+
bt.ActionButton(
|
|
35
|
+
method=RequestType.PATCH,
|
|
36
|
+
identifiers=("wbcompliance:riskincident",),
|
|
37
|
+
endpoint=endpoint,
|
|
38
|
+
label=_("Resolve all open Incident"),
|
|
39
|
+
description_fields=_(
|
|
40
|
+
"<p>Are you sure you want to close the current <b>{}</b> opened incidents?</p>"
|
|
41
|
+
).format(queryset.count()),
|
|
42
|
+
serializer=RiskRuleTypeSerializer,
|
|
43
|
+
action_label=_("resolveallincidents"),
|
|
44
|
+
title=_("Resolve all open Incident"),
|
|
45
|
+
instance_display=create_simple_display([["resolve_status"], ["comment"]]),
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
return set()
|
|
49
|
+
|
|
50
|
+
def get_custom_list_instance_buttons(self):
|
|
51
|
+
return set()
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from django.utils.translation import gettext as _
|
|
2
|
+
from wbcore import serializers as wb_serializers
|
|
3
|
+
from wbcore.contrib.icons import WBIcon
|
|
4
|
+
from wbcore.enums import RequestType
|
|
5
|
+
from wbcore.metadata.configs import buttons as bt
|
|
6
|
+
from wbcore.metadata.configs.buttons.view_config import ButtonViewConfig
|
|
7
|
+
from wbcore.metadata.configs.display.instance_display.shortcuts import (
|
|
8
|
+
create_simple_display,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class RiskRuleButtonConfig(ButtonViewConfig):
|
|
13
|
+
def get_custom_instance_buttons(self):
|
|
14
|
+
class CheckSerializer(wb_serializers.Serializer):
|
|
15
|
+
start = wb_serializers.DateField(label=_("Start"))
|
|
16
|
+
end = wb_serializers.DateField(label=_("End"))
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
bt.ActionButton(
|
|
20
|
+
method=RequestType.PATCH,
|
|
21
|
+
identifiers=("risk_management:riskcheck",),
|
|
22
|
+
key="recheck",
|
|
23
|
+
label=_("Recheck Rules"),
|
|
24
|
+
icon=WBIcon.REGENERATE.icon,
|
|
25
|
+
description_fields=_(
|
|
26
|
+
"""
|
|
27
|
+
<p>Recheck all the rules between a certain interval</p>
|
|
28
|
+
"""
|
|
29
|
+
),
|
|
30
|
+
serializer=CheckSerializer,
|
|
31
|
+
action_label=_("recheck"),
|
|
32
|
+
title=_("Recheck Rules"),
|
|
33
|
+
instance_display=create_simple_display([["start"], ["end"]]),
|
|
34
|
+
)
|
|
35
|
+
}
|