ethyca-fides 2.63.1b4__py2.py3-none-any.whl → 2.63.2__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.
- {ethyca_fides-2.63.1b4.dist-info → ethyca_fides-2.63.2.dist-info}/METADATA +1 -1
- {ethyca_fides-2.63.1b4.dist-info → ethyca_fides-2.63.2.dist-info}/RECORD +110 -113
- fides/_version.py +3 -3
- fides/api/models/attachment.py +23 -36
- fides/api/models/detection_discovery/monitor_task.py +1 -0
- fides/api/service/privacy_request/dsr_package/dsr_report_builder.py +46 -264
- fides/api/service/privacy_request/dsr_package/templates/collection_index.html +9 -34
- fides/api/service/privacy_request/dsr_package/templates/item.html +37 -0
- fides/api/service/privacy_request/dsr_package/templates/main.css +2 -45
- fides/api/service/privacy_request/dsr_package/templates/welcome.html +8 -12
- fides/api/service/privacy_request/request_runner_service.py +139 -258
- fides/api/service/storage/gcs.py +3 -15
- fides/api/service/storage/s3.py +14 -28
- fides/api/service/storage/util.py +7 -45
- fides/api/tasks/storage.py +91 -85
- fides/ui-build/static/admin/404.html +1 -1
- fides/ui-build/static/admin/_next/static/{X2nvWLg2_-vsCTkhSWpzw → IrQqz_6ngcumU4YlWY9nL}/_buildManifest.js +1 -1
- fides/ui-build/static/admin/_next/static/chunks/pages/privacy-requests/configure/messaging-8cab04871908cfeb.js +1 -0
- fides/ui-build/static/admin/_next/static/chunks/pages/privacy-requests/configure/storage-150d40428245ee0c.js +1 -0
- fides/ui-build/static/admin/_next/static/chunks/pages/privacy-requests-20cdb2c8a03deae1.js +1 -0
- fides/ui-build/static/admin/add-systems/manual.html +1 -1
- fides/ui-build/static/admin/add-systems/multiple.html +1 -1
- fides/ui-build/static/admin/add-systems.html +1 -1
- fides/ui-build/static/admin/consent/configure/add-vendors.html +1 -1
- fides/ui-build/static/admin/consent/configure.html +1 -1
- fides/ui-build/static/admin/consent/privacy-experience/[id].html +1 -1
- fides/ui-build/static/admin/consent/privacy-experience/new.html +1 -1
- fides/ui-build/static/admin/consent/privacy-experience.html +1 -1
- fides/ui-build/static/admin/consent/privacy-notices/[id].html +1 -1
- fides/ui-build/static/admin/consent/privacy-notices/new.html +1 -1
- fides/ui-build/static/admin/consent/privacy-notices.html +1 -1
- fides/ui-build/static/admin/consent/properties.html +1 -1
- fides/ui-build/static/admin/consent/reporting.html +1 -1
- fides/ui-build/static/admin/consent.html +1 -1
- fides/ui-build/static/admin/data-catalog/[systemId]/projects/[projectUrn]/[resourceUrn].html +1 -1
- fides/ui-build/static/admin/data-catalog/[systemId]/projects/[projectUrn].html +1 -1
- fides/ui-build/static/admin/data-catalog/[systemId]/projects.html +1 -1
- fides/ui-build/static/admin/data-catalog/[systemId]/resources/[resourceUrn].html +1 -1
- fides/ui-build/static/admin/data-catalog/[systemId]/resources.html +1 -1
- fides/ui-build/static/admin/data-catalog.html +1 -1
- fides/ui-build/static/admin/data-discovery/action-center/[monitorId]/[systemId].html +1 -1
- fides/ui-build/static/admin/data-discovery/action-center/[monitorId].html +1 -1
- fides/ui-build/static/admin/data-discovery/action-center.html +1 -1
- fides/ui-build/static/admin/data-discovery/activity.html +1 -1
- fides/ui-build/static/admin/data-discovery/detection/[resourceUrn].html +1 -1
- fides/ui-build/static/admin/data-discovery/detection.html +1 -1
- fides/ui-build/static/admin/data-discovery/discovery/[resourceUrn].html +1 -1
- fides/ui-build/static/admin/data-discovery/discovery.html +1 -1
- fides/ui-build/static/admin/datamap.html +1 -1
- fides/ui-build/static/admin/dataset/[datasetId]/[collectionName]/[...subfieldNames].html +1 -1
- fides/ui-build/static/admin/dataset/[datasetId]/[collectionName].html +1 -1
- fides/ui-build/static/admin/dataset/[datasetId].html +1 -1
- fides/ui-build/static/admin/dataset/new.html +1 -1
- fides/ui-build/static/admin/dataset.html +1 -1
- fides/ui-build/static/admin/datastore-connection/[id].html +1 -1
- fides/ui-build/static/admin/datastore-connection/new.html +1 -1
- fides/ui-build/static/admin/datastore-connection.html +1 -1
- fides/ui-build/static/admin/index.html +1 -1
- fides/ui-build/static/admin/integrations/[id].html +1 -1
- fides/ui-build/static/admin/integrations.html +1 -1
- fides/ui-build/static/admin/lib/fides-ext-gpp.js +1 -1
- fides/ui-build/static/admin/lib/fides-headless.js +1 -1
- fides/ui-build/static/admin/lib/fides-preview.js +1 -1
- fides/ui-build/static/admin/lib/fides-tcf.js +2 -2
- fides/ui-build/static/admin/lib/fides.js +2 -2
- fides/ui-build/static/admin/login/[provider].html +1 -1
- fides/ui-build/static/admin/login.html +1 -1
- fides/ui-build/static/admin/messaging/[id].html +1 -1
- fides/ui-build/static/admin/messaging/add-template.html +1 -1
- fides/ui-build/static/admin/messaging.html +1 -1
- fides/ui-build/static/admin/poc/ant-components.html +1 -1
- fides/ui-build/static/admin/poc/form-experiments/AntForm.html +1 -1
- fides/ui-build/static/admin/poc/form-experiments/FormikAntFormItem.html +1 -1
- fides/ui-build/static/admin/poc/form-experiments/FormikControlled.html +1 -1
- fides/ui-build/static/admin/poc/form-experiments/FormikField.html +1 -1
- fides/ui-build/static/admin/poc/form-experiments/FormikSpreadField.html +1 -1
- fides/ui-build/static/admin/poc/forms.html +1 -1
- fides/ui-build/static/admin/poc/table-migration.html +1 -1
- fides/ui-build/static/admin/privacy-requests/[id].html +1 -1
- fides/ui-build/static/admin/privacy-requests/configure/messaging.html +1 -1
- fides/ui-build/static/admin/privacy-requests/configure/storage.html +1 -1
- fides/ui-build/static/admin/privacy-requests/configure.html +1 -1
- fides/ui-build/static/admin/privacy-requests.html +1 -1
- fides/ui-build/static/admin/properties/[id].html +1 -1
- fides/ui-build/static/admin/properties/add-property.html +1 -1
- fides/ui-build/static/admin/properties.html +1 -1
- fides/ui-build/static/admin/reporting/datamap.html +1 -1
- fides/ui-build/static/admin/settings/about/alpha.html +1 -1
- fides/ui-build/static/admin/settings/about.html +1 -1
- fides/ui-build/static/admin/settings/consent/[configuration_id]/[purpose_id].html +1 -1
- fides/ui-build/static/admin/settings/consent.html +1 -1
- fides/ui-build/static/admin/settings/custom-fields.html +1 -1
- fides/ui-build/static/admin/settings/domain-records.html +1 -1
- fides/ui-build/static/admin/settings/domains.html +1 -1
- fides/ui-build/static/admin/settings/email-templates.html +1 -1
- fides/ui-build/static/admin/settings/locations.html +1 -1
- fides/ui-build/static/admin/settings/organization.html +1 -1
- fides/ui-build/static/admin/settings/regulations.html +1 -1
- fides/ui-build/static/admin/systems/configure/[id]/test-datasets.html +1 -1
- fides/ui-build/static/admin/systems/configure/[id].html +1 -1
- fides/ui-build/static/admin/systems.html +1 -1
- fides/ui-build/static/admin/taxonomy.html +1 -1
- fides/ui-build/static/admin/user-management/new.html +1 -1
- fides/ui-build/static/admin/user-management/profile/[id].html +1 -1
- fides/ui-build/static/admin/user-management.html +1 -1
- fides/api/service/privacy_request/attachment_handling.py +0 -132
- fides/api/service/privacy_request/dsr_package/templates/attachments_index.html +0 -33
- fides/api/tasks/csv_utils.py +0 -170
- fides/api/tasks/encryption_utils.py +0 -42
- fides/ui-build/static/admin/_next/static/chunks/pages/privacy-requests/configure/messaging-c583a61302f02add.js +0 -1
- fides/ui-build/static/admin/_next/static/chunks/pages/privacy-requests/configure/storage-20d20a8d1736f7c4.js +0 -1
- fides/ui-build/static/admin/_next/static/chunks/pages/privacy-requests-0e557d79e1e43c2b.js +0 -1
- {ethyca_fides-2.63.1b4.dist-info → ethyca_fides-2.63.2.dist-info}/WHEEL +0 -0
- {ethyca_fides-2.63.1b4.dist-info → ethyca_fides-2.63.2.dist-info}/entry_points.txt +0 -0
- {ethyca_fides-2.63.1b4.dist-info → ethyca_fides-2.63.2.dist-info}/licenses/LICENSE +0 -0
- {ethyca_fides-2.63.1b4.dist-info → ethyca_fides-2.63.2.dist-info}/top_level.txt +0 -0
- /fides/ui-build/static/admin/_next/static/{X2nvWLg2_-vsCTkhSWpzw → IrQqz_6ngcumU4YlWY9nL}/_ssgManifest.js +0 -0
@@ -1,15 +1,13 @@
|
|
1
1
|
import json
|
2
2
|
import os
|
3
|
-
import time as time_module
|
4
3
|
import zipfile
|
5
4
|
from collections import defaultdict
|
6
5
|
from io import BytesIO
|
7
6
|
from pathlib import Path
|
8
|
-
from typing import Any, Optional
|
7
|
+
from typing import Any, Dict, List, Optional
|
9
8
|
|
10
9
|
import jinja2
|
11
10
|
from jinja2 import Environment, FileSystemLoader
|
12
|
-
from loguru import logger
|
13
11
|
|
14
12
|
from fides.api.models.privacy_request import PrivacyRequest
|
15
13
|
from fides.api.schemas.policy import ActionType
|
@@ -24,79 +22,54 @@ BORDER_COLOR = "#E2E8F0"
|
|
24
22
|
|
25
23
|
# pylint: disable=too-many-instance-attributes
|
26
24
|
class DsrReportBuilder:
|
27
|
-
"""
|
28
|
-
Manages populating HTML templates from the given data and adding the generated
|
29
|
-
pages to a zip file in a way that the pages can be navigated between.
|
30
|
-
|
31
|
-
The zip file is structured as follows:
|
32
|
-
- welcome.html: the main index page
|
33
|
-
- data/dataset_name/index.html: the index page for the dataset
|
34
|
-
- data/dataset_name/collection_name/index.html: the index page for the collection
|
35
|
-
- data/dataset_name/collection_name/item_index.html: the detail page for the item
|
36
|
-
- attachments/index.html: the index page for the attachments
|
37
|
-
|
38
|
-
Args:
|
39
|
-
privacy_request: the privacy request object
|
40
|
-
dsr_data: the DSR data
|
41
|
-
"""
|
42
|
-
|
43
25
|
def __init__(
|
44
26
|
self,
|
45
27
|
privacy_request: PrivacyRequest,
|
46
|
-
dsr_data:
|
28
|
+
dsr_data: Dict[str, Any],
|
47
29
|
):
|
48
30
|
"""
|
49
|
-
|
31
|
+
Manages populating HTML templates from the given data and adding the generated
|
32
|
+
pages to a zip file in a way that the pages can be navigated between.
|
50
33
|
"""
|
51
|
-
# Define pretty_print function for Jinja templates
|
52
|
-
jinja2.filters.FILTERS["pretty_print"] = lambda value, indent=4: json.dumps(
|
53
|
-
value, indent=indent, cls=StorageJSONEncoder
|
54
|
-
)
|
55
34
|
|
56
|
-
#
|
35
|
+
# zip file variables
|
57
36
|
self.baos = BytesIO()
|
58
37
|
|
59
38
|
# we close this in the finally block of generate()
|
60
39
|
# pylint: disable=consider-using-with
|
61
40
|
self.out = zipfile.ZipFile(self.baos, "w")
|
41
|
+
|
42
|
+
# Jinja template environment initialization
|
43
|
+
def pretty_print(value: str, indent: int = 4) -> str:
|
44
|
+
return json.dumps(
|
45
|
+
value, indent=indent, default=StorageJSONEncoder().default
|
46
|
+
)
|
47
|
+
|
48
|
+
jinja2.filters.FILTERS["pretty_print"] = pretty_print
|
62
49
|
self.template_loader = Environment(
|
63
50
|
loader=FileSystemLoader(DSR_DIRECTORY), autoescape=True
|
64
51
|
)
|
65
52
|
|
66
53
|
# to pass in custom colors in the future
|
67
|
-
self.template_data:
|
54
|
+
self.template_data: Dict[str, Any] = {
|
68
55
|
"text_color": TEXT_COLOR,
|
69
56
|
"header_color": HEADER_COLOR,
|
70
57
|
"border_color": BORDER_COLOR,
|
71
58
|
}
|
72
|
-
self.main_links:
|
59
|
+
self.main_links: Dict[str, Any] = {} # used to track the generated pages
|
73
60
|
|
74
61
|
# report data to populate the templates
|
75
62
|
self.request_data = _map_privacy_request(privacy_request)
|
76
63
|
self.dsr_data = dsr_data
|
77
64
|
|
78
|
-
# Track used filenames across all attachments
|
79
|
-
self.used_filenames: set[str] = set()
|
80
|
-
|
81
65
|
def _populate_template(
|
82
66
|
self,
|
83
67
|
template_path: str,
|
84
68
|
heading: Optional[str] = None,
|
85
69
|
description: Optional[str] = None,
|
86
|
-
data: Optional[
|
70
|
+
data: Optional[Dict[str, Any]] = None,
|
87
71
|
) -> str:
|
88
|
-
"""
|
89
|
-
Populates the template with the given data.
|
90
|
-
|
91
|
-
Args:
|
92
|
-
template_path: the path to the template to populate
|
93
|
-
heading: the heading to display on the template
|
94
|
-
description: the description to display on the template
|
95
|
-
data: the data to populate the template with
|
96
|
-
|
97
|
-
Returns:
|
98
|
-
The rendered template as a string.
|
99
|
-
"""
|
72
|
+
"""Generates a file from the template and data"""
|
100
73
|
report_data = {
|
101
74
|
"heading": heading,
|
102
75
|
"description": description,
|
@@ -109,24 +82,14 @@ class DsrReportBuilder:
|
|
109
82
|
return rendered_template
|
110
83
|
|
111
84
|
def _add_file(self, filename: str, contents: str) -> None:
|
112
|
-
"""
|
113
|
-
Adds a file to the zip file.
|
114
|
-
|
115
|
-
Args:
|
116
|
-
filename: the name of the file to add
|
117
|
-
contents: the contents of the file to add
|
118
|
-
"""
|
85
|
+
"""Helper to add a file to the zip archive"""
|
119
86
|
if filename and contents:
|
120
87
|
self.out.writestr(f"{filename}", contents.encode("utf-8"))
|
121
88
|
|
122
|
-
def _add_dataset(self, dataset_name: str, collections:
|
89
|
+
def _add_dataset(self, dataset_name: str, collections: Dict[str, Any]) -> None:
|
123
90
|
"""
|
124
91
|
Generates a page for each collection in the dataset and an index page for the dataset.
|
125
92
|
Tracks the generated links to build a root level index after each collection has been processed.
|
126
|
-
|
127
|
-
Args:
|
128
|
-
dataset_name: the name of the dataset to add
|
129
|
-
collections: the collections to add to the dataset
|
130
93
|
"""
|
131
94
|
# track links to collection indexes
|
132
95
|
collection_links = {}
|
@@ -146,203 +109,40 @@ class DsrReportBuilder:
|
|
146
109
|
),
|
147
110
|
)
|
148
111
|
|
149
|
-
def _get_unique_filename(self, filename: str) -> str:
|
150
|
-
"""
|
151
|
-
Generates a unique filename by appending a counter if the file already exists.
|
152
|
-
Now tracks filenames across all directories to ensure global uniqueness.
|
153
|
-
|
154
|
-
Args:
|
155
|
-
filename: The original filename
|
156
|
-
|
157
|
-
Returns:
|
158
|
-
A unique filename that won't conflict with existing files
|
159
|
-
"""
|
160
|
-
base_name, extension = os.path.splitext(filename)
|
161
|
-
counter = 1
|
162
|
-
unique_filename = filename
|
163
|
-
|
164
|
-
# Check if file exists in used_filenames set
|
165
|
-
while unique_filename in self.used_filenames:
|
166
|
-
unique_filename = f"{base_name}_{counter}{extension}"
|
167
|
-
counter += 1
|
168
|
-
|
169
|
-
# Add the new filename to the set
|
170
|
-
self.used_filenames.add(unique_filename)
|
171
|
-
return unique_filename
|
172
|
-
|
173
|
-
def _write_attachment_content(
|
174
|
-
self,
|
175
|
-
attachments: list[dict[str, Any]],
|
176
|
-
directory: str,
|
177
|
-
) -> dict[str, dict[str, str]]:
|
178
|
-
"""
|
179
|
-
Processes attachments and returns a dictionary mapping filenames to their download URLs and sizes.
|
180
|
-
|
181
|
-
Args:
|
182
|
-
attachments: The attachments to process
|
183
|
-
directory: The directory path (unused for presigned URLs)
|
184
|
-
|
185
|
-
Returns:
|
186
|
-
Dictionary mapping filenames to dictionaries containing url and size
|
187
|
-
"""
|
188
|
-
# First process all attachments into a list of tuples (filename, data)
|
189
|
-
processed_attachments = []
|
190
|
-
|
191
|
-
for attachment in attachments:
|
192
|
-
if not isinstance(attachment, dict):
|
193
|
-
continue
|
194
|
-
|
195
|
-
file_name = attachment.get("file_name")
|
196
|
-
if not file_name:
|
197
|
-
logger.warning("Skipping attachment with no file name")
|
198
|
-
continue
|
199
|
-
|
200
|
-
download_url = attachment.get("download_url")
|
201
|
-
if not download_url:
|
202
|
-
logger.warning("Skipping attachment with no download URL")
|
203
|
-
continue
|
204
|
-
|
205
|
-
file_size = attachment.get("file_size")
|
206
|
-
if isinstance(file_size, (int, float)):
|
207
|
-
file_size = self._format_size(float(file_size))
|
208
|
-
else:
|
209
|
-
file_size = "Unknown"
|
210
|
-
|
211
|
-
# Get a unique filename to prevent duplicates
|
212
|
-
unique_filename = self._get_unique_filename(file_name)
|
213
|
-
|
214
|
-
# Add to processed attachments
|
215
|
-
processed_attachments.append(
|
216
|
-
(unique_filename, {"url": download_url, "size": file_size})
|
217
|
-
)
|
218
|
-
|
219
|
-
# Convert list of tuples to dictionary
|
220
|
-
return dict(processed_attachments)
|
221
|
-
|
222
112
|
def _add_collection(
|
223
|
-
self, rows:
|
113
|
+
self, rows: List[Dict[str, Any]], dataset_name: str, collection_name: str
|
224
114
|
) -> None:
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
item_data = collection_item.copy()
|
238
|
-
|
239
|
-
# Process any attachments in the item
|
240
|
-
if "attachments" in item_data and isinstance(
|
241
|
-
item_data["attachments"], list
|
242
|
-
):
|
243
|
-
# Process attachments and get their URLs
|
244
|
-
attachment_links = self._write_attachment_content(
|
245
|
-
item_data["attachments"],
|
246
|
-
f"data/{dataset_name}/{collection_name}",
|
247
|
-
)
|
248
|
-
# Add the attachment URLs to the item data
|
249
|
-
item_data["attachments"] = attachment_links
|
250
|
-
|
251
|
-
# Add item content to the list
|
252
|
-
items_content.append(
|
253
|
-
{
|
254
|
-
"index": index,
|
255
|
-
"heading": f"{collection_name} (item #{index})",
|
256
|
-
"data": item_data,
|
257
|
-
}
|
115
|
+
# track links to detail pages
|
116
|
+
detail_links = {}
|
117
|
+
for index, item in enumerate(rows, 1):
|
118
|
+
detail_url = f"{index}.html"
|
119
|
+
self._add_file(
|
120
|
+
f"data/{dataset_name}/{collection_name}/{index}.html",
|
121
|
+
self._populate_template(
|
122
|
+
"templates/item.html",
|
123
|
+
f"{collection_name} (item #{index})",
|
124
|
+
None,
|
125
|
+
item,
|
126
|
+
),
|
258
127
|
)
|
128
|
+
detail_links[f"item #{index}"] = detail_url
|
259
129
|
|
260
|
-
#
|
130
|
+
# generate detail index page
|
261
131
|
self._add_file(
|
262
132
|
f"data/{dataset_name}/{collection_name}/index.html",
|
263
133
|
self._populate_template(
|
264
134
|
"templates/collection_index.html",
|
265
135
|
collection_name,
|
266
136
|
None,
|
267
|
-
|
268
|
-
),
|
269
|
-
)
|
270
|
-
|
271
|
-
def _add_attachments(self, attachments: list[dict[str, Any]]) -> None:
|
272
|
-
"""
|
273
|
-
Adds top-level attachments to the zip file.
|
274
|
-
|
275
|
-
Args:
|
276
|
-
attachments: the attachments to add
|
277
|
-
"""
|
278
|
-
if not attachments or not isinstance(attachments, list):
|
279
|
-
return
|
280
|
-
|
281
|
-
# Process attachments and get the links
|
282
|
-
attachment_links = self._write_attachment_content(attachments, "attachments")
|
283
|
-
|
284
|
-
# Generate attachments index page using the attachments index template
|
285
|
-
self._add_file(
|
286
|
-
"attachments/index.html",
|
287
|
-
self._populate_template(
|
288
|
-
"templates/attachments_index.html",
|
289
|
-
"Attachments",
|
290
|
-
"Files attached to this privacy request",
|
291
|
-
attachment_links,
|
137
|
+
detail_links,
|
292
138
|
),
|
293
139
|
)
|
294
140
|
|
295
|
-
def _get_datasets_from_dsr_data(self) -> dict[str, Any]:
|
296
|
-
"""
|
297
|
-
Returns the datasets from the DSR data.
|
298
|
-
"""
|
299
|
-
# pre-process data to split the dataset:collection keys
|
300
|
-
datasets: dict[str, Any] = defaultdict(lambda: defaultdict(list))
|
301
|
-
for key, rows in self.dsr_data.items():
|
302
|
-
|
303
|
-
# we handle attachments separately
|
304
|
-
if key == "attachments":
|
305
|
-
continue
|
306
|
-
|
307
|
-
parts = key.split(":", 1)
|
308
|
-
if len(parts) > 1:
|
309
|
-
dataset_name, collection_name = parts
|
310
|
-
else:
|
311
|
-
for row in rows:
|
312
|
-
if "system_name" in row:
|
313
|
-
dataset_name = row["system_name"]
|
314
|
-
collection_name = parts[0]
|
315
|
-
break
|
316
|
-
else:
|
317
|
-
dataset_name = "manual"
|
318
|
-
collection_name = parts[0]
|
319
|
-
|
320
|
-
datasets[dataset_name][collection_name].extend(rows)
|
321
|
-
|
322
|
-
return datasets
|
323
|
-
|
324
|
-
def _format_size(self, size_bytes: float) -> str:
|
325
|
-
"""
|
326
|
-
Format size in bytes to human readable format.
|
327
|
-
|
328
|
-
Args:
|
329
|
-
size_bytes: Size in bytes
|
330
|
-
|
331
|
-
Returns:
|
332
|
-
Formatted string with appropriate unit (B, KB, MB, GB)
|
333
|
-
"""
|
334
|
-
for unit in ["B", "KB", "MB", "GB"]:
|
335
|
-
if size_bytes < 1024.0:
|
336
|
-
return f"{size_bytes:.1f} {unit}"
|
337
|
-
size_bytes /= 1024.0
|
338
|
-
return f"{size_bytes:.1f} TB"
|
339
|
-
|
340
141
|
def generate(self) -> BytesIO:
|
341
142
|
"""
|
342
143
|
Processes the request and DSR data to build zip file containing the DSR report.
|
343
144
|
Returns the zip file as an in-memory byte array.
|
344
145
|
"""
|
345
|
-
start_time = time_module.time()
|
346
146
|
try:
|
347
147
|
# all the css for the pages is in main.css
|
348
148
|
self._add_file(
|
@@ -357,28 +157,18 @@ class DsrReportBuilder:
|
|
357
157
|
)
|
358
158
|
|
359
159
|
# pre-process data to split the dataset:collection keys
|
360
|
-
datasets:
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
160
|
+
datasets: Dict[str, Any] = defaultdict(lambda: defaultdict(list))
|
161
|
+
for key, rows in self.dsr_data.items():
|
162
|
+
parts = key.split(":", 1)
|
163
|
+
dataset_name, collection_name = (
|
164
|
+
parts if len(parts) > 1 else ("manual", parts[0])
|
165
|
+
)
|
166
|
+
datasets[dataset_name][collection_name].extend(rows)
|
366
167
|
|
367
|
-
|
368
|
-
|
369
|
-
self._add_dataset(dataset_name, datasets[dataset_name])
|
168
|
+
for dataset_name, collections in datasets.items():
|
169
|
+
self._add_dataset(dataset_name, collections)
|
370
170
|
self.main_links[dataset_name] = f"data/{dataset_name}/index.html"
|
371
171
|
|
372
|
-
# Add Additional Data if it exists
|
373
|
-
if "dataset" in datasets:
|
374
|
-
self._add_dataset("dataset", datasets["dataset"])
|
375
|
-
self.main_links["Additional Data"] = "data/dataset/index.html"
|
376
|
-
|
377
|
-
# Add Additional Attachments last if it exists
|
378
|
-
if "attachments" in self.dsr_data:
|
379
|
-
self._add_attachments(self.dsr_data["attachments"])
|
380
|
-
self.main_links["Additional Attachments"] = "attachments/index.html"
|
381
|
-
|
382
172
|
# create the main index once all the datasets have been added
|
383
173
|
self._add_file(
|
384
174
|
"welcome.html",
|
@@ -392,20 +182,12 @@ class DsrReportBuilder:
|
|
392
182
|
|
393
183
|
# reset the file pointer so the file can be fully read by the caller
|
394
184
|
self.baos.seek(0)
|
395
|
-
|
396
|
-
# Calculate time taken and file size
|
397
|
-
time_taken = time_module.time() - start_time
|
398
|
-
file_size = self._format_size(float(len(self.baos.getvalue())))
|
399
|
-
|
400
|
-
logger.bind(time_to_generate=time_taken, dsr_package_size=file_size).info(
|
401
|
-
"DSR report generation complete."
|
402
|
-
)
|
403
185
|
return self.baos
|
404
186
|
|
405
187
|
|
406
|
-
def _map_privacy_request(privacy_request: PrivacyRequest) ->
|
188
|
+
def _map_privacy_request(privacy_request: PrivacyRequest) -> Dict[str, Any]:
|
407
189
|
"""Creates a map with a subset of values from the privacy request"""
|
408
|
-
request_data:
|
190
|
+
request_data: Dict[str, Any] = {}
|
409
191
|
request_data["id"] = privacy_request.id
|
410
192
|
|
411
193
|
action_type: Optional[ActionType] = privacy_request.policy.get_action_type()
|
@@ -14,42 +14,17 @@
|
|
14
14
|
</a>
|
15
15
|
</div>
|
16
16
|
<h1>{{ heading }}</h1>
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
<div class="table">
|
21
|
-
<div class="table-row">
|
22
|
-
<div class="table-cell">Field</div>
|
23
|
-
<div class="table-cell">Value</div>
|
24
|
-
</div>
|
25
|
-
{% for field, value in item.data.items() %}
|
26
|
-
<div class="table-row">
|
27
|
-
<div class="table-cell">{{ field }}</div>
|
28
|
-
<div class="table-cell">
|
29
|
-
{% if field == "attachments" and value is mapping and value|length > 0 %}
|
30
|
-
<p class="expiration-notice">Note: All download links will expire in 7 days.</p>
|
31
|
-
<div class="table table-hover">
|
32
|
-
<div class="table-row">
|
33
|
-
<div class="table-cell" style="text-align: left;">File Name</div>
|
34
|
-
<div class="table-cell" style="text-align: left;">Size</div>
|
35
|
-
</div>
|
36
|
-
{% for attachment_name, attachment_info in value.items() %}
|
37
|
-
<a href="{{ attachment_info.url }}" class="table-row" target="_blank">
|
38
|
-
<div class="table-cell" style="text-align: left;">{{ attachment_name }}</div>
|
39
|
-
<div class="table-cell" style="text-align: left;">{{ attachment_info.size }}</div>
|
40
|
-
</a>
|
41
|
-
{% endfor %}
|
42
|
-
</div>
|
43
|
-
{% else %}
|
44
|
-
<pre>{{ value | pretty_print }}</pre>
|
45
|
-
{% endif %}
|
46
|
-
</div>
|
47
|
-
</div>
|
48
|
-
{% endfor %}
|
17
|
+
<div class="table table-hover">
|
18
|
+
<div class="table-row">
|
19
|
+
<div class="table-cell">Items</div>
|
49
20
|
</div>
|
21
|
+
{% for name, link in data.items() %}
|
22
|
+
<a href="{{ link }}" class="table-row">
|
23
|
+
<div class="table-cell">{{ name }}</div>
|
24
|
+
</a>
|
25
|
+
{% endfor %}
|
50
26
|
</div>
|
51
|
-
{% endfor %}
|
52
27
|
</div>
|
53
28
|
</div>
|
54
29
|
</body>
|
55
|
-
</html>
|
30
|
+
</html>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<html>
|
2
|
+
|
3
|
+
<head>
|
4
|
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600">
|
5
|
+
<link rel="stylesheet" href="../../main.css">
|
6
|
+
</head>
|
7
|
+
|
8
|
+
<body>
|
9
|
+
<div class="container">
|
10
|
+
<div class="header"></div>
|
11
|
+
<div class="content">
|
12
|
+
<div class="button-container">
|
13
|
+
<a href="index.html">
|
14
|
+
<div class="button"><img src="../../back.svg"></div>
|
15
|
+
<span>Back to list</span>
|
16
|
+
</a>
|
17
|
+
</div>
|
18
|
+
<h1>{{ heading }}</h1>
|
19
|
+
<div class="table">
|
20
|
+
<div class="table-row">
|
21
|
+
<div class="table-cell">Field</div>
|
22
|
+
<div class="table-cell">Value</div>
|
23
|
+
</div>
|
24
|
+
{% for field, value in data.items() %}
|
25
|
+
<div class="table-row">
|
26
|
+
<div class="table-cell">{{ field }}</div>
|
27
|
+
<div class="table-cell">
|
28
|
+
<pre>{{ value | pretty_print }}</pre>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
{% endfor %}
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
</body>
|
36
|
+
|
37
|
+
</html>
|
@@ -35,7 +35,7 @@ h1 {
|
|
35
35
|
margin-bottom: 24px;
|
36
36
|
width: 100%;
|
37
37
|
display: flex;
|
38
|
-
justify-content: center;
|
38
|
+
justify-content: center;
|
39
39
|
}
|
40
40
|
|
41
41
|
.header div {
|
@@ -176,47 +176,4 @@ h1 {
|
|
176
176
|
|
177
177
|
a {
|
178
178
|
text-decoration: none;
|
179
|
-
}
|
180
|
-
|
181
|
-
.attachment-link {
|
182
|
-
color: var(--text-color);
|
183
|
-
text-decoration: underline;
|
184
|
-
cursor: pointer;
|
185
|
-
}
|
186
|
-
|
187
|
-
.attachment-link:hover {
|
188
|
-
opacity: 0.8;
|
189
|
-
}
|
190
|
-
|
191
|
-
.dataset-list {
|
192
|
-
padding: 20px 0 100px;
|
193
|
-
}
|
194
|
-
|
195
|
-
.dataset-list h2 {
|
196
|
-
font-size: 16px;
|
197
|
-
font-weight: 600;
|
198
|
-
margin-bottom: 16px;
|
199
|
-
}
|
200
|
-
|
201
|
-
.dataset-item {
|
202
|
-
margin-bottom: 8px;
|
203
|
-
}
|
204
|
-
|
205
|
-
.dataset-link {
|
206
|
-
display: block;
|
207
|
-
color: var(--text-color);
|
208
|
-
text-decoration: none;
|
209
|
-
font-size: 14px;
|
210
|
-
line-height: 20px;
|
211
|
-
font-weight: 600;
|
212
|
-
background-color: var(--header-color);
|
213
|
-
padding: 16px;
|
214
|
-
border: 1px solid var(--border-color);
|
215
|
-
border-radius: 6px;
|
216
|
-
transition: opacity 0.2s ease;
|
217
|
-
}
|
218
|
-
|
219
|
-
.dataset-link:hover {
|
220
|
-
opacity: 0.8;
|
221
|
-
cursor: pointer;
|
222
|
-
}
|
179
|
+
}
|
@@ -45,22 +45,18 @@
|
|
45
45
|
<div id="requestedAt">{{ request.requested_at }}</div>
|
46
46
|
</div>
|
47
47
|
</div>
|
48
|
-
<div class="
|
49
|
-
<
|
50
|
-
|
51
|
-
information has been compiled from the following areas. Click on each section to open a file and view
|
52
|
-
your data in PDF format.
|
53
|
-
</p>
|
54
|
-
</div>
|
55
|
-
<div class="dataset-list">
|
56
|
-
{% for name, link in data.items() %}
|
57
|
-
<div class="dataset-item">
|
58
|
-
<a href="{{ link }}" class="dataset-link">{{ name }}</a>
|
48
|
+
<div class="table table-hover">
|
49
|
+
<div class="table-row">
|
50
|
+
<div class="table-cell">Dataset</div>
|
59
51
|
</div>
|
52
|
+
{% for name, link in data.items() %}
|
53
|
+
<a href="{{ link }}" class="table-row">
|
54
|
+
<div class="table-cell">{{ name }}</div>
|
55
|
+
</a>
|
60
56
|
{% endfor %}
|
61
57
|
</div>
|
62
58
|
</div>
|
63
59
|
</div>
|
64
60
|
</body>
|
65
61
|
|
66
|
-
</html>
|
62
|
+
</html>
|