Skip to content

Commit

Permalink
refac(audit/task): early return if no related_object_id
Browse files Browse the repository at this point in the history
  • Loading branch information
gagantrivedi committed Jul 27, 2023
1 parent f4e4105 commit 785026a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions api/audit/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,19 @@ def create_audit_log_from_historical_record(

environment, project = instance.get_environment_and_project()

related_object_id = instance.get_audit_log_related_object_id(history_instance)
related_object_type = instance.get_audit_log_related_object_type(history_instance)

if not related_object_id:
return

log_message = {
"+": instance.get_create_log_message,
"-": instance.get_delete_log_message,
"~": instance.get_update_log_message,
}[history_instance.history_type](history_instance)

related_object_id = instance.get_audit_log_related_object_id(history_instance)
related_object_type = instance.get_audit_log_related_object_type(history_instance)

if not (log_message and related_object_id):
if not log_message:
return

AuditLog.objects.create(
Expand Down

0 comments on commit 785026a

Please sign in to comment.