|
|
@ -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 |
|
|
|