From 55fec926f7c7054d14830399622b0f9d5b4b3790 Mon Sep 17 00:00:00 2001 From: Vlad0n20 Date: Wed, 14 Jan 2026 14:37:41 +0200 Subject: [PATCH 1/2] Update RegistrationActionSerializer --- api/actions/serializers.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/api/actions/serializers.py b/api/actions/serializers.py index d572ee41654..86f006ef3fe 100644 --- a/api/actions/serializers.py +++ b/api/actions/serializers.py @@ -26,6 +26,7 @@ ) from osf.utils.workflows import ( + ApprovalStates, DefaultStates, DefaultTriggers, ReviewStates, @@ -278,6 +279,30 @@ def create(self, validated_data): comment = validated_data.pop('comment', '') user = validated_data.pop('user') + pending_schema_responses = target.schema_responses.filter( + reviews_state__in=[ + ApprovalStates.UNAPPROVED.db_name, + ApprovalStates.PENDING_MODERATION.db_name, + ], + ).order_by('-created') + + if pending_schema_responses.exists(): + pending_response = pending_schema_responses.first() + short_message = 'This registration has a pending update' + long_message = ( + f'This registration has a pending schema response update (ID: {pending_response._id}) ' + f'that must be moderated. Please use the schema response actions endpoint to approve or reject ' + f'the update instead of creating a registration action.' + ) + raise HTTPError( + http_status.HTTP_400_BAD_REQUEST, + data={ + 'message_short': short_message, + 'message_long': long_message, + 'schema_response_id': pending_response._id, + }, + ) + sanction = target.sanction try: From e894d6ed0e6ba8f1505e10deeec69e1d4e05cadb Mon Sep 17 00:00:00 2001 From: Vlad0n20 Date: Wed, 14 Jan 2026 18:43:14 +0200 Subject: [PATCH 2/2] Update RegistrationActionSerializer --- api/actions/serializers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/actions/serializers.py b/api/actions/serializers.py index 86f006ef3fe..a4ab5b71d83 100644 --- a/api/actions/serializers.py +++ b/api/actions/serializers.py @@ -279,15 +279,16 @@ def create(self, validated_data): comment = validated_data.pop('comment', '') user = validated_data.pop('user') - pending_schema_responses = target.schema_responses.filter( + pending_schema_response_updates = target.schema_responses.filter( reviews_state__in=[ ApprovalStates.UNAPPROVED.db_name, ApprovalStates.PENDING_MODERATION.db_name, ], + previous_response__isnull=False, # Only updates, not initial submissions ).order_by('-created') - if pending_schema_responses.exists(): - pending_response = pending_schema_responses.first() + if pending_schema_response_updates.exists(): + pending_response = pending_schema_response_updates.first() short_message = 'This registration has a pending update' long_message = ( f'This registration has a pending schema response update (ID: {pending_response._id}) '