Skip to content

Commit

Permalink
Create logEntry object if none exists
Browse files Browse the repository at this point in the history
  • Loading branch information
CaitBarnard committed Dec 6, 2024
1 parent a2d02fa commit deec657
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions core/utils/generic_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,6 @@ def check_empty(value):
return None


class EmptyLogObject:
def __init__(self, app_label="generic", model_name="empty", pk=None):
self.pk = str(pk)
self._meta = type(
"meta", (), {"app_label": app_label, "model_name": model_name}
)


def log_object_change(
requesting_user_id,
message,
Expand All @@ -107,9 +99,11 @@ def log_object_change(
queryset=[obj],
)
else:
LogEntry.objects.log_actions(
LogEntry.objects.create(
user_id=requesting_user_id,
content_type_id=None,
object_id=None,
object_repr="",
action_flag=CHANGE,
change_message=message,
queryset=[EmptyLogObject()],
)

0 comments on commit deec657

Please sign in to comment.