Returns application state if any stored.
()
| 347 | methods=["GET"], endpoint='get_application_state') |
| 348 | @pga_login_required |
| 349 | def get_application_state(): |
| 350 | """ |
| 351 | Returns application state if any stored. |
| 352 | """ |
| 353 | fernet = Fernet(current_app.config['SECRET_KEY'].encode()) |
| 354 | result = db.session \ |
| 355 | .query(ApplicationState) \ |
| 356 | .filter(ApplicationState.uid == current_user.id) \ |
| 357 | .all() |
| 358 | |
| 359 | res = [] |
| 360 | for row in result: |
| 361 | connection_info = row.connection_info |
| 362 | if (connection_info and 'open_file_name' in connection_info and |
| 363 | connection_info['open_file_name']): |
| 364 | file_path = get_complete_file_path( |
| 365 | connection_info['open_file_name']) |
| 366 | file_deleted = False if file_path else True |
| 367 | connection_info['file_deleted'] = file_deleted |
| 368 | |
| 369 | if (not file_deleted and connection_info['is_editor_dirty'] and |
| 370 | 'last_saved_file_hash' in connection_info and |
| 371 | connection_info['last_saved_file_hash']): |
| 372 | connection_info['external_file_changes'] = \ |
| 373 | check_external_file_changes( |
| 374 | file_path, connection_info['last_saved_file_hash']) |
| 375 | |
| 376 | res.append({'connection_info': connection_info, |
| 377 | 'tool_data': fernet.decrypt(row.tool_data).decode(), |
| 378 | 'id': row.id |
| 379 | }) |
| 380 | return make_json_response( |
| 381 | data={ |
| 382 | 'status': True, |
| 383 | 'msg': '', |
| 384 | 'result': res |
| 385 | } |
| 386 | ) |
| 387 | |
| 388 | |
| 389 | @blueprint.route( |
nothing calls this directly
no test coverage detected