feat: add response for users with existing active assemblies
This commit is contained in:
@@ -56,6 +56,22 @@ def create_assembly():
|
|||||||
'statusCode': 'USER_ALREADY_HAS_ACTIVE_ASSEMBLY'
|
'statusCode': 'USER_ALREADY_HAS_ACTIVE_ASSEMBLY'
|
||||||
}
|
}
|
||||||
return jsonify(response)
|
return jsonify(response)
|
||||||
|
assembled_assembly = (
|
||||||
|
database.Assembly.query
|
||||||
|
.filter(
|
||||||
|
database.Assembly.order_id == order_id,
|
||||||
|
database.Assembly.ended_at != None
|
||||||
|
)
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
if assembled_assembly:
|
||||||
|
response = {
|
||||||
|
'ok': False,
|
||||||
|
'message': 'Вы уже собирали этот товар',
|
||||||
|
'assemblyId': assembled_assembly.id,
|
||||||
|
'statusCode': 'USER_ALREADY_HAS_ACTIVE_ASSEMBLY',
|
||||||
|
}
|
||||||
|
return jsonify(response)
|
||||||
assembly = database.Assembly(user_id=user_id,
|
assembly = database.Assembly(user_id=user_id,
|
||||||
order_id=order_id,
|
order_id=order_id,
|
||||||
state=AssemblyState.NOT_STARTED,
|
state=AssemblyState.NOT_STARTED,
|
||||||
@@ -79,6 +95,7 @@ def create_assembly():
|
|||||||
}
|
}
|
||||||
return jsonify(response)
|
return jsonify(response)
|
||||||
|
|
||||||
|
|
||||||
def close_assembly_by_id(
|
def close_assembly_by_id(
|
||||||
assembly_id: int,
|
assembly_id: int,
|
||||||
):
|
):
|
||||||
@@ -111,6 +128,7 @@ def close_assembly_by_id(
|
|||||||
|
|
||||||
return sipro_response
|
return sipro_response
|
||||||
|
|
||||||
|
|
||||||
@assembly_blueprint.post('/close')
|
@assembly_blueprint.post('/close')
|
||||||
def close_assembly():
|
def close_assembly():
|
||||||
args = request.json
|
args = request.json
|
||||||
|
|||||||
Reference in New Issue
Block a user