diff --git a/cope2n-ai-fi/.dockerignore b/cope2n-ai-fi/.dockerignore index b2ac9a7..4936ddc 100755 --- a/cope2n-ai-fi/.dockerignore +++ b/cope2n-ai-fi/.dockerignore @@ -5,4 +5,5 @@ packages/ __pycache__ DataBase/image_temp/ DataBase/json_temp/ -DataBase/template.db \ No newline at end of file +DataBase/template.db +key_value_understanding-20231024-125646_manulife2/ \ No newline at end of file diff --git a/cope2n-api/fwd_api/utils/file.py b/cope2n-api/fwd_api/utils/file.py index 5e95ff8..d3ae556 100644 --- a/cope2n-api/fwd_api/utils/file.py +++ b/cope2n-api/fwd_api/utils/file.py @@ -326,3 +326,21 @@ def build_url(folder: str, data_id: str, user_id: int, file_name: str = None) -> def build_media_url_v2(media_id: str, user_id: int, sub_id: int, u_sync_id: str) -> str: token = image_authenticator.generate_img_token_v2(user_id, sub_id, u_sync_id) return f'{settings.BASE_URL}/api/ctel/v2/media/request/{media_id}/?token={token}' + +def json2xlsx(input: json): + """_summary_ + + Args: + input (json): + : [{ + Subs: Jan, # Subtotal name + Metadata: {num_imei: 1, + ...: ...} + Data: [{num_imei: 1, + ...: ...}] + }] + OR + + """ + # return xlsx + pass \ No newline at end of file diff --git a/cope2n-api/fwd_api/utils/process.py b/cope2n-api/fwd_api/utils/process.py index 28bf0b7..c89b42f 100644 --- a/cope2n-api/fwd_api/utils/process.py +++ b/cope2n-api/fwd_api/utils/process.py @@ -104,7 +104,9 @@ def validate_ocr_request_and_get(request, subscription): FileUtils.validate_list_file(list_file) validated_data['file'] = list_file[0] - validated_data['is_test_request'] = request.data.get('is_test_request', False) + # validated_data['is_test_request'] = bool(request.data.get('is_test_request', False)) + validated_data['is_test_request'] = string_to_boolean(request.data.get('is_test_request', "false")) + # print(f"[DEBUG]: is_test_request: ", validated_data['is_test_request']) return validated_data @@ -139,9 +141,22 @@ def sbt_validate_ocr_request_and_get(request, subscription): validated_data['imei_file'] = imei_files validated_data['invoice_file'] = invoice_file validated_data['redemption_ID'] = redemption_ID + validated_data['is_test_request'] = string_to_boolean(request.data.get('is_test_request', "false")) + # print(f"[DEBUG]: is_test_request: ", validated_data['is_test_request']) return validated_data +def string_to_boolean(value): + true_strings = ['true', 'yes', '1', 'on'] + false_strings = ['false', 'no', '0', 'off'] + + if isinstance(value, str): + lower_value = value.lower() + if lower_value in true_strings: + return True + else: + return False + def sbt_validate_feedback(request): validated_data = {} diff --git a/docker-compose-prod.yml b/docker-compose-prod.yml index be4c4b2..cbc1e68 100644 --- a/docker-compose-prod.yml +++ b/docker-compose-prod.yml @@ -139,7 +139,6 @@ services: condition: service_started volumes: - BE_media:${MEDIA_ROOT} - working_dir: /app command: sh -c "celery -A fwd_api.celery_worker.worker worker -l INFO -c 5" diff --git a/tests/utils.py b/tests/utils.py index 2994ef9..0dc3518 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -34,7 +34,7 @@ def make_sbt_request(host, token, invoice_files=None, imei_files=None, ensure_su files.append(('imei_files', (file, open(file, "rb"), 'application/octet-stream'))) num_files = len(files) files.append(('processType', '12')) - files.append(('is_test_request', 'true')) + files.append(('is_test_request', 'True')) start_time = time.time() end_of_upload_time = 0