From 39ea33ca609800393574995edb26def39376e399 Mon Sep 17 00:00:00 2001 From: venkataakhil Date: Thu, 30 Nov 2023 12:26:57 +0530 Subject: [PATCH] changes in variant mapping --- smart_service/apis/v2/master.py | 184 ++++++++++-------- .../doctype/role_master/role_master.json | 9 +- .../doctype/feature_finder/feature_finder.js | 6 +- .../doctype/feature_finder/feature_finder.py | 2 +- .../transactions/doctype/publish/publish.py | 4 +- .../variant_mapping/variant_mapping.json | 3 +- 6 files changed, 120 insertions(+), 88 deletions(-) diff --git a/smart_service/apis/v2/master.py b/smart_service/apis/v2/master.py index 0c7942e..d04e9cf 100644 --- a/smart_service/apis/v2/master.py +++ b/smart_service/apis/v2/master.py @@ -19,23 +19,23 @@ date_format = "%Y-%m-%d %H:%M:%S.%f" current_db_name = frappe.conf.get("db_name") # style="""""" @@ -62,10 +62,10 @@ def get_role_mapping(): data['module'] = module_details if lsdt: role_maping_details = frappe.db.sql(f"""SELECT role,my_id,display_order,modules,active_status,modified from `tabRole Master` - where modified>='{lsdt}' order by display_order;""", as_dict=1) + where active_status = 'Active' and modified>='{lsdt}' order by display_order;""", as_dict=1) else: role_maping_details = frappe.db.sql(f"""SELECT role,my_id,display_order,modules,active_status,modified from `tabRole Master` - order by display_order;""", as_dict=1) + where active_status = 'Active' order by display_order;""", as_dict=1) data['role_mapping'] = role_maping_details return {"status": 1, "error": None, 'lsdt': utils.now(), "data": data} @@ -188,7 +188,7 @@ def new_publish(): data = [] if module == 'Feature Finder': - + flag, data = get_feature_finder(vehicle, variant, language) elif module == 'Repair/Service Check Sheet': @@ -197,98 +197,119 @@ def new_publish(): elif module == 'QWIK Service': flag, data = get_qwik_service(variant, language) CLEANR = re.compile('<.*?>') - CLEANR_back_slash = re.compile("\"") - ul_html='' - find_last_ul='' - + CLEANR_back_slash = re.compile("\"") + ul_html = '' + find_last_ul = '' + for dt in data: - if len(dt['consumables'])>0: - + if len(dt['consumables']) > 0: + for con in dt['consumables']: if con['content']: con['content'] = re.sub(CLEANR, '', con['content']) # if len(dt['pre_work'])>0: for pw in dt['pre_work']: - reg_str = "

" + reg_str = "

" reg_str1 = "

" if pw['content']: res = str(pw['content']).find('
') res1 = str(pw['content']).find('

') if res == 1: - pw['content'] = re.sub('

','',pw['content']) - pw['content'] = re.sub('
','',pw['content']) - pw['content'] = re.sub('

','

',pw['content'] ) - pw['content'] = re.sub('

','
',pw['content'] ) - cnverted_data = re.sub(CLEANR_back_slash,"'",pw['content']) + pw['content'] = re.sub( + '
', '', pw['content']) + pw['content'] = re.sub( + '
', '', pw['content']) + pw['content'] = re.sub( + '

', '

', pw['content']) + pw['content'] = re.sub( + '

', '
', pw['content']) + cnverted_data = re.sub( + CLEANR_back_slash, "'", pw['content']) pw['content'] = cnverted_data else: - pw['content'] = '
'+pw['content']+'
' - cnverted_data = re.sub(CLEANR_back_slash,"'",pw['content']) + pw['content'] = '
' + \ + pw['content']+'
' + cnverted_data = re.sub( + CLEANR_back_slash, "'", pw['content']) frappe.log_error(str('if')+pw['content']) pw['content'] = cnverted_data if res1 == 1: - pw['content'] = re.sub('
','',pw['content']) - pw['content'] = re.sub('
','',pw['content']) - pw['content'] = re.sub('

','

',pw['content'] ) - pw['content'] = re.sub('

','
',pw['content'] ) - cnverted_data = re.sub(CLEANR_back_slash,"'",pw['content']) + pw['content'] = re.sub( + '
', '', pw['content']) + pw['content'] = re.sub( + '
', '', pw['content']) + pw['content'] = re.sub( + '

', '

', pw['content']) + pw['content'] = re.sub( + '

', '
', pw['content']) + cnverted_data = re.sub( + CLEANR_back_slash, "'", pw['content']) pw['content'] = cnverted_data else: frappe.log_error(str('else')+pw['content']) - pw['content'] = '
'+pw['content']+'
' - cnverted_data = re.sub(CLEANR_back_slash,"'",pw['content']) + pw['content'] = '
' + \ + pw['content']+'
' + cnverted_data = re.sub( + CLEANR_back_slash, "'", pw['content']) frappe.log_error(str('if')+pw['content']) pw['content'] = cnverted_data - if dt['qwik_procedure']: for qp in dt['qwik_procedure']['LHS']: if qp['content']: - qp['content'] = re.sub('
    ', ul_html,qp['content'] ) - qp['content'] = re.sub('
  • ',li_html,qp['content']) - clsing_li_tag = re.sub('
  • ',cling_li,qp['content']) + qp['content'] = re.sub( + '
      ', ul_html, qp['content']) + qp['content'] = re.sub( + '
    • ', li_html, qp['content']) + clsing_li_tag = re.sub( + '
    • ', cling_li, qp['content']) qp['content'] = clsing_li_tag - res = re.sub(find_last_ul,cling_last,qp['content']) + res = re.sub( + find_last_ul, cling_last, qp['content']) qp['content'] = res - - cnverted_data = re.sub(CLEANR_back_slash,"'",qp['content']) + + cnverted_data = re.sub( + CLEANR_back_slash, "'", qp['content']) qp['content'] = cnverted_data - for qp_rhs in dt['qwik_procedure']['RHS']: if qp_rhs: - qp_rhs['content'] = re.sub('
        ', ul_html,qp_rhs['content'] ) - qp_rhs['content'] = re.sub('
      • ',li_html,qp_rhs['content']) - qp_rhs['content'] = re.sub('
      • ',cling_li,qp_rhs['content']) - qp_rhs['content'] = re.sub(find_last_ul,cling_last,qp_rhs['content']) - cnverted_data = re.sub(CLEANR_back_slash,"'",qp_rhs['content']) + qp_rhs['content'] = re.sub( + '
          ', ul_html, qp_rhs['content']) + qp_rhs['content'] = re.sub( + '
        • ', li_html, qp_rhs['content']) + qp_rhs['content'] = re.sub( + '
        • ', cling_li, qp_rhs['content']) + qp_rhs['content'] = re.sub( + find_last_ul, cling_last, qp_rhs['content']) + cnverted_data = re.sub( + CLEANR_back_slash, "'", qp_rhs['content']) qp_rhs['content'] = cnverted_data - - elif module == 'Training Information': # flag, data = get_training_information(vehicle, language) pass elif module == 'Mahindra Special Tool Information': - CLEANR_back_slash = re.compile("\"") + CLEANR_back_slash = re.compile("\"") html_code_ul = '
            ' - html_code_li = '
          • ' + html_code_li = '
          • ' flag, data = get_special_tool_information(vehicle) for dt in data: - if len(dt['instructions'])>0: + if len(dt['instructions']) > 0: for c_t in dt['instructions']: if c_t['content_type'] == 'Description': if c_t['content']: - c_t['content'] = html_code_ul+html_code_li+c_t['content']+'
          • '+'
          ' - cnverted_data = re.sub(CLEANR_back_slash,"'",c_t['content']) + c_t['content'] = html_code_ul + \ + html_code_li+c_t['content']+''+'
        ' + cnverted_data = re.sub( + CLEANR_back_slash, "'", c_t['content']) c_t['content'] = cnverted_data - elif module == 'PDI Inspection': pass @@ -312,7 +333,7 @@ def new_publish(): return {'status': 0, 'error': "Parameter's missing: " + str(e), 'data': None} -@frappe.whitelist(methods=['POST'],allow_guest = 1) +@frappe.whitelist(methods=['POST'], allow_guest=1) def new_publish1(): req = json.loads(frappe.request.data) try: @@ -323,7 +344,7 @@ def new_publish1(): language = req['language'] val = input_validation(req) - + if val != '' or val != "": return {"status": 0, "error": "Input parameter Missing: " + val} data = [] @@ -338,12 +359,17 @@ def new_publish1(): # BASE_PATH = BASE_URL + "/files/json_files/phase2/" + \ # str(vehicle) + '/' + str(language) + '/' + str(publish_type) + '/' - FULL_UPDATE_PATH = BASE_URL+ "/files/json_files/phase2/" + str(vehicle) + '/' + str(language) + '/' +"{}".format(publish_type)+"_Full_Update/" + FULL_UPDATE_PATH = BASE_URL + "/files/json_files/phase2/" + \ + str(vehicle) + '/' + str(language) + '/' + \ + "{}".format(publish_type)+"_Full_Update/" + + FULL_UPDATE_PATH_FILE = FULL_UPDATE_PATH + \ + vehicle.replace(' ', '-') + '-feature_finder_full_update' + '.json' + LATEST_GLOBAL_PATH = BASE_URL + "/files/json_files/phase2/" + \ + str(vehicle) + '/' + str(language) + '/' + "Global_Full_Update/" + LATEST_GLOBAL_FILE = LATEST_GLOBAL_PATH + \ + vehicle.replace(' ', '-') + '-feature_finder_full_update' + '.json' - FULL_UPDATE_PATH_FILE = FULL_UPDATE_PATH + vehicle.replace(' ', '-') + '-feature_finder_full_update' + '.json' - LATEST_GLOBAL_PATH = BASE_URL+ "/files/json_files/phase2/" + str(vehicle) + '/' + str(language) + '/' +"Global_Full_Update/" - LATEST_GLOBAL_FILE = LATEST_GLOBAL_PATH + vehicle.replace(' ', '-') + '-feature_finder_full_update' + '.json' - if module == 'Feature Finder': # if publish_type == 'Internal': if os.path.isfile(FULL_UPDATE_PATH_FILE): @@ -355,7 +381,7 @@ def new_publish1(): data = data.get('data') data = data.get(variant) else: - + with open(LATEST_GLOBAL_FILE) as outfile: data = json.load(outfile) # data = data['data'] @@ -364,8 +390,6 @@ def new_publish1(): data = data.get('data') data = data.get(variant) - - elif module == 'Repair/Service Check Sheet': with open(BASE_PATH + str(vehicle) + '-repair_check_sheet.json') as outfile: data = json.load(outfile) @@ -388,7 +412,7 @@ def new_publish1(): pass elif module == 'Mahindra Special Tool Information': - + with open(BASE_PATH + str(vehicle) + '-special_tool_information.json') as outfile: data = json.load(outfile) # data = data['data'] @@ -494,7 +518,7 @@ def filter_publish_json(src_json, filter_cond): return filtered_json[0] except Exception as e: - frappe.throw("fil",str(e)) + frappe.throw("fil", str(e)) def input_validation(req): @@ -512,10 +536,8 @@ def input_validation(req): return sts - - @frappe.whitelist() def get_published_data(): data = frappe.db.sql("""select vehicle,variant,language,publish_type from `tabPublish` where not in (select vehicle,variant,language,publish_type from - `tabModule Publish Mapping`)""",as_dict=1) - return data \ No newline at end of file + `tabModule Publish Mapping`)""", as_dict=1) + return data diff --git a/smart_service/masters/doctype/role_master/role_master.json b/smart_service/masters/doctype/role_master/role_master.json index b587e4d..3d7c8a0 100644 --- a/smart_service/masters/doctype/role_master/role_master.json +++ b/smart_service/masters/doctype/role_master/role_master.json @@ -11,6 +11,7 @@ "column_break_ffrrr", "modules", "skill_id", + "active_status", "section_break_bkwnr", "module_name_configuration", "module_master_html" @@ -56,11 +57,17 @@ { "fieldname": "section_break_bkwnr", "fieldtype": "Section Break" + }, + { + "fieldname": "active_status", + "fieldtype": "Select", + "label": "Active Status", + "options": "Active\nInactive" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-10-17 18:03:13.331281", + "modified": "2023-11-30 10:57:17.784350", "modified_by": "Administrator", "module": "Masters", "name": "Role Master", 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 8cc7c72..e97154d 100644 --- a/smart_service/phase_2/doctype/feature_finder/feature_finder.js +++ b/smart_service/phase_2/doctype/feature_finder/feature_finder.js @@ -944,7 +944,7 @@ function custom_tab_html(frm) { { label: 'Value', fieldname: 'value', - fieldtype: 'Data', + fieldtype: 'Small Text', default: spec_dialog_value.value }, // { @@ -985,7 +985,7 @@ function custom_tab_html(frm) { }, callback: function (r) { if (r.message.status == "success") { - + frappe.msgprint("Submited data will be auto saved") cur_frm.reload_doc() cur_frm.refresh() } @@ -1077,6 +1077,7 @@ function custom_tab_html(frm) { }, callback: function (r) { if (r.message.status == "success") { + frappe.msgprint("Submited data will be auto saved") cur_frm.reload_doc() cur_frm.refresh() } @@ -1153,6 +1154,7 @@ function custom_tab_html(frm) { }, callback: function (r) { if (r.message.status == "success") { + frappe.msgprint("Submited data will be auto saved") cur_frm.reload_doc() cur_frm.refresh() } 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 94adc86..7a66d7f 100644 --- a/smart_service/phase_2/doctype/feature_finder/feature_finder.py +++ b/smart_service/phase_2/doctype/feature_finder/feature_finder.py @@ -105,7 +105,7 @@ def get_list_data(name, val): @frappe.whitelist() -def insert_spec_data(doc_name, values, tab_ref): +def insert_spec_data(doc_name, values, tab_ref=None): try: val = json.loads(values) get_count = frappe.db.sql("""select name from `tabFeature Finder Specification` where parent='%s' and feature_type='%s'""" % ( diff --git a/smart_service/transactions/doctype/publish/publish.py b/smart_service/transactions/doctype/publish/publish.py index 5df4bc8..aeaa997 100644 --- a/smart_service/transactions/doctype/publish/publish.py +++ b/smart_service/transactions/doctype/publish/publish.py @@ -528,10 +528,10 @@ def max_publish(doc): @frappe.whitelist() def variant(doctype, txt, searchfield, start, page_len, filters): vehicle = filters.get('vehicle') - return frappe.db.sql(""" select name,family_code,fuel,transmission,vehicle_segment,active_status + return frappe.db.sql(""" select name,family_code,fuel,transmission,vehicle_segment,active_status,drive FROM {0}.`tabVariant Mapping` where vehicle = "{1}" and (active_status like "%%%(txt)s%%" or vehicle_segment like "%%%(txt)s%%" or name like "%%%(txt)s%%" or variant like "%%%(txt)s%%" or - family_code like "%%%(txt)s%%" or fuel like "%%%(txt)s%%" or transmission like "%%%(txt)s%%") order by modified desc limit %(start)s, %(page_len)s """.format(current_db_name, vehicle) % {'txt': txt, 'start': start, 'page_len': page_len}) + family_code like "%%%(txt)s%%" or fuel like "%%%(txt)s%%" or transmission like "%%%(txt)s%%" or drive like "%%%(txt)s%%") order by modified desc limit %(start)s, %(page_len)s """.format(current_db_name, vehicle) % {'txt': txt, 'start': start, 'page_len': page_len}) @frappe.whitelist() diff --git a/smart_service/transactions/doctype/variant_mapping/variant_mapping.json b/smart_service/transactions/doctype/variant_mapping/variant_mapping.json index 5d270cc..5eda3c5 100644 --- a/smart_service/transactions/doctype/variant_mapping/variant_mapping.json +++ b/smart_service/transactions/doctype/variant_mapping/variant_mapping.json @@ -126,6 +126,7 @@ { "fieldname": "drive", "fieldtype": "Link", + "in_preview": 1, "in_standard_filter": 1, "label": "Drive", "options": "Drive", @@ -193,7 +194,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-08-03 18:15:04.709396", + "modified": "2023-11-30 10:25:25.713843", "modified_by": "Administrator", "module": "Transactions", "name": "Variant Mapping",