Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions api/actions/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
)

from osf.utils.workflows import (
ApprovalStates,
DefaultStates,
DefaultTriggers,
ReviewStates,
Expand Down Expand Up @@ -278,6 +279,31 @@ def create(self, validated_data):
comment = validated_data.pop('comment', '')
user = validated_data.pop('user')

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_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}) '
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:
Expand Down
Loading