Skip to content

Commit 8612887

Browse files
Vlad0n20ihorsokhanexoft
authored andcommitted
[ENG-10042] Fix/eng 10042 (#11551)
* Update RegistrationActionSerializer * Update RegistrationActionSerializer
1 parent 8212ede commit 8612887

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

api/actions/serializers.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
)
2727

2828
from osf.utils.workflows import (
29+
ApprovalStates,
2930
DefaultStates,
3031
DefaultTriggers,
3132
ReviewStates,
@@ -278,6 +279,31 @@ def create(self, validated_data):
278279
comment = validated_data.pop('comment', '')
279280
user = validated_data.pop('user')
280281

282+
pending_schema_response_updates = target.schema_responses.filter(
283+
reviews_state__in=[
284+
ApprovalStates.UNAPPROVED.db_name,
285+
ApprovalStates.PENDING_MODERATION.db_name,
286+
],
287+
previous_response__isnull=False, # Only updates, not initial submissions
288+
).order_by('-created')
289+
290+
if pending_schema_response_updates.exists():
291+
pending_response = pending_schema_response_updates.first()
292+
short_message = 'This registration has a pending update'
293+
long_message = (
294+
f'This registration has a pending schema response update (ID: {pending_response._id}) '
295+
f'that must be moderated. Please use the schema response actions endpoint to approve or reject '
296+
f'the update instead of creating a registration action.'
297+
)
298+
raise HTTPError(
299+
http_status.HTTP_400_BAD_REQUEST,
300+
data={
301+
'message_short': short_message,
302+
'message_long': long_message,
303+
'schema_response_id': pending_response._id,
304+
},
305+
)
306+
281307
sanction = target.sanction
282308

283309
try:

0 commit comments

Comments
 (0)