Skip to content

Commit f879475

Browse files
authoredSep 26, 2024··
Merge pull request #382 from maykinmedia/fix/377-fix-review-responses
[#377] Fix review responses
2 parents 1899acd + 3ec6429 commit f879475

File tree

13 files changed

+549
-232
lines changed

13 files changed

+549
-232
lines changed
 

‎backend/docs/developers/index.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ Content
1414

1515
e2e-tests
1616
gherkin-like-tests
17-
vcr-tests
17+
vcr-tests
18+
logic

‎backend/docs/developers/logic.rst

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.. _developers_logic:
2+
3+
4+
Processing a review
5+
===================
6+
7+
After a reviewer has reviewed a destruction list, the record manager needs to process the feedback.
8+
For each zaak that has been "rejected" by the reviewer, the record manager can:
9+
10+
- Keep the zaak in the destruction list (go against the suggestion of the reviewer). In this case, no details of the zaak can be updated.
11+
- Remove the zaak from the destruction list. When removing the zaak, the record manager should either:
12+
13+
- Update the selectielijstklasse of the zaak. This should automatically update the archiefactiedatum of the zaak (this is currently done by the frontend). This is for example desirable in the case that the zaak has the wrong selectielijstklasse by accident.
14+
- Update the archiefactiedatum of the zaak. In this case the selectielijstklasse is correct, but for whatever reason the zaak needs to be kept for longer.

‎backend/src/openarchiefbeheer/destruction/api/serializers.py

+44
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818
from openarchiefbeheer.zaken.models import Zaak
1919

2020
from ..constants import (
21+
DestructionListItemAction,
2122
InternalStatus,
2223
ListItemStatus,
2324
ListRole,
2425
ListStatus,
2526
ReviewDecisionChoices,
27+
ZaakActionType,
2628
)
2729
from ..models import (
2830
DestructionList,
@@ -502,11 +504,53 @@ class Meta:
502504
"pk",
503505
"review_item",
504506
"action_item",
507+
"action_zaak_type",
505508
"action_zaak",
506509
"created",
507510
"comment",
508511
)
509512

513+
def validate(self, attrs: dict) -> dict:
514+
action_zaak = attrs.get("action_zaak", {})
515+
if attrs["action_item"] == DestructionListItemAction.keep and action_zaak:
516+
raise ValidationError(
517+
{
518+
"action_zaak": _(
519+
"The case cannot be changed if it is kept in the destruction list."
520+
)
521+
}
522+
)
523+
524+
zaak_action_type = attrs.get("action_zaak_type")
525+
selectielijstklasse = action_zaak.get("selectielijstklasse")
526+
if (
527+
attrs["action_item"] == DestructionListItemAction.remove
528+
and zaak_action_type == ZaakActionType.bewaartermijn
529+
and selectielijstklasse
530+
):
531+
raise ValidationError(
532+
{
533+
"action_zaak_type": _(
534+
"The selectielijstklasse cannot be changed if the case action type is 'bewaartermijn'."
535+
)
536+
}
537+
)
538+
539+
if (
540+
attrs["action_item"] == DestructionListItemAction.remove
541+
and zaak_action_type == ZaakActionType.selectielijstklasse_and_bewaartermijn
542+
and not selectielijstklasse
543+
):
544+
raise ValidationError(
545+
{
546+
"selectielijstklasse": _(
547+
"The selectielijstklasse is required for action type is 'selectielijstklasse_and_bewaartermijn'."
548+
)
549+
}
550+
)
551+
552+
return attrs
553+
510554

511555
class ReviewResponseSerializer(serializers.ModelSerializer):
512556
items_responses = ReviewItemResponseSerializer(many=True)

‎backend/src/openarchiefbeheer/destruction/constants.py

+7
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ class DestructionListItemAction(models.TextChoices):
3333
remove = "remove", _("remove")
3434

3535

36+
class ZaakActionType(models.TextChoices):
37+
selectielijstklasse_and_bewaartermijn = "selectielijstklasse_and_bewaartermijn", _(
38+
"selectielijstklasse and bewaartermijn"
39+
)
40+
bewaartermijn = "bewaartermijn", _("bewaartermijn")
41+
42+
3643
class InternalStatus(models.TextChoices):
3744
new = "new", _("new")
3845
queued = "queued", _("queued")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Generated by Django 4.2.15 on 2024-09-23 13:12
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("destruction", "0021_destructionlist_planned_destruction_date"),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name="reviewitemresponse",
15+
name="action_zaak_type",
16+
field=models.CharField(
17+
blank=True,
18+
choices=[
19+
(
20+
"selectielijstklasse_and_bewaartermijn",
21+
"selectielijstklasse and bewaartermijn",
22+
),
23+
("bewaartermijn", "bewaartermijn"),
24+
],
25+
help_text="What type of change to do on the case. ",
26+
max_length=80,
27+
verbose_name="action zaak type",
28+
),
29+
),
30+
]

‎backend/src/openarchiefbeheer/destruction/models.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
ListRole,
2525
ListStatus,
2626
ReviewDecisionChoices,
27+
ZaakActionType,
2728
)
2829
from .exceptions import ZaakArchiefactiedatumInFuture, ZaakNotFound
2930

@@ -468,6 +469,13 @@ class ReviewItemResponse(models.Model):
468469
choices=DestructionListItemAction.choices,
469470
max_length=80,
470471
)
472+
action_zaak_type = models.CharField(
473+
_("action zaak type"),
474+
choices=ZaakActionType.choices,
475+
max_length=80,
476+
help_text=_("What type of change to do on the case. "),
477+
blank=True,
478+
)
471479
action_zaak = models.JSONField(
472480
_("action case"),
473481
blank=True,
@@ -501,7 +509,7 @@ class Meta:
501509
def __str__(self):
502510
return f"Response to {self.review_item}"
503511

504-
def process(self):
512+
def process(self) -> None:
505513
if self.processing_status == InternalStatus.succeeded:
506514
return
507515

@@ -514,7 +522,6 @@ def process(self):
514522
destruction_list_item.status = ListItemStatus.removed
515523
destruction_list_item.save()
516524

517-
if self.action_zaak:
518525
destruction_list_item.zaak.update_data(self.action_zaak)
519526

520527
self.processing_status = InternalStatus.succeeded

0 commit comments

Comments
 (0)
Please sign in to comment.