Skip to content

Commit 64caacc

Browse files
committed
✨ [#318] Finish flow archivaris
1 parent f733956 commit 64caacc

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

backend/src/openarchiefbeheer/destruction/assignment_logic.py

+16-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from django.db.models import Count, Min
44

55
from .constants import ListRole, ListStatus, ReviewDecisionChoices
6+
from .exceptions import NoReviewFoundError
67

78
if TYPE_CHECKING:
89
from .models import DestructionList, DestructionListAssignee
@@ -73,11 +74,15 @@ def reassign(self, destruction_list: "DestructionList") -> None:
7374

7475
class ChangesRequested:
7576
def assign_next(self, destruction_list: "DestructionList") -> None:
76-
destruction_list.set_status(ListStatus.ready_to_review)
77-
78-
# The reviewer who rejected the list reviews first
7977
last_review = destruction_list.reviews.order_by("created").last()
80-
destruction_list.assign(destruction_list.get_assignee(last_review.author))
78+
last_reviewer = destruction_list.get_assignee(last_review.author)
79+
80+
if last_reviewer.role == ListRole.archivist:
81+
destruction_list.set_status(ListStatus.ready_for_archivist)
82+
else:
83+
destruction_list.set_status(ListStatus.ready_to_review)
84+
85+
destruction_list.assign(last_reviewer)
8186

8287
def reassign(self, destruction_list: "DestructionList") -> None:
8388
# When a list has requested changes, it is assigned to the author. No action needed.
@@ -103,11 +108,15 @@ def reassign(self, destruction_list: "DestructionList") -> None:
103108
class ReadyForArchivist:
104109
def assign_next(self, destruction_list: "DestructionList") -> None:
105110
last_review = destruction_list.reviews.order_by("created").last()
106-
if last_review and last_review.decision == ReviewDecisionChoices.accepted:
111+
if not last_review:
112+
raise NoReviewFoundError()
113+
114+
if last_review.decision == ReviewDecisionChoices.accepted:
107115
destruction_list.set_status(ListStatus.ready_to_delete)
108-
destruction_list.assign(destruction_list.get_author())
116+
else:
117+
destruction_list.set_status(ListStatus.changes_requested)
109118

110-
# TODO in the case where the archivist rejects it is not clear yet what should happen!
119+
destruction_list.assign(destruction_list.get_author())
111120

112121
def reassign(self, destruction_list: "DestructionList") -> None:
113122
# TODO

backend/src/openarchiefbeheer/destruction/exceptions.py

+4
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ class DeletionProcessingError(Exception):
44

55
class ZaakNotFound(Exception):
66
pass
7+
8+
9+
class NoReviewFoundError(Exception):
10+
pass

0 commit comments

Comments
 (0)