File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626)
2727
2828from 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 :
You can’t perform that action at this time.
0 commit comments