Skip to content

Commit

Permalink
🎨 - refactor: formatting/sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Roeland committed Dec 20, 2024
1 parent ec34130 commit 5f829ce
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 29 deletions.
37 changes: 25 additions & 12 deletions backend/src/openarchiefbeheer/destruction/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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."
Expand Down
26 changes: 18 additions & 8 deletions backend/src/openarchiefbeheer/destruction/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

0 comments on commit 5f829ce

Please sign in to comment.