Skip to content

Commit

Permalink
✨ [#499] Add logging for when the record manager processes the review
Browse files Browse the repository at this point in the history
  • Loading branch information
SilviaAmAm committed Nov 26, 2024
1 parent f27e90a commit a4c030e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 2 deletions.
4 changes: 4 additions & 0 deletions backend/src/openarchiefbeheer/destruction/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,10 @@ def create(self, validated_data: dict) -> ReviewResponse:
review_response = ReviewResponse.objects.create(**validated_data)
ReviewItemResponse.objects.bulk_create(items_responses)

logevent.destruction_list_review_response_created(
validated_data["review"].destruction_list, self.context["request"].user
)

process_review_response.delay(review_response.pk)

return review_response
Expand Down
8 changes: 6 additions & 2 deletions backend/src/openarchiefbeheer/destruction/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from celery import chain

from openarchiefbeheer.celery import app
from openarchiefbeheer.logging import logevent

from .constants import InternalStatus, ListItemStatus, ListStatus
from .exceptions import DeletionProcessingError
Expand Down Expand Up @@ -43,10 +44,13 @@ def process_review_response(pk: int) -> None:
item_response.save()
return

destruction_list = review_response.review.destruction_list
prepopulate_selection_after_review_response(
review_response.review.destruction_list, items_review_responses
destruction_list, items_review_responses
)
review_response.review.destruction_list.assign_next()
destruction_list.assign_next()

logevent.destruction_list_review_response_processed(destruction_list)


def delete_destruction_list(destruction_list: DestructionList) -> None:
Expand Down
25 changes: 25 additions & 0 deletions backend/src/openarchiefbeheer/logging/logevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from openarchiefbeheer.accounts.api.serializers import UserSerializer
from openarchiefbeheer.accounts.models import User
from openarchiefbeheer.destruction.constants import ListItemStatus
from openarchiefbeheer.destruction.models import (
DestructionList,
DestructionListAssignee,
Expand Down Expand Up @@ -99,6 +100,30 @@ def destruction_list_ready_for_first_review(
)


def destruction_list_review_response_created(
destruction_list: DestructionList, user: User
) -> None:
_create_log(
model=destruction_list,
event="destruction_list_review_response_created",
user=user,
)


def destruction_list_review_response_processed(
destruction_list: DestructionList,
) -> None:
_create_log(
model=destruction_list,
event="destruction_list_review_response_processed",
extra_data={
"number_of_zaken": destruction_list.items.filter(
status=ListItemStatus.suggested
).count(),
},
)


def destruction_list_updated(destruction_list: DestructionList, user: User) -> None:
_create_log(model=destruction_list, event="destruction_list_updated", user=user)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% load i18n %}{% with groups=log.extra_data.user_groups|join:", " %}{% blocktranslate trimmed with list_name=log.content_object.name groups=groups group_pluralized=group_pluralized author=log.user count counter=log.extra_data.user_groups|length %}
User {{ author }} (member of group {{ groups }}) has processed the feedback on destruction list "{{ list_name }}".{% plural %}User {{ author }} (member of groups {{ groups }}) has processed the feedback on destruction list "{{ list_name }}".
{% endblocktranslate %}{% endwith %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% load i18n %}{% blocktranslate trimmed with list_name=log.content_object.name %}
The review response of destruction list "{{ list_name }}" has been processed.
{% endblocktranslate %}
{% blocktranslate trimmed with number_of_zaken=log.extra_data.number_of_zaken count counter=log.extra_data.number_of_zaken %}
There is now one zaak on the list.{% plural %}There are now {{ number_of_zaken }} zaken on the list.
{% endblocktranslate %}

0 comments on commit a4c030e

Please sign in to comment.