summaryrefslogtreecommitdiff
path: root/tests/admin_utils/models.py
diff options
context:
space:
mode:
authorAkash Kumar Sen <Akash-Kumar-Sen@users.noreply.github.com>2023-06-12 08:50:55 +0530
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-10-31 18:06:44 +0100
commit40b3975e7d3e1464a733c69171ad7d38f8814280 (patch)
treedabd02bf22c82b52556931bb7c633b28753f6ab0 /tests/admin_utils/models.py
parent45e0c5892f84b5bb47999cbe16eabb5a13293d85 (diff)
Fixed #34462 -- Made admin log actions in bulk.
This also deprecates ModelAdmin.log_deletion() and LogEntryManager.log_action().
Diffstat (limited to 'tests/admin_utils/models.py')
-rw-r--r--tests/admin_utils/models.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/admin_utils/models.py b/tests/admin_utils/models.py
index 243f314b03..8e812e27eb 100644
--- a/tests/admin_utils/models.py
+++ b/tests/admin_utils/models.py
@@ -1,4 +1,5 @@
from django.contrib import admin
+from django.contrib.admin.models import LogEntry, LogEntryManager
from django.db import models
from django.utils.translation import gettext_lazy as _
@@ -86,3 +87,26 @@ class VehicleMixin(Vehicle):
class Car(VehicleMixin):
pass
+
+
+class InheritedLogEntryManager(LogEntryManager):
+ model = LogEntry
+
+ def log_action(
+ self,
+ user_id,
+ content_type_id,
+ object_id,
+ object_repr,
+ action_flag,
+ change_message="",
+ ):
+ return LogEntry.objects.create(
+ user_id=user_id,
+ content_type_id=content_type_id,
+ object_id=str(object_id),
+ # Changing actual repr to test repr
+ object_repr="Test Repr",
+ action_flag=action_flag,
+ change_message=change_message,
+ )