feat: implement close_assembly_by_id function and confirm_current_assembly endpoint
This commit is contained in:
		@@ -79,11 +79,9 @@ def create_assembly():
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        return jsonify(response)
 | 
					        return jsonify(response)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def close_assembly_by_id(
 | 
				
			||||||
@assembly_blueprint.post('/close')
 | 
					        assembly_id: int,
 | 
				
			||||||
def close_assembly():
 | 
					):
 | 
				
			||||||
    args = request.json
 | 
					 | 
				
			||||||
    assembly_id = args.get('assemblyId')
 | 
					 | 
				
			||||||
    if not assembly_id or (not isinstance(assembly_id, int)):
 | 
					    if not assembly_id or (not isinstance(assembly_id, int)):
 | 
				
			||||||
        response = {
 | 
					        response = {
 | 
				
			||||||
            'ok': False,
 | 
					            'ok': False,
 | 
				
			||||||
@@ -113,6 +111,13 @@ def close_assembly():
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    return sipro_response
 | 
					    return sipro_response
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@assembly_blueprint.post('/close')
 | 
				
			||||||
 | 
					def close_assembly():
 | 
				
			||||||
 | 
					    args = request.json
 | 
				
			||||||
 | 
					    assembly_id = args.get('assemblyId')
 | 
				
			||||||
 | 
					    sipro_response = close_assembly_by_id(int(assembly_id))
 | 
				
			||||||
 | 
					    return sipro_response
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@assembly_blueprint.post('/cancel')
 | 
					@assembly_blueprint.post('/cancel')
 | 
				
			||||||
def cancel_assembly():
 | 
					def cancel_assembly():
 | 
				
			||||||
@@ -191,6 +196,26 @@ def get_active_assembly():
 | 
				
			|||||||
    return jsonify(response)
 | 
					    return jsonify(response)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@assembly_blueprint.post('/confirmCurrent')
 | 
				
			||||||
 | 
					def confirm_current_assembly():
 | 
				
			||||||
 | 
					    # confirm current assembly for user
 | 
				
			||||||
 | 
					    user_id = get_jwt_identity()
 | 
				
			||||||
 | 
					    assembly = database.Assembly.query.filter(database.Assembly.user_id == user_id,
 | 
				
			||||||
 | 
					                                              database.Assembly.is_active == True).first()
 | 
				
			||||||
 | 
					    if not assembly:
 | 
				
			||||||
 | 
					        response = {
 | 
				
			||||||
 | 
					            'ok': False,
 | 
				
			||||||
 | 
					            'message': 'У вас нет активных сборок'
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return jsonify(response)
 | 
				
			||||||
 | 
					    close_assembly_by_id(assembly.id)
 | 
				
			||||||
 | 
					    response = {
 | 
				
			||||||
 | 
					        'ok': True,
 | 
				
			||||||
 | 
					        'message': 'Сборка успешно завершена!',
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return response
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@assembly_blueprint.post('/confirm')
 | 
					@assembly_blueprint.post('/confirm')
 | 
				
			||||||
def confirm_assembly():
 | 
					def confirm_assembly():
 | 
				
			||||||
    user_id = get_jwt_identity()
 | 
					    user_id = get_jwt_identity()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user