@ -1,3 +1,4 @@
from frappe . utils import cstr
import frappe
import re
from urllib import request
@ -8,10 +9,9 @@ import html
import os
import shutil
import zipfile
success_reponse = { " status " : 1 , " data " : " " , " message " : " " }
from frappe . utils import cstr
site_name = cstr ( frappe . local . site )
BASE_URL = os . path . expanduser (
" ~ " ) + " /frappe-bench/sites/ " + site_name + " /public "
@ -383,11 +383,14 @@ def new_publish():
" {} " . format ( publish_type ) + " _Full_Update/ "
FULL_UPDATE_PATH_FILE = FULL_UPDATE_PATH + \
vehicle . replace ( ' ' , ' - ' ) + ' -feature_finder_full_update ' + ' .json '
vehicle . replace ( ' ' , ' - ' ) + \
' -feature_finder_full_update ' + ' .json '
LATEST_GLOBAL_PATH = BASE_URL + " /files/json_files/phase2/ " + \
str ( vehicle ) + ' / ' + str ( language ) + ' / ' + " Global_Full_Update/ "
str ( vehicle ) + ' / ' + str ( language ) + \
' / ' + " Global_Full_Update/ "
LATEST_GLOBAL_FILE = LATEST_GLOBAL_PATH + \
vehicle . replace ( ' ' , ' - ' ) + ' -feature_finder_full_update ' + ' .json '
vehicle . replace ( ' ' , ' - ' ) + \
' -feature_finder_full_update ' + ' .json '
# if publish_type == 'Internal':
if os . path . isfile ( FULL_UPDATE_PATH_FILE ) :
@ -432,8 +435,6 @@ def new_publish():
data = data . get ( ' data ' )
elif module == ' QWIK Service ' :
frappe . log_error ( str ( publish_type ) )
FULL_UPDATE_PATH = BASE_URL + " /files/json_files/phase2/ " + \
@ -443,7 +444,8 @@ def new_publish():
FULL_UPDATE_PATH_FILE = FULL_UPDATE_PATH + \
vehicle . replace ( ' ' , ' - ' ) + ' -qwik_service_full_update.json '
LATEST_GLOBAL_PATH = BASE_URL + " /files/json_files/phase2/ " + \
str ( vehicle ) + ' / ' + str ( language ) + ' / ' + " Global_Full_Update/ "
str ( vehicle ) + ' / ' + str ( language ) + \
' / ' + " Global_Full_Update/ "
LATEST_GLOBAL_FILE = LATEST_GLOBAL_PATH + \
vehicle . replace ( ' ' , ' - ' ) + ' -qwik_service_full_update.json '
@ -527,7 +529,6 @@ def new_publish():
' / ' + " Global_Full_Update/ "
LATEST_GLOBAL_FILE = LATEST_GLOBAL_PATH + \
vehicle . replace ( ' ' , ' - ' ) + ' -torque_manual_full_update.json '
# if publish_type == 'Internal':
if os . path . isfile ( FULL_UPDATE_PATH_FILE ) :
with open ( FULL_UPDATE_PATH_FILE ) as outfile :
data = json . load ( outfile )
@ -537,17 +538,14 @@ def new_publish():
data = data . get ( ' data ' )
data = data . get ( variant )
else :
with open ( LATEST_GLOBAL_FILE ) as outfile :
data = json . load ( outfile )
# data = data['data']
# filter_json = filter_publish_json(data, variant)
# data = filter_json
data = data . get ( ' data ' )
data = data . get ( variant )
torque_column_mapping = frappe . db . sql (
f ''' select idx as display_order, concat( ' col ' ,idx) as column_id,column_name from `tabTorque Column Mapping` where parent = ' { variant } ' order by idx; ''' , as_dict = 1 )
data = { ' torque_manual_mapping ' : torque_column_mapping , ' torque_manual_data ' : data }
f ''' select idx as display_order, concat( ' col ' ,idx) as column_id,column_name from `tabTorque Column Mapping` where parent = ' { vehicle } ' order by idx; ''' , as_dict = 1 )
data = { ' torque_manual_mapping ' : torque_column_mapping ,
' torque_manual_data ' : data }
return { ' status ' : 1 , ' error ' : None , ' data ' : data }
@ -585,8 +583,6 @@ def get_qwik_service(variant, language):
parent = ' %s ' & & content_type = ' Tools ' order by display_order ; ''' % (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)
LHS = frappe . db . sql ( ''' select idx as ' display_order ' ,side,level,content from `tabQwik Procedure`
where parent = ' %s ' and side = ' LHS ' ; ''' % (p[ ' name ' ]), as_dict=1)
RHS = frappe . db . sql ( ''' select idx as ' display_order ' ,side,level,content from `tabQwik Procedure`
@ -601,12 +597,24 @@ def get_qwik_service(variant, language):
@frappe . whitelist ( methods = [ " POST " ] , allow_guest = 1 )
def get_torque_information ( variant , language ) :
try :
torque_information_details = frappe . db . sql ( ''' select name,variant,vehicle,language,active_status,category,sub_category,display_order,my_id,keywords
torque_manual_details = frappe . db . sql ( ''' select name,variant,vehicle,language,active_status,category,sub_category,display_order,keywords,my_id
from ` tabTorque Manual ` where variant = ' %s ' & & language = ' %s ' ; ''' % (variant, language), as_dict=1)
for t in torque_information_details :
t [ ' torque_table ' ] = frappe . db . sql ( ''' select idx as ' display_order ' ,fastener_description,specification,qty,torque_nm,remark from
` tabTorque Manual Details ` where parent = ' %s ' order by display_order ; ''' % (t[ ' name ' ]), as_dict=1)
return True , torque_information_details
for t in torque_manual_details :
t [ ' torque_table ' ] = frappe . db . sql ( ''' select name,idx as display_order from
` tabTorque Manual Details ` where parent = ' %s ' order by idx ; ''' % (t[ ' name ' ]), as_dict=1)
for d in t [ ' torque_table ' ] :
torque_data = frappe . db . sql ( ''' select col1,col2,col3,col4,col5,col6,col7,col8,col9,col10 from
` tabTorque Manual Details ` where name = ' %s ' order by idx ; ''' % (d[ ' name ' ]), as_dict=1)
# return torque_data
tor_list = [ ]
for i in torque_data :
for k , v in i . items ( ) :
tor_list . append ( { ' column_title ' : k , ' column_value ' : v } )
d [ ' torque_data ' ] = tor_list
success_reponse [ ' data ' ] = torque_manual_details
return success_reponse
except Exception as e :
return False , e