From 5f829ceed9ef05a18286e843f941f4cfb09e73df Mon Sep 17 00:00:00 2001 From: Julian Roeland Date: Fri, 20 Dec 2024 12:12:45 +0100 Subject: [PATCH] :art: - refactor: formatting/sorting --- .../destruction/api/serializers.py | 37 ++++++++++----- .../openarchiefbeheer/destruction/models.py | 26 ++++++---- .../e2e/issues/test_568_correct_count.py | 47 +++++++++++++++---- 3 files changed, 81 insertions(+), 29 deletions(-) diff --git a/backend/src/openarchiefbeheer/destruction/api/serializers.py b/backend/src/openarchiefbeheer/destruction/api/serializers.py index 88ebcf5b..3ffc41c0 100644 --- a/backend/src/openarchiefbeheer/destruction/api/serializers.py +++ b/backend/src/openarchiefbeheer/destruction/api/serializers.py @@ -11,21 +11,32 @@ from openarchiefbeheer.zaken.api.filtersets import ZaakFilterSet from openarchiefbeheer.zaken.api.serializers import ZaakSerializer from openarchiefbeheer.zaken.models import Zaak -from openarchiefbeheer.zaken.utils import \ - retrieve_selectielijstklasse_resultaat +from openarchiefbeheer.zaken.utils import retrieve_selectielijstklasse_resultaat from requests.exceptions import HTTPError from rest_framework import serializers from rest_framework.exceptions import ValidationError from rest_framework.relations import SlugRelatedField from ..api.constants import MAX_NUMBER_CO_REVIEWERS -from ..constants import (DestructionListItemAction, InternalStatus, - ListItemStatus, ListRole, ListStatus, - ReviewDecisionChoices, ZaakActionType) -from ..models import (DestructionList, DestructionListAssignee, - DestructionListCoReview, DestructionListItem, - DestructionListItemReview, DestructionListReview, - ReviewItemResponse, ReviewResponse) +from ..constants import ( + DestructionListItemAction, + InternalStatus, + ListItemStatus, + ListRole, + ListStatus, + ReviewDecisionChoices, + ZaakActionType, +) +from ..models import ( + DestructionList, + DestructionListAssignee, + DestructionListCoReview, + DestructionListItem, + DestructionListItemReview, + DestructionListReview, + ReviewItemResponse, + ReviewResponse, +) from ..signals import co_reviewers_added from ..tasks import process_review_response @@ -416,7 +427,6 @@ class DestructionListReadSerializer(serializers.ModelSerializer): deletable_items_count = serializers.SerializerMethodField( help_text=_("Number of items to be deleted"), allow_null=True, - ) class Meta: @@ -434,14 +444,17 @@ class Meta: "created", "status_changed", "planned_destruction_date", - "deletable_items_count" + "deletable_items_count", ) def get_deletable_items_count(self, instance) -> int: - succeeded_count = instance.items.filter(processing_status=InternalStatus.succeeded).count() + succeeded_count = instance.items.filter( + processing_status=InternalStatus.succeeded + ).count() total_count = instance.items.all().count() return total_count - succeeded_count + class ZakenReviewSerializer(serializers.Serializer): zaak_url = serializers.URLField( required=True, help_text="The URL of the case for which changes are requested." diff --git a/backend/src/openarchiefbeheer/destruction/models.py b/backend/src/openarchiefbeheer/destruction/models.py index 92bd69f2..d8581993 100644 --- a/backend/src/openarchiefbeheer/destruction/models.py +++ b/backend/src/openarchiefbeheer/destruction/models.py @@ -14,16 +14,24 @@ from openarchiefbeheer.accounts.models import User from openarchiefbeheer.config.models import ArchiveConfig from openarchiefbeheer.utils.results_store import ResultStore -from openarchiefbeheer.zaken.utils import (delete_zaak_and_related_objects, - get_zaak_metadata) +from openarchiefbeheer.zaken.utils import ( + delete_zaak_and_related_objects, + get_zaak_metadata, +) from privates.fields import PrivateMediaFileField from slugify import slugify from timeline_logger.models import TimelineLog from .assignment_logic import STATE_MANAGER -from .constants import (DestructionListItemAction, InternalStatus, - ListItemStatus, ListRole, ListStatus, - ReviewDecisionChoices, ZaakActionType) +from .constants import ( + DestructionListItemAction, + InternalStatus, + ListItemStatus, + ListRole, + ListStatus, + ReviewDecisionChoices, + ZaakActionType, +) from .exceptions import ZaakArchiefactiedatumInFuture, ZaakNotFound from .managers import DestructionListManager @@ -234,9 +242,11 @@ def generate_destruction_report(self) -> None: self.save() def create_report_zaak(self) -> None: - from .utils import (attach_report_to_zaak, - create_eio_destruction_report, - create_zaak_for_report) + from .utils import ( + attach_report_to_zaak, + create_eio_destruction_report, + create_zaak_for_report, + ) if self.processing_status == InternalStatus.succeeded: return diff --git a/backend/src/openarchiefbeheer/destruction/tests/e2e/issues/test_568_correct_count.py b/backend/src/openarchiefbeheer/destruction/tests/e2e/issues/test_568_correct_count.py index eea0d3e8..6f5ec540 100644 --- a/backend/src/openarchiefbeheer/destruction/tests/e2e/issues/test_568_correct_count.py +++ b/backend/src/openarchiefbeheer/destruction/tests/e2e/issues/test_568_correct_count.py @@ -15,17 +15,46 @@ async def test_destruction_fails_with_incorrect_count(self): async with browser_page() as page: zaken = await self.given.zaken_are_indexed(amount=5) await self.given.record_manager_exists() - - destruction_list = await self.given.list_exists(name="Destruction list to check count for", status=ListStatus.ready_to_delete, processing_status=InternalStatus.failed, zaken=[]) - await self.given.list_item_exists(destruction_list=destruction_list, processing_status=InternalStatus.new, zaak=zaken[0]) - await self.given.list_item_exists(destruction_list=destruction_list, processing_status=InternalStatus.failed, zaak=zaken[1]) - await self.given.list_item_exists(destruction_list=destruction_list, processing_status=InternalStatus.processing, zaak=zaken[2]) - await self.given.list_item_exists(destruction_list=destruction_list, processing_status=InternalStatus.queued, zaak=zaken[3]) - await self.given.list_item_exists(destruction_list=destruction_list, processing_status=InternalStatus.succeeded, zaak=zaken[4]) + + destruction_list = await self.given.list_exists( + name="Destruction list to check count for", + status=ListStatus.ready_to_delete, + processing_status=InternalStatus.failed, + zaken=[], + ) + await self.given.list_item_exists( + destruction_list=destruction_list, + processing_status=InternalStatus.new, + zaak=zaken[0], + ) + await self.given.list_item_exists( + destruction_list=destruction_list, + processing_status=InternalStatus.failed, + zaak=zaken[1], + ) + await self.given.list_item_exists( + destruction_list=destruction_list, + processing_status=InternalStatus.processing, + zaak=zaken[2], + ) + await self.given.list_item_exists( + destruction_list=destruction_list, + processing_status=InternalStatus.queued, + zaak=zaken[3], + ) + await self.given.list_item_exists( + destruction_list=destruction_list, + processing_status=InternalStatus.succeeded, + zaak=zaken[4], + ) await self.when.record_manager_logs_in(page) await self.then.path_should_be(page, "/destruction-lists") - await self.when.user_clicks_button(page, "Destruction list to check count for") + await self.when.user_clicks_button( + page, "Destruction list to check count for" + ) await self.when.user_clicks_button(page, "Vernietigen herstarten") - await self.then.page_should_contain_text(page, "U staat op het punt om 4 zaken definitief te vernietigen") + await self.then.page_should_contain_text( + page, "U staat op het punt om 4 zaken definitief te vernietigen" + )