mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-05-21 13:51:52 +00:00
add actor email
This commit is contained in:
parent
447347710d
commit
d00e147068
3 changed files with 23 additions and 1 deletions
|
|
@ -23,7 +23,9 @@ def set_actor(actor, remote_addr=None):
|
|||
auditlog_value.set(context_data)
|
||||
|
||||
# Connect signal for automatic logging
|
||||
set_actor = partial(_set_actor, user=actor, signal_duid=context_data["signal_duid"])
|
||||
set_actor = partial(
|
||||
_set_actor, user=actor, signal_duid=context_data["signal_duid"],
|
||||
)
|
||||
pre_save.connect(
|
||||
set_actor,
|
||||
sender=LogEntry,
|
||||
|
|
@ -61,6 +63,7 @@ def _set_actor(user, sender, instance, signal_duid, **kwargs):
|
|||
and instance.actor is None
|
||||
):
|
||||
instance.actor = user
|
||||
instance.actor_email = user.email
|
||||
|
||||
instance.remote_addr = auditlog["remote_addr"]
|
||||
|
||||
|
|
|
|||
17
auditlog/migrations/0016_add_actor_email.py
Normal file
17
auditlog/migrations/0016_add_actor_email.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("auditlog", "0015_alter_logentry_changes"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="logentry",
|
||||
name="actor_email",
|
||||
field=models.CharField(
|
||||
null=True, verbose_name="actor email", blank=True, max_length=254,
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
@ -377,9 +377,11 @@ class LogEntry(models.Model):
|
|||
additional_data = models.JSONField(
|
||||
blank=True, null=True, verbose_name=_("additional data")
|
||||
)
|
||||
actor_email = models.CharField(blank=True, null=True, max_length=254)
|
||||
|
||||
objects = LogEntryManager()
|
||||
|
||||
|
||||
class Meta:
|
||||
get_latest_by = "timestamp"
|
||||
ordering = ["-timestamp"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue