|
|
|
|
@ -92,6 +92,7 @@ class DataApi(APIView): |
|
|
|
|
|
|
|
|
|
updates = defaultdict(dict) |
|
|
|
|
deletions = defaultdict(list) |
|
|
|
|
grants = defaultdict(dict) |
|
|
|
|
revocations = defaultdict(list) # New dictionary for revocations |
|
|
|
|
revocation_parents = defaultdict(dict) |
|
|
|
|
|
|
|
|
|
@ -113,10 +114,10 @@ class DataApi(APIView): |
|
|
|
|
serializer = serializer_class(instance) |
|
|
|
|
|
|
|
|
|
# data = get_serialized_data('tournaments', log.model_name, log.model_id) |
|
|
|
|
updates[log.model_name][log.model_id] = serializer.data |
|
|
|
|
grants[log.model_name][log.model_id] = serializer.data |
|
|
|
|
# instance = model.objects.get(id=log.model_id) |
|
|
|
|
self.add_children_recursively(instance, updates) |
|
|
|
|
self.add_parents_recursively(instance, updates) |
|
|
|
|
self.add_children_recursively(instance, grants) |
|
|
|
|
self.add_parents_recursively(instance, grants) |
|
|
|
|
elif log.operation == 'REVOKE_ACCESS': |
|
|
|
|
print(f'revoke access {log.model_id} - {log.store_id}') |
|
|
|
|
# Add to revocations instead of deletions |
|
|
|
|
@ -143,12 +144,16 @@ class DataApi(APIView): |
|
|
|
|
for model_name in deletions: |
|
|
|
|
deletions[model_name] = deletions[model_name] |
|
|
|
|
|
|
|
|
|
for model_name in grants: |
|
|
|
|
grants[model_name] = list(grants[model_name].values()) |
|
|
|
|
|
|
|
|
|
for model_name in revocation_parents: |
|
|
|
|
revocation_parents[model_name] = list(revocation_parents[model_name].values()) |
|
|
|
|
|
|
|
|
|
response_data = { |
|
|
|
|
"updates": dict(updates), |
|
|
|
|
"deletions": dict(deletions), |
|
|
|
|
"grants": dict(grants), |
|
|
|
|
"revocations": dict(revocations), |
|
|
|
|
"revocation_parents": dict(revocation_parents), |
|
|
|
|
"date": last_log_date |
|
|
|
|
|