Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add actor email #641

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion auditlog/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ 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,
Expand Down Expand Up @@ -61,6 +65,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"]

Expand Down
20 changes: 20 additions & 0 deletions auditlog/migrations/0016_add_actor_email.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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,
),
),
]
1 change: 1 addition & 0 deletions auditlog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ class Action:
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()

Expand Down