Skip to content

Commit

Permalink
🔊 - feat: log author and assignees when creating a destruction list
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvandescheur committed Jul 9, 2024
1 parent 13f644f commit a3bfbb5
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion backend/src/openarchiefbeheer/logging/logevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from timeline_logger.models import TimelineLog

from openarchiefbeheer.accounts.models import User
from openarchiefbeheer.destruction.constants import ListRole
from openarchiefbeheer.destruction.models import (
DestructionList,
DestructionListAssignee,
Expand All @@ -23,7 +24,30 @@ def _create_log(


def destruction_list_created(destruction_list: DestructionList, user: User) -> None:
_create_log(model=destruction_list, event="destruction_list_created", user=user)
_create_log(
model=destruction_list,
event="destruction_list_created",
user=user,
extra_data={
"pk": destruction_list.pk,
"name": destruction_list.name,
"author": {
"pk": destruction_list.author.pk,
"email": destruction_list.author.email,
"username": destruction_list.author.username,
},
"assignees": [
{
"user": {
"pk": assignee.user.pk,
"email": assignee.user.email,
"username": assignee.user.username,
},
}
for assignee in destruction_list.assignees.exclude(role=ListRole.author)
],
},
)


def destruction_list_updated(destruction_list: DestructionList) -> None:
Expand Down

0 comments on commit a3bfbb5

Please sign in to comment.