Browse Source

changes in variant mapping

version2
venkataakhil 10 months ago
parent
commit
39ea33ca60
  1. 184
      smart_service/apis/v2/master.py
  2. 9
      smart_service/masters/doctype/role_master/role_master.json
  3. 6
      smart_service/phase_2/doctype/feature_finder/feature_finder.js
  4. 2
      smart_service/phase_2/doctype/feature_finder/feature_finder.py
  5. 4
      smart_service/transactions/doctype/publish/publish.py
  6. 3
      smart_service/transactions/doctype/variant_mapping/variant_mapping.json

184
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="""<style>
# ul {
# margin: 0.75em 0;
# padding: 0 1em;
# list-style: none;
# }
# li:before {
# content: "";
# border-color: transparent #FF0000;
# border-style: solid;
# border-width: 0.35em 0 0.35em 0.45em;
# display: block;
# height: 0;
# width: 0;
# left: -1em;
# top: 0.9em;
# position: relative;
# }
# ul {
# margin: 0.75em 0;
# padding: 0 1em;
# list-style: none;
# }
# li:before {
# content: "";
# border-color: transparent #FF0000;
# border-style: solid;
# border-width: 0.35em 0 0.35em 0.45em;
# display: block;
# height: 0;
# width: 0;
# left: -1em;
# top: 0.9em;
# position: relative;
# }
# </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='<ul style="list-style-type: none; padding-left: 0px;"><span style="width: 0;height: 0;border-top: 6px solid transparent;border-left: 8px solid red;border-bottom: 6px solid transparent;position: absolute;margin-top: 3px;"></span>'
li_html='<li style="margin-left: 15px;padding: 0px 1px 5px 0px;"data-list=\"bullet\">'
cling_li='</li><span style="width: 0;height: 0;border-top: 6px solid transparent;border-left: 8px solid red;border-bottom: 6px solid transparent;position: absolute;margin-top: 3px;"></span>'
cling_last='</ul>'
find_last_ul='<span style="width: 0;height: 0;border-top: 6px solid transparent;border-left: 8px solid red;border-bottom: 6px solid transparent;position: absolute;margin-top: 3px;"></span></ul>'
CLEANR_back_slash = re.compile("\"")
ul_html = '<ul style="list-style-type: none; padding-left: 0px;"><span style="width: 0;height: 0;border-top: 6px solid transparent;border-left: 8px solid red;border-bottom: 6px solid transparent;position: absolute;margin-top: 3px;"></span>'
li_html = '<li style="margin-left: 15px;padding: 0px 1px 5px 0px;"data-list=\"bullet\">'
cling_li = '</li><span style="width: 0;height: 0;border-top: 6px solid transparent;border-left: 8px solid red;border-bottom: 6px solid transparent;position: absolute;margin-top: 3px;"></span>'
cling_last = '</ul>'
find_last_ul = '<span style="width: 0;height: 0;border-top: 6px solid transparent;border-left: 8px solid red;border-bottom: 6px solid transparent;position: absolute;margin-top: 3px;"></span></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 = "<p>"
reg_str = "<p>"
reg_str1 = "<div>"
if pw['content']:
res = str(pw['content']).find('<div>')
res1 = str(pw['content']).find('<p>')
if res == 1:
pw['content'] = re.sub('<div>','',pw['content'])
pw['content'] = re.sub('</div>','',pw['content'])
pw['content'] = re.sub('<p>','<div style="color: #fff;margin:0px !important;">',pw['content'] )
pw['content'] = re.sub('</p>','</div>',pw['content'] )
cnverted_data = re.sub(CLEANR_back_slash,"'",pw['content'])
pw['content'] = re.sub(
'<div>', '', pw['content'])
pw['content'] = re.sub(
'</div>', '', pw['content'])
pw['content'] = re.sub(
'<p>', '<div style="color: #fff;margin:0px !important;">', pw['content'])
pw['content'] = re.sub(
'</p>', '</div>', pw['content'])
cnverted_data = re.sub(
CLEANR_back_slash, "'", pw['content'])
pw['content'] = cnverted_data
else:
pw['content'] = '<div style="color: #fff;margin:0px !important;">'+pw['content']+'</div>'
cnverted_data = re.sub(CLEANR_back_slash,"'",pw['content'])
pw['content'] = '<div style="color: #fff;margin:0px !important;">' + \
pw['content']+'</div>'
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('<div>','',pw['content'])
pw['content'] = re.sub('</div>','',pw['content'])
pw['content'] = re.sub('<p>','<div style="color: #fff;margin:0px !important;">',pw['content'] )
pw['content'] = re.sub('</p>','</div>',pw['content'] )
cnverted_data = re.sub(CLEANR_back_slash,"'",pw['content'])
pw['content'] = re.sub(
'<div>', '', pw['content'])
pw['content'] = re.sub(
'</div>', '', pw['content'])
pw['content'] = re.sub(
'<p>', '<div style="color: #fff;margin:0px !important;">', pw['content'])
pw['content'] = re.sub(
'</p>', '</div>', 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'] = '<div style="color: #fff;margin:0px !important;">'+pw['content']+'</div>'
cnverted_data = re.sub(CLEANR_back_slash,"'",pw['content'])
pw['content'] = '<div style="color: #fff;margin:0px !important;">' + \
pw['content']+'</div>'
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>', ul_html,qp['content'] )
qp['content'] = re.sub('<li data-list="bullet">',li_html,qp['content'])
clsing_li_tag = re.sub('</li>',cling_li,qp['content'])
qp['content'] = re.sub(
'<ul>', ul_html, qp['content'])
qp['content'] = re.sub(
'<li data-list="bullet">', li_html, qp['content'])
clsing_li_tag = re.sub(
'</li>', 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>', ul_html,qp_rhs['content'] )
qp_rhs['content'] = re.sub('<li data-list="bullet">',li_html,qp_rhs['content'])
qp_rhs['content'] = re.sub('</li>',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>', ul_html, qp_rhs['content'])
qp_rhs['content'] = re.sub(
'<li data-list="bullet">', li_html, qp_rhs['content'])
qp_rhs['content'] = re.sub(
'</li>', 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 = '<ul style="list-style-type: none; padding-left: 0px;"><span style="width: 0;height: 0;border-top: 6px solid transparent;border-left: 8px solid red;border-bottom: 6px solid transparent;position: absolute;margin-top: 3px;"></span>'
html_code_li = '<li style="margin-left: 15px;padding: 0px 1px 5px 0px;"data-list="bullet">'
html_code_li = '<li style="margin-left: 15px;padding: 0px 1px 5px 0px;"data-list="bullet">'
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']+'</li>'+'</ul>'
cnverted_data = re.sub(CLEANR_back_slash,"'",c_t['content'])
c_t['content'] = html_code_ul + \
html_code_li+c_t['content']+'</li>'+'</ul>'
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
`tabModule Publish Mapping`)""", as_dict=1)
return data

9
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",

6
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()
}

2
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'""" % (

4
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()

3
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",

Loading…
Cancel
Save