summaryrefslogtreecommitdiff
path: root/ishtar_common/utils.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2024-01-18 11:36:19 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2024-02-10 14:45:20 +0100
commit13cff2b11a06c9ed334c6bad96ce14a7e3d629d8 (patch)
tree97fa08bfda014a128ce7fe161695e8123b221cea /ishtar_common/utils.py
parent7293985b9d83bed4130a677521ef72d4759202c3 (diff)
downloadIshtar-13cff2b11a06c9ed334c6bad96ce14a7e3d629d8.tar.bz2
Ishtar-13cff2b11a06c9ed334c6bad96ce14a7e3d629d8.zip
✨ GDPR: manage merge action, admin consultation, edition, delete, ✅ GDPR tests
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r--ishtar_common/utils.py35
1 files changed, 31 insertions, 4 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py
index cf56ea705..3081d488c 100644
--- a/ishtar_common/utils.py
+++ b/ishtar_common/utils.py
@@ -507,8 +507,6 @@ class OwnPerms:
return q
-
-
def update_data(data, new_data, merge=False):
"""
Update a data directory taking account of key detail
@@ -619,11 +617,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():
@@ -735,6 +733,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",