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 457d458
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion api/audit/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ 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,
Expand All @@ -93,7 +99,7 @@ def create_audit_log_from_historical_record(
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 457d458

Please sign in to comment.