File tree 2 files changed +3
-24
lines changed
backend/src/openarchiefbeheer/destruction
2 files changed +3
-24
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ class DestructionListViewSet(
188
188
"assignees" ,
189
189
queryset = DestructionListAssignee .objects .select_related (
190
190
"user" , "user__role"
191
- ),
191
+ ). order_by ( "pk" ) ,
192
192
)
193
193
)
194
194
)
Original file line number Diff line number Diff line change 4
4
from django .conf import settings
5
5
from django .core .mail import send_mail
6
6
from django .db import transaction
7
- from django .db .models import Q
8
7
9
8
from openarchiefbeheer .accounts .models import User
10
9
from openarchiefbeheer .emails .models import EmailConfig
@@ -133,30 +132,10 @@ def process_new_assignees(
133
132
assignees : list [dict ],
134
133
role : str ,
135
134
) -> list [DestructionListAssignee ]:
136
- """
137
- Remove any assignees that are not present in the new assignees and create the new ones.
138
-
139
- Example:
140
- Before reassigning there are reviewerA, reviewerB and reviewerC.
141
- The record manager requests that the new reviewers are reviewerB and reviewerD.
142
- This function deletes reviewerA and reviewerC and creates reviewerD.
143
- """
144
- users = [assignee ["user" ] for assignee in assignees ]
145
-
146
135
with transaction .atomic ():
147
- destruction_list .assignees .filter (~ Q (user__in = users ), role = role ).delete ()
148
-
149
- existing_assignees_users = [
150
- assignee .user .pk
151
- for assignee in destruction_list .assignees .filter (role = role )
152
- ]
153
- assignees_to_create = []
154
- for assignee in assignees :
155
- if assignee ["user" ].pk not in existing_assignees_users :
156
- assignees_to_create .append (assignee )
157
-
136
+ destruction_list .assignees .filter (role = role ).delete ()
158
137
new_assignees = destruction_list .bulk_create_assignees (
159
- assignees_to_create ,
138
+ assignees ,
160
139
role ,
161
140
)
162
141
You can’t perform that action at this time.
0 commit comments