From 08440f378cf0caa8169c54cbe367d6306621381f Mon Sep 17 00:00:00 2001 From: venkataakhil Date: Fri, 22 Sep 2023 10:40:57 +0530 Subject: [PATCH] QWIK and MST tools --- smart_service/apis/v2/master.py | 66 +++++++------- .../doctype/feature_finder/feature_finder.js | 3 +- .../doctype/feature_finder/feature_finder.py | 56 ++++++------ .../phase_2/doctype/instructions/__init__.py | 0 .../doctype/instructions/instructions.json | 56 ++++++++++++ .../doctype/instructions/instructions.py | 8 ++ .../instructions_step_name/__init__.py | 0 .../instructions_step_name.js | 8 ++ .../instructions_step_name.json | 51 +++++++++++ .../instructions_step_name.py | 8 ++ .../test_instructions_step_name.py | 8 ++ .../doctype/qwik_service/qwik_service.js | 29 +++--- .../doctype/qwik_service/qwik_service.json | 7 +- .../doctype/qwik_service/qwik_service.py | 10 ++- .../qwik_service_publish_data/__init__.py | 0 .../qwik_service_publish_data.json | 70 +++++++++++++++ .../qwik_service_publish_data.py | 8 ++ .../special_tool_information.json | 88 ++++++++++++------- 18 files changed, 364 insertions(+), 112 deletions(-) create mode 100644 smart_service/phase_2/doctype/instructions/__init__.py create mode 100644 smart_service/phase_2/doctype/instructions/instructions.json create mode 100644 smart_service/phase_2/doctype/instructions/instructions.py create mode 100644 smart_service/phase_2/doctype/instructions_step_name/__init__.py create mode 100644 smart_service/phase_2/doctype/instructions_step_name/instructions_step_name.js create mode 100644 smart_service/phase_2/doctype/instructions_step_name/instructions_step_name.json create mode 100644 smart_service/phase_2/doctype/instructions_step_name/instructions_step_name.py create mode 100644 smart_service/phase_2/doctype/instructions_step_name/test_instructions_step_name.py create mode 100644 smart_service/phase_2/doctype/qwik_service_publish_data/__init__.py create mode 100644 smart_service/phase_2/doctype/qwik_service_publish_data/qwik_service_publish_data.json create mode 100644 smart_service/phase_2/doctype/qwik_service_publish_data/qwik_service_publish_data.py diff --git a/smart_service/apis/v2/master.py b/smart_service/apis/v2/master.py index 407b7f1..90c346a 100644 --- a/smart_service/apis/v2/master.py +++ b/smart_service/apis/v2/master.py @@ -169,7 +169,11 @@ def new_publish(): elif module == "Mahindra Special Tool Information": flag, data = get_special_tool_information(vehicle) - + + elif module == "Qwik Service": + flag, data = get_qwik_service(variant,language) + return data + if flag: return {'status': 1, 'error': None, 'data': data} else: @@ -211,6 +215,11 @@ def new_publish1(): data = json.load(outfile) data = data['data'] + elif module == 'Qwik Service': + with open(BASE_PATH + str(vehicle) + '-qwik_service.json') as outfile: + data = json.load(outfile) + data = data['data'] + # elif module == 'Training Information': # flag, data = get_training_information(vehicle, language) @@ -226,44 +235,29 @@ def new_publish1(): @frappe.whitelist(methods=['POST'], allow_guest=1) def get_special_tool_information(vehicle): try: - special_tool_details = frappe.db.sql(f''' select name,vehicle,category,sub_category,display_order, my_id,keywords from `tabSpecial Tool Information` + special_tool_details = frappe.db.sql(f''' select name,vehicle,category,sub_category,display_order, + my_id,keywords from `tabSpecial Tool Information` where vehicle="{vehicle}";''', as_dict=1) for s in special_tool_details: - s['tool_usage_content'] = frappe.db.sql(f'''select idx as 'display_order',image,content,video,asset_type,active_status from `tabMST Information Assets` - where parent = '{s['name']}' order by display_order;''', as_dict=1) + s['tool_usage_content'] = frappe.db.sql(f'''select idx as 'display_order',image,content,video,asset_type,active_status + from `tabMST Information Assets` where parent = '{s['name']}' order by display_order;''', as_dict=1) return True, special_tool_details except Exception as e: return False, e + - -@frappe.whitelist(allow_guest=1) -def update_publish_mapping(vehicle, variant, language, module): - frappe.set_user('Administrator') - pub_data = frappe.db.get_list('Module Publish Mapping', filters={ - "vehicle": vehicle, - "variant": variant, - "language": language - }, fields=['name']) - - if pub_data: - doc = frappe.get_doc('Module Publish Mapping', pub_data[0]['name']) - else: - doc = frappe.get_doc({ - 'doctype': 'Module Publish Mapping', - "vehicle": vehicle, - "variant": variant, - "language": language - }) - if module == 'Automotive System': - doc.automotive_system = 1 - doc.tsb = 1 - doc.fsa = 1 - doc.tekalert = 1 - - elif module == 'Feature Finder': - doc.feature_finder = 1 - - elif module == 'Repair service': - doc.repairservice_check_sheet = 1 - doc.save() - return 1 +@frappe.whitelist(methods=['POST'], allow_guest=1) +def get_qwik_service(variant,language): + try: + qwik_service_details=frappe.db.sql('''select name,variant,vehicle,kilometers,language,service_time,active_status, + pdf,display_order,keywords,my_id from `tabQwik Service` where variant='%s' && + language='%s';'''%(variant,language),as_dict=1) + for q in qwik_service_details: + q['content'] = frappe.db.sql('''select idx as 'display_order',content_type,content from `tabQwik Service Content` + where parent='%s';'''%(q['name']),as_dict=1) + for p in qwik_service_details: + p['qwik_procedure'] = frappe.db.sql('''select idx as 'display_order',side,level,content from `tabQwik Procedure` + where parent ='%s';'''%(p['name']),as_dict=1) + return True, qwik_service_details + except Exception as e: + return False, e \ No newline at end of file diff --git a/smart_service/phase_2/doctype/feature_finder/feature_finder.js b/smart_service/phase_2/doctype/feature_finder/feature_finder.js index c329ce1..cb042b8 100644 --- a/smart_service/phase_2/doctype/feature_finder/feature_finder.js +++ b/smart_service/phase_2/doctype/feature_finder/feature_finder.js @@ -340,6 +340,7 @@ function custom_tab_html(frm) { tab_ref: "SOP" }, callback: function (r) { + console.log("tab",r) frm.refresh_field('tab_ref') } }) @@ -537,7 +538,7 @@ function custom_tab_html(frm) { //buttons spec_custom_dt += '' spec_custom_dt += '' - spec_custom_dt += '' + spec_custom_dt += '' spec_custom_dt += '' spec_custom_dt += '' diff --git a/smart_service/phase_2/doctype/feature_finder/feature_finder.py b/smart_service/phase_2/doctype/feature_finder/feature_finder.py index 0b4ef6c..10b201c 100644 --- a/smart_service/phase_2/doctype/feature_finder/feature_finder.py +++ b/smart_service/phase_2/doctype/feature_finder/feature_finder.py @@ -24,7 +24,8 @@ class FeatureFinder(Document): def validate(self): try: - self.sop_name = self.sop_name.strip() + if self.sop_name: + self.sop_name = self.sop_name.strip() if self.is_new(): self.tab_ref = "SOP" if self.variant and self.language and self.feature_name: @@ -38,7 +39,7 @@ class FeatureFinder(Document): # ''', as_dict=1) check_exe = frappe.db.sql(''' select * from `tabFeature Finder` where variant='%s' and features_names='%s' and language='en' and name != '%s' ; - ''' %(self.variant,self.features_names,self.name), as_dict=1) + ''' % (self.variant, self.features_names, self.name), as_dict=1) # frappe.log_error("check_exe",str(check_exe)) if check_exe: if self.language != "en": @@ -49,7 +50,7 @@ class FeatureFinder(Document): if not check_exe: if self.language != "en": frappe.throw("First language will be english only") - + if not self.is_new() and self.is_published == 1: self.is_published = 0 @@ -87,7 +88,7 @@ class FeatureFinder(Document): @frappe.whitelist() def get_feature_list(vehicle, language): features_list = frappe.db.sql( - """select feature_name from `tabFeature Finder Master` where vehicle='%s' and language = '%s';""" %(vehicle,language), as_list=1) + """select feature_name from `tabFeature Finder Master` where vehicle='%s' and language = '%s';""" % (vehicle, language), as_list=1) return features_list @@ -95,37 +96,38 @@ def get_feature_list(vehicle, language): def get_list_data(name, val): specification = frappe.db.sql( """select *,'Feature Finder Specification' as doctype from `tabFeature Finder Specification` where parent = '%s' and - post_vin_cutoff_name='%s'""" %(name,val), as_dict=1) + post_vin_cutoff_name='%s'""" % (name, val), as_dict=1) feature_finder_images = frappe.db.sql( - """select * from `tabFeature Finder Images` where parent = '%s' and post_vin_cutoff_name='%s'""" %(name,val), as_dict=1) + """select * from `tabFeature Finder Images` where parent = '%s' and post_vin_cutoff_name='%s'""" % (name, val), as_dict=1) feature_finder_content = frappe.db.sql( - """select * from `tabFeature Finder Content` where parent = '%s' and post_vin_cutoff_name='%s'""" %(name,val), as_dict=1) + """select * from `tabFeature Finder Content` where parent = '%s' and post_vin_cutoff_name='%s'""" % (name, val), as_dict=1) return specification, feature_finder_images, feature_finder_content @frappe.whitelist() -def insert_spec_data(doc_name, values,tab_ref): +def insert_spec_data(doc_name, values, tab_ref): try: val = json.loads(values) - get_count = frappe.db.sql("""select name from `tabFeature Finder Specification` where parent='%s' and feature_type='%s'""" %(doc_name,val.get('feature_type')),as_dict=1) + get_count = frappe.db.sql("""select name from `tabFeature Finder Specification` where parent='%s' and feature_type='%s'""" % ( + doc_name, val.get('feature_type')), as_dict=1) get_count = len(get_count)+1 result = frappe.get_doc("Feature Finder", doc_name) result.tab_ref = tab_ref result.save() frappe.db.commit() - if val.get('name') != None: + if val.get('name') != None: doc = frappe.get_doc("Feature Finder Specification", val['name']) doc.specification = val.get('specification') doc.value = val.get('value') # doc.active_status = val.get('active_status') doc.feature_type = val.get('feature_type') - doc.display_order = val.get('display_order') + doc.display_order = val.get('display_order') doc.save() frappe.db.commit() else: res = frappe.get_doc("Feature Finder", doc_name) - val['display_order'] = get_count + val['display_order'] = get_count res.append("specification", val) res.save() @@ -149,11 +151,11 @@ def delete_spec_data(values): @frappe.whitelist() -def insert_image_data(doc_name, values,tab_ref): +def insert_image_data(doc_name, values, tab_ref): try: val = json.loads(values) get_count = frappe.db.sql("""select name from `tabFeature Finder Images` where parent='%s' and - feature_type='%s'""" %(doc_name,val.get('feature_type')),as_dict=1) + feature_type='%s'""" % (doc_name, val.get('feature_type')), as_dict=1) get_count = len(get_count)+1 result = frappe.get_doc("Feature Finder", doc_name) result.tab_ref = tab_ref @@ -170,7 +172,7 @@ def insert_image_data(doc_name, values,tab_ref): else: res = frappe.get_doc("Feature Finder", doc_name) - val['display_order'] = get_count + val['display_order'] = get_count res.append("feature_finder_images", val) res.save() frappe.db.commit() @@ -195,11 +197,11 @@ def delete_image_data(values): @frappe.whitelist() -def insert_content_data(doc_name, values,tab_ref): +def insert_content_data(doc_name, values, tab_ref): try: val = json.loads(values) get_count = frappe.db.sql("""select name from `tabFeature Finder Content` where parent='%s' and - feature_type='%s'""" %(doc_name,val.get('feature_type')),as_dict=1) + feature_type='%s'""" % (doc_name, val.get('feature_type')), as_dict=1) get_count = len(get_count)+1 result = frappe.get_doc("Feature Finder", doc_name) result.tab_ref = tab_ref @@ -216,7 +218,7 @@ def insert_content_data(doc_name, values,tab_ref): else: res = frappe.get_doc("Feature Finder", doc_name) - val['display_order'] = get_count + val['display_order'] = get_count res.append("feature_finder_content", val) res.save() frappe.db.commit() @@ -251,13 +253,13 @@ def delete_content_data(values): @frappe.whitelist() def set_display_order(doctype_name, values): try: - if len(values)>0: + if len(values) > 0: val = json.loads(values) if len(val) > 0: count_val = 0 for k in val: count_val += 1 - frappe.log_error("k",(str(k))) + frappe.log_error("k", (str(k))) if k: res = frappe.get_doc(doctype_name, k) # frappe.msgprint(str(k)+"-"+str(count_val)) @@ -266,25 +268,25 @@ def set_display_order(doctype_name, values): frappe.db.commit() return {"status": "success"} else: - return{"status":"fail"} + return {"status": "fail"} except Exception as e: frappe.log_error("set_display_order", frappe.get_traceback()) pass - @frappe.whitelist() def get_specification_list(): - res = frappe.db.sql("""select name from `tabFeature Finder Specification Master`""",as_dict=1) + res = frappe.db.sql( + """select name from `tabFeature Finder Specification Master`""", as_dict=1) return res - @frappe.whitelist() -def insert_tab_ref(docname,tab_ref): +def insert_tab_ref(docname, tab_ref): try: if docname and tab_ref: - frappe.db.sql("""UPDATE `tabFeature Finder` set tab_ref='%s' WHERE name ='%s'""" %(tab_ref,docname)) + frappe.db.sql("""UPDATE `tabFeature Finder` set tab_ref='%s' WHERE name ='%s'""" % ( + tab_ref, docname)) frappe.db.commit() except Exception as e: - frappe.log_error("insert_tab",frappe.get_traceback()) \ No newline at end of file + frappe.log_error("insert_tab", frappe.get_traceback()) diff --git a/smart_service/phase_2/doctype/instructions/__init__.py b/smart_service/phase_2/doctype/instructions/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/smart_service/phase_2/doctype/instructions/instructions.json b/smart_service/phase_2/doctype/instructions/instructions.json new file mode 100644 index 0000000..ee420e7 --- /dev/null +++ b/smart_service/phase_2/doctype/instructions/instructions.json @@ -0,0 +1,56 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2023-09-21 17:56:22.177272", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "step_name", + "content_type", + "content", + "imagevideo", + "pdf" + ], + "fields": [ + { + "fieldname": "step_name", + "fieldtype": "Link", + "label": "Step Name", + "options": "Instructions Step Name" + }, + { + "fieldname": "content_type", + "fieldtype": "Select", + "label": "Content Type", + "options": "Content\nImage\nVideo\nPDF" + }, + { + "fieldname": "content", + "fieldtype": "Data", + "label": "Content" + }, + { + "depends_on": "eval:doc.instructions!='Content'", + "fieldname": "imagevideo", + "fieldtype": "Attach", + "label": "Image/Video" + }, + { + "fieldname": "pdf", + "fieldtype": "Attach", + "label": "PDF" + } + ], + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2023-09-21 18:30:15.606987", + "modified_by": "Administrator", + "module": "Phase-2", + "name": "Instructions", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC" +} \ No newline at end of file diff --git a/smart_service/phase_2/doctype/instructions/instructions.py b/smart_service/phase_2/doctype/instructions/instructions.py new file mode 100644 index 0000000..0327ff2 --- /dev/null +++ b/smart_service/phase_2/doctype/instructions/instructions.py @@ -0,0 +1,8 @@ +# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + +class Instructions(Document): + pass diff --git a/smart_service/phase_2/doctype/instructions_step_name/__init__.py b/smart_service/phase_2/doctype/instructions_step_name/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/smart_service/phase_2/doctype/instructions_step_name/instructions_step_name.js b/smart_service/phase_2/doctype/instructions_step_name/instructions_step_name.js new file mode 100644 index 0000000..6e94dc9 --- /dev/null +++ b/smart_service/phase_2/doctype/instructions_step_name/instructions_step_name.js @@ -0,0 +1,8 @@ +// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Instructions Step Name', { + // refresh: function(frm) { + + // } +}); diff --git a/smart_service/phase_2/doctype/instructions_step_name/instructions_step_name.json b/smart_service/phase_2/doctype/instructions_step_name/instructions_step_name.json new file mode 100644 index 0000000..2a54ffb --- /dev/null +++ b/smart_service/phase_2/doctype/instructions_step_name/instructions_step_name.json @@ -0,0 +1,51 @@ +{ + "actions": [], + "allow_import": 1, + "allow_rename": 1, + "autoname": "format:{step_name}", + "creation": "2023-09-21 17:30:21.195368", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "step_name" + ], + "fields": [ + { + "allow_in_quick_entry": 1, + "fieldname": "step_name", + "fieldtype": "Data", + "in_list_view": 1, + "in_preview": 1, + "label": "Step Name", + "reqd": 1, + "unique": 1 + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2023-09-21 17:30:21.195368", + "modified_by": "Administrator", + "module": "Phase-2", + "name": "Instructions Step Name", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "quick_entry": 1, + "search_fields": "step_name", + "sort_field": "step_name", + "sort_order": "ASC", + "title_field": "step_name" +} \ No newline at end of file diff --git a/smart_service/phase_2/doctype/instructions_step_name/instructions_step_name.py b/smart_service/phase_2/doctype/instructions_step_name/instructions_step_name.py new file mode 100644 index 0000000..f160c01 --- /dev/null +++ b/smart_service/phase_2/doctype/instructions_step_name/instructions_step_name.py @@ -0,0 +1,8 @@ +# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + +class InstructionsStepName(Document): + pass diff --git a/smart_service/phase_2/doctype/instructions_step_name/test_instructions_step_name.py b/smart_service/phase_2/doctype/instructions_step_name/test_instructions_step_name.py new file mode 100644 index 0000000..40bbb30 --- /dev/null +++ b/smart_service/phase_2/doctype/instructions_step_name/test_instructions_step_name.py @@ -0,0 +1,8 @@ +# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and Contributors +# See license.txt + +# import frappe +import unittest + +class TestInstructionsStepName(unittest.TestCase): + pass diff --git a/smart_service/phase_2/doctype/qwik_service/qwik_service.js b/smart_service/phase_2/doctype/qwik_service/qwik_service.js index d978d9e..eb03e99 100644 --- a/smart_service/phase_2/doctype/qwik_service/qwik_service.js +++ b/smart_service/phase_2/doctype/qwik_service/qwik_service.js @@ -84,7 +84,7 @@ frappe.ui.form.on('Qwik Service', { function custom_tab_html(frm){ // tab start var res = $(cur_frm.fields_dict.test_html.wrapper).empty(); - var ret = '