Skip to content

Commit

Permalink
✨ [#499] Add log for marking ready to review
Browse files Browse the repository at this point in the history
  • Loading branch information
SilviaAmAm committed Nov 25, 2024
1 parent d9ad329 commit 20360dc
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
47 changes: 46 additions & 1 deletion backend/src/openarchiefbeheer/logging/logevent.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import traceback

from django.db.models import Model
from django.db.models import Max, Min, Model

from timeline_logger.models import TimelineLog

Expand All @@ -12,6 +12,10 @@
DestructionListReview,
ReviewDecisionChoices,
)
from openarchiefbeheer.zaken.utils import (
format_resultaten_choices,
format_zaaktype_choices,
)


def _create_log(
Expand Down Expand Up @@ -53,6 +57,47 @@ def destruction_list_created(
)


def destruction_list_ready_for_first_review(
destruction_list: DestructionList, user: User
) -> None:

extra_data = {
"zaaktypen": format_zaaktype_choices(
destruction_list.items.distinct("zaak__zaaktype").values_list(
"zaak___expand__zaaktype", flat=True
)
),
"resultaten": format_resultaten_choices(
destruction_list.items.distinct("zaak__resultaat")
.values_list("zaak___expand__resultaat", flat=True)
.distinct()
),
"archiefnominaties": list(
destruction_list.items.distinct("zaak__archiefnominatie").values_list(
"zaak__archiefnominatie", flat=True
)
),
"comment": destruction_list.comment,
"number_of_zaken": destruction_list.items.count(),
}

items_max_min = destruction_list.items.aggregate(
Min("zaak__archiefactiedatum"), Max("zaak__archiefactiedatum")
)
if archiefactiedatum_min := items_max_min.get("zaak__archiefactiedatum__min"):
extra_data["min_archiefactiedatum"] = archiefactiedatum_min

if archiefactiedatum_max := items_max_min.get("zaak__archiefactiedatum__max"):
extra_data["max_archiefactiedatum"] = archiefactiedatum_max

_create_log(
model=destruction_list,
event="destruction_list_ready_for_first_review",
user=user,
extra_data=extra_data,
)


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 %}{% blocktranslate trimmed with list_name=log.content_object.name groups=log.extra_data.user_groups|join:", " record_manager=log.user comment=log.extra_data.comment count counter=log.extra_data.user_groups|length %}
User {{ record_manager }} (member of group {{ groups }}) has marked the destruction list "{{ list_name }}" as ready to review.{% plural %}User {{ record_manager }} (member of groups {{ groups }}) has marked the destruction list "{{ list_name }}" as ready to review.
{% endblocktranslate %}
11 changes: 11 additions & 0 deletions backend/src/openarchiefbeheer/zaken/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@ def format_selectielijstklasse_choice(resultaat: Resultaat) -> DropDownChoice:
}


def format_resultaten_choices(resultaten: list[dict]) -> DropDownChoice:
result = [
{
"value": resultaat["url"],
"label": resultaat.get("toelichting", resultaat["uuid"]),
}
for resultaat in resultaten
]
return result


@lru_cache
def retrieve_selectielijstklasse_choices(query_params: HashableDict | None) -> list:
config = APIConfig.get_solo()
Expand Down

0 comments on commit 20360dc

Please sign in to comment.