(trans_id)
| 391 | methods=["GET"], endpoint='get_tool_data') |
| 392 | @pga_login_required |
| 393 | def get_tool_data(trans_id): |
| 394 | fernet = Fernet(current_app.config['SECRET_KEY'].encode()) |
| 395 | result = db.session \ |
| 396 | .query(ApplicationState) \ |
| 397 | .filter(ApplicationState.uid == current_user.id, |
| 398 | ApplicationState.id == trans_id) \ |
| 399 | .first() |
| 400 | |
| 401 | if result: |
| 402 | connection_info = result.connection_info |
| 403 | tool_data = fernet.decrypt(result.tool_data).decode() |
| 404 | |
| 405 | if (connection_info and 'open_file_name' in connection_info and |
| 406 | connection_info['open_file_name']): |
| 407 | file_path = ( |
| 408 | get_complete_file_path(connection_info['open_file_name'])) |
| 409 | file_deleted = False if file_path else True |
| 410 | connection_info['file_deleted'] = file_deleted |
| 411 | |
| 412 | if (not file_deleted and connection_info['is_editor_dirty'] and |
| 413 | 'last_saved_file_hash' in connection_info and |
| 414 | connection_info['last_saved_file_hash']): |
| 415 | connection_info['external_file_changes'] = \ |
| 416 | check_external_file_changes( |
| 417 | file_path, connection_info['last_saved_file_hash']) |
| 418 | |
| 419 | if not (file_deleted or connection_info['is_editor_dirty']): |
| 420 | # Send tool data only if file is deleted or edited |
| 421 | tool_data = None |
| 422 | |
| 423 | return make_json_response( |
| 424 | data={ |
| 425 | 'status': True, |
| 426 | 'msg': '', |
| 427 | 'result': { |
| 428 | 'connection_info': connection_info, |
| 429 | 'tool_data': tool_data, |
| 430 | 'id': result.id |
| 431 | } |
| 432 | } |
| 433 | ) |
| 434 | else: |
| 435 | return ( |
| 436 | make_json_response( |
| 437 | success=0, |
| 438 | errormsg=gettext( |
| 439 | 'There is no saved content available for this tab.'), |
| 440 | status=404 |
| 441 | )) |
| 442 | |
| 443 | |
| 444 | @blueprint.route( |
nothing calls this directly
no test coverage detected