From f7fc18c5267d745ab754be0039967f53468a3665 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 18 Jan 2024 11:36:19 +0100 Subject: ✨ GDPR: manage merge action, admin consultation, edition, delete, ✅ GDPR tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/utils.py | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'ishtar_common/utils.py') diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 35289145c..0a6926d9d 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -508,8 +508,6 @@ class OwnPerms: return q - - def update_data(data, new_data, merge=False): """ Update a data directory taking account of key detail @@ -620,11 +618,11 @@ class MultiValueDict(BaseMultiValueDict): return lst -def is_downloadable(url): +def is_downloadable(curl): """ Does the url contain a downloadable resource """ - h = requests.head(url, allow_redirects=True) + h = requests.head(curl, allow_redirects=True) header = h.headers content_type = header.get("content-type") if "text" in content_type.lower(): @@ -736,6 +734,35 @@ def deserialize_args_for_tasks(sender, kwargs, extra_kwargs=None): return sender, instance +def get_person_gdpr_log(view_name, request, data_type, queryset, slice_query=None): + if not settings.GDPR_LOGGING: + return + if view_name == "get_item": + activity = "DE" if data_type == "csv" else "DC" + elif view_name == "show_item": + activity = "PV" if not data_type else "PE" + elif view_name in ("new_qa_item", "new_item"): + activity = "PC" + elif view_name in ("modify_qa_item", "modify_item"): + activity = "PM" + elif view_name == "delete_item": + activity = "PD" + elif view_name == "merge_person": + activity = "Pm" + elif view_name == "admin_person_consultation": + activity = "AC" + elif view_name == "admin_person_view": + activity = "AV" + elif view_name == "admin_person_modify": + activity = "AM" + elif view_name == "admin_person_delete": + activity = "AD" + else: + return + GDPRLog = apps.get_model("ishtar_common", "GDPRLog") + GDPRLog.create_log(request, activity, queryset, slice_query) + + EXTRA_KWARGS_TRIGGER = [ "_cascade_change", "_cached_labels_bulk_update", -- cgit v1.2.3