From 26d8d6fdf7e1ceaae7616482f9f3d794f6a6a802 Mon Sep 17 00:00:00 2001 From: venkataakhil Date: Mon, 22 May 2023 17:38:33 +0530 Subject: [PATCH] Publish version fix for float, Input validation message update --- smart_service/apis/master_api.py | 11 +++++++---- smart_service/apis/publish_api.py | 15 +++++---------- .../masters/doctype/app_labels/app_labels.js | 2 +- smart_service/masters/doctype/drive/drive.js | 2 +- smart_service/masters/doctype/fuel/fuel.js | 2 +- .../doctype/procedure_name/procedure_name.js | 2 +- .../service_kilometers/service_kilometers.js | 2 +- .../masters/doctype/sub_systems/sub_systems.js | 2 +- smart_service/masters/doctype/systems/systems.js | 2 +- .../masters/doctype/transmission/transmission.js | 2 +- smart_service/masters/doctype/variant/variant.js | 2 +- .../doctype/vehicle_segment/vehicle_segment.js | 2 +- 12 files changed, 22 insertions(+), 24 deletions(-) diff --git a/smart_service/apis/master_api.py b/smart_service/apis/master_api.py index 502bdbf..758f5d3 100644 --- a/smart_service/apis/master_api.py +++ b/smart_service/apis/master_api.py @@ -437,17 +437,20 @@ def change_file_dir(): def file_not_exists(): file_data = frappe.db.sql(''' - select parent,step_name,file,name from tabProcedure_Details where content_type = 'File' order by parent; ;''', as_dict=1) + select parent,step_name,file,name from tabProcedure_Details where content_type = 'File' order by parent;''', as_dict=1) changed_file_list = [] + count = 1 for d in file_data: path = d['file'] - isExist = os.path.exists(base_path + path) + is_exist = os.path.exists(base_path + path) - if not isExist: + if not is_exist: print(d) + d['id'] = count changed_file_list.append(d) + count += 1 file_path_not_exists = base_path + "/files/json_files/1.json" with open(file_path_not_exists, 'w') as outfile: @@ -572,4 +575,4 @@ def change_single_star_data(): def get_single_star_data(): count = frappe.db.sql(''' select count(*) from tabProcedure_Details where content like "%*%";''', as_dict=1) - print(count) \ No newline at end of file + print(count) diff --git a/smart_service/apis/publish_api.py b/smart_service/apis/publish_api.py index 0d1b005..7f9f254 100644 --- a/smart_service/apis/publish_api.py +++ b/smart_service/apis/publish_api.py @@ -316,7 +316,7 @@ def new_publish(args, publish_type, vehicle, language, version): # get_step_total_count(full_update_file_name) else: - pub_ver = frappe.db.sql(''' SELECT vehicle,`language`,version,publish_type FROM tabPublish where vehicle = '{}' + pub_ver = frappe.db.sql(''' SELECT vehicle,`language`,format(version,2) as version,publish_type FROM tabPublish where vehicle = '{}' and publish_type = 'Global' AND `language` = '{}' order by version desc limit 2 ;'''.format(vehicle, language), as_dict=True) if pub_ver: prev_update_ver = pub_ver[1]['version'] @@ -324,11 +324,11 @@ def new_publish(args, publish_type, vehicle, language, version): '%s-%s-full_v%s.json' % (vehicle, language, prev_update_ver) # test_full_update_file_name = '/home/ubuntu/frappe-bench/sites/guidedsmartservice.com/public/files/json_files/full_update/XUV 0613/XUV 0613-en-full_update.json' - file_flag, final_update_file = merge_json_files( - prev_full_update_file, file_name, full_update_file_name) + # file_flag, final_update_file = merge_json_files( + # prev_full_update_file, file_name, full_update_file_name) # return prev_full_update_file, file_name, new_full_update_file_name - # file_flag, final_update_file = new_merge_json_files( - # prev_full_update_file, file_name, new_full_update_file_name) + file_flag, final_update_file = new_merge_json_files( + prev_full_update_file, file_name, full_update_file_name) return file_flag, final_update_file return True, file_name.split('public')[1] @@ -355,7 +355,6 @@ def merge_json_files(old_json_path, new_json_path, out_file_path): try: with open(old_json_path, 'r') as json_file: data_old = json.load(json_file) - # return data_old with open(new_json_path, 'r') as json_file1: data_new = json.load(json_file1) @@ -594,7 +593,6 @@ def new_merge_json_files(old_json_path, new_json_path, out_file_path): variant_asset_added = set() variant_asset_list = [] try: - # variant_new['Variant']['Assets'] for variant_asset in variant_new['Variant']['Assets']: variant_asset_name.add(variant_asset['file']) if variant_asset['file'] not in variant_asset_added and variant_asset[ @@ -604,7 +602,6 @@ def new_merge_json_files(old_json_path, new_json_path, out_file_path): except: pass try: - # variant_new['Variant']['Systems'] for system in variant_new['Variant']['Systems']: system_asset_name = set() system_asset_added = set() @@ -771,7 +768,6 @@ def new_merge_json_files(old_json_path, new_json_path, out_file_path): if variant_old['Variant']['name'] in variant_name and variant_old['Variant']['name'] not in variant_added: data_consolidated['JSON'].append({'Variant': variant_old['Variant'], }) - return True, data_consolidated json_object = json.dumps(data_consolidated) with open(out_file_path, "w") as outfile: outfile.write(json_object) @@ -779,7 +775,6 @@ def new_merge_json_files(old_json_path, new_json_path, out_file_path): return True, out_file_path except Exception as e: return False, frappe.get_traceback() - # return "Exception in publish" @frappe.whitelist(allow_guest=True) diff --git a/smart_service/masters/doctype/app_labels/app_labels.js b/smart_service/masters/doctype/app_labels/app_labels.js index 0da0ae7..a27107f 100644 --- a/smart_service/masters/doctype/app_labels/app_labels.js +++ b/smart_service/masters/doctype/app_labels/app_labels.js @@ -39,7 +39,7 @@ frappe.ui.form.on('App Labels', { var regex = /[!@#$%^&*()_+\=\[\]{};`~':"\\|.<>\/?]+/; if (frm.doc.english_label) { if (regex.test(frm.doc.english_label) === true) { - frappe.throw(__("English Label : Only letters, numbers and -, are allowed.")); + frappe.throw(__("English Label : Only letters, numbers and - , are allowed.")); frappe.validated = false; } else if (frm.doc.english_label) { if (frm.doc.english_label.includes("'")) { diff --git a/smart_service/masters/doctype/drive/drive.js b/smart_service/masters/doctype/drive/drive.js index 07feb07..0da8456 100644 --- a/smart_service/masters/doctype/drive/drive.js +++ b/smart_service/masters/doctype/drive/drive.js @@ -20,7 +20,7 @@ frappe.ui.form.on('Drive', { } var regex = /[!@#$%^&*()_+\=\[\]{};'`~:"\\|.<>\/?]+/; if (regex.test(frm.doc.drive) === true) { - frappe.msgprint(__("Variant: Only letters, numbers and -, are allowed.")); + frappe.msgprint(__("Variant: Only letters, numbers and - , are allowed.")); frappe.validated = false; } else if (frm.doc.drive) { if (frm.doc.drive.includes("'")) { diff --git a/smart_service/masters/doctype/fuel/fuel.js b/smart_service/masters/doctype/fuel/fuel.js index 382f492..6eddad9 100644 --- a/smart_service/masters/doctype/fuel/fuel.js +++ b/smart_service/masters/doctype/fuel/fuel.js @@ -21,7 +21,7 @@ frappe.ui.form.on('Fuel', { var regex = /[!@#$%^&*()_+\=\[\]{};`~':"\\|.<>\/?]+/; if (frm.doc.fuel) { if (regex.test(frm.doc.fuel) === true) { - frappe.msgprint(__("Fuel: Only letters, numbers and -, are allowed.")); + frappe.msgprint(__("Fuel: Only letters, numbers and - , are allowed.")); frappe.validated = false; } else if (frm.doc.fuel) { if (frm.doc.fuel.includes("'")) { diff --git a/smart_service/masters/doctype/procedure_name/procedure_name.js b/smart_service/masters/doctype/procedure_name/procedure_name.js index a679ead..0ed3c54 100644 --- a/smart_service/masters/doctype/procedure_name/procedure_name.js +++ b/smart_service/masters/doctype/procedure_name/procedure_name.js @@ -20,7 +20,7 @@ frappe.ui.form.on('Procedure Name', { var regex = /[!@#$%^&*()_+\=\[\]{};`~':"\\|.<>\/?]+/; if (frm.doc.procedure_name) { if (regex.test(frm.doc.procedure_name) === true) { - frappe.msgprint(__("Procedure Name: Only letters, numbers and -, are allowed.")); + frappe.msgprint(__("Procedure Name: Only letters, numbers and - , are allowed.")); frappe.validated = false; } else if (frm.doc.procedure_name) { if (frm.doc.procedure_name.includes("'")) { diff --git a/smart_service/masters/doctype/service_kilometers/service_kilometers.js b/smart_service/masters/doctype/service_kilometers/service_kilometers.js index eb17805..e627c9f 100644 --- a/smart_service/masters/doctype/service_kilometers/service_kilometers.js +++ b/smart_service/masters/doctype/service_kilometers/service_kilometers.js @@ -31,7 +31,7 @@ frappe.ui.form.on('Service Kilometers', { var regex = /[!@#$%^&*()_+\=\[\]{};~`':"\\|.<>\/?]+/; if (frm.doc.kilometer) { if (regex.test(frm.doc.kilometer) === true) { - frappe.throw(__("Service Kilometer: Only letters, numbers and / - , are allowed.")); + frappe.throw(__("Service Kilometer: Only letters, numbers and - , are allowed.")); frappe.validated = false; } else if ((frm.doc.kilometer.includes("'"))) { frappe.throw(__("Service Kilometer: Only letters, numbers and , are allowed.")); diff --git a/smart_service/masters/doctype/sub_systems/sub_systems.js b/smart_service/masters/doctype/sub_systems/sub_systems.js index 4ee5a95..e55625c 100644 --- a/smart_service/masters/doctype/sub_systems/sub_systems.js +++ b/smart_service/masters/doctype/sub_systems/sub_systems.js @@ -17,7 +17,7 @@ frappe.ui.form.on('Sub Systems', { var regex = /[!@#$%^&*()_+\=\[\]{};`~:"\\|.<>\/?]+/; if (frm.doc.sub_system_name) { if (regex.test(frm.doc.sub_system_name) === true) { - frappe.msgprint(__("Sub System Name: Only letters, numbers and -,' are allowed.")); + frappe.msgprint(__("Sub System Name: Only letters, numbers and - , ' are allowed.")); frappe.validated = false; } } diff --git a/smart_service/masters/doctype/systems/systems.js b/smart_service/masters/doctype/systems/systems.js index 12731da..18d0a2f 100644 --- a/smart_service/masters/doctype/systems/systems.js +++ b/smart_service/masters/doctype/systems/systems.js @@ -47,7 +47,7 @@ frappe.ui.form.on('Systems', { var regex = /[!@#$%^&*()_+\=\[\]{};`~:"\\|.<>\/?]+/; if (frm.doc.system_name) { if (regex.test(frm.doc.system_name) === true) { - frappe.msgprint(__("system Name: Only letters, numbers and -,' are allowed.")); + frappe.msgprint(__("system Name: Only letters, numbers and - ,' are allowed.")); frappe.validated = false; } } diff --git a/smart_service/masters/doctype/transmission/transmission.js b/smart_service/masters/doctype/transmission/transmission.js index e8cd205..2b92f8f 100644 --- a/smart_service/masters/doctype/transmission/transmission.js +++ b/smart_service/masters/doctype/transmission/transmission.js @@ -21,7 +21,7 @@ frappe.ui.form.on('Transmission', { var regex = /[!@#$%^&*()_+\=\[\]{};`~':"\\|.<>\/?]+/; if (frm.doc.transmission) { if (regex.test(frm.doc.transmission) === true) { - frappe.msgprint(__("Transmission: Only letters, numbers and -, are allowed.")); + frappe.msgprint(__("Transmission: Only letters, numbers and - , are allowed.")); frappe.validated = false; } else if (frm.doc.transmission) { if (frm.doc.transmission.includes("'")) { diff --git a/smart_service/masters/doctype/variant/variant.js b/smart_service/masters/doctype/variant/variant.js index 51d76a6..83f2dcd 100644 --- a/smart_service/masters/doctype/variant/variant.js +++ b/smart_service/masters/doctype/variant/variant.js @@ -27,7 +27,7 @@ frappe.ui.form.on('Variant', { var regex = /[!@#$%^&*()_+\=\[\]{};'`~:"\\|.<>\/?]+/; if(frm.doc.variant){ if (regex.test(frm.doc.variant) === true){ - frappe.msgprint(__("Variant: Only letters, numbers and -, are allowed.")); + frappe.msgprint(__("Variant: Only letters, numbers and - , are allowed.")); frappe.validated = false; } else if(frm.doc.variant) { if(frm.doc.variant.includes("'")) { diff --git a/smart_service/masters/doctype/vehicle_segment/vehicle_segment.js b/smart_service/masters/doctype/vehicle_segment/vehicle_segment.js index 344d4b9..e47b5e2 100644 --- a/smart_service/masters/doctype/vehicle_segment/vehicle_segment.js +++ b/smart_service/masters/doctype/vehicle_segment/vehicle_segment.js @@ -58,7 +58,7 @@ frappe.ui.form.on('Vehicle Segment', { var regex = /[!@#$%^&*()_+\-=\[\]{};'`~:"\\|,.<>\/?]+/; if (frm.doc.vehicle_segment) { if (regex.test(frm.doc.vehicle_segment) === true) { - frappe.msgprint(__("Vehicle Segment: Only letters and numbers are allowed")); + frappe.msgprint(__("Vehicle Segment: Only letters , numbers and - , are allowed")); frappe.validated = false; } else if (frm.doc.vehicle_segment) { if (frm.doc.vehicle_segment.includes("'")) {