Browse Source

link field content update

master
Ubuntu 2 years ago
parent
commit
8cd6eb8d93
  1. 45
      smart_service/apis/update_validation.py

45
smart_service/apis/update_validation.py

@ -97,10 +97,13 @@ def check_vehicle_update(vehicle_list):
l_id = v['LanguageID'] l_id = v['LanguageID']
current_version = v['CurrentVersion'] current_version = v['CurrentVersion']
if publish_type == 'Internal': if publish_type == 'Internal':
publish_data = frappe.db.sql('''select name,CAST(version AS DECIMAL(10,2)) as version from {}.tabPublish where vehicle= '{}' and language='{}' and publish_type = '{}' and version > {} and vehicle_status = 'Active'; publish_data = frappe.db.sql('''select name,CAST(version AS DECIMAL(10,2)) as version from {}.tabPublish where vehicle= '{}'
and language='{}' and publish_type = '{}' and version > {} and vehicle_status = 'Active';
'''.format(current_db_name, vehicle, l_id, publish_type, current_version), as_dict=True) '''.format(current_db_name, vehicle, l_id, publish_type, current_version), as_dict=True)
else: else:
publish_data = frappe.db.sql('''select name,version,release_description as description from {}.tabPublish where vehicle= '{}' and language='{}' and publish_type= '{}' and version > {} and vehicle_status = 'Active'; '''.format(current_db_name, vehicle, l_id, publish_type, current_version), as_dict=True) publish_data = frappe.db.sql('''select name,version,release_description as description from {}.tabPublish where vehicle= '{}'
and language='{}' and publish_type= '{}' and version > {} and vehicle_status = 'Active'; '''.format(current_db_name, vehicle, l_id, publish_type,
current_version),as_dict=True)
if len(publish_data) > 0: if len(publish_data) > 0:
update_version = publish_data[-1]['version'] update_version = publish_data[-1]['version']
@ -165,8 +168,8 @@ def check_vehicle_update(vehicle_list):
current_db_name, d), as_dict=True) current_db_name, d), as_dict=True)
var_asset = frappe.db.sql( var_asset = frappe.db.sql(
'''SELECT category, attach_file as file, %s,idx as variant_asset_idx FROM %s.`tabVariant Mapping_Assets` where category<>'Technical Manual' and parent='%s' and language='%s';''' % ( '''SELECT category, attach_file as file, %s,idx as variant_asset_idx FROM %s.`tabVariant Mapping_Assets` where category<>'Technical Manual'
active_status_case, current_db_name, d, l_id), as_dict=True) and parent='%s' and language='%s';''' % (active_status_case, current_db_name, d, l_id), as_dict=True)
vari = vari[0] vari = vari[0]
if vari['active_status'] == 'Active': if vari['active_status'] == 'Active':
@ -179,9 +182,9 @@ def check_vehicle_update(vehicle_list):
# System data # System data
system_out = [] system_out = []
for i in appendDict[d]: for i in appendDict[d]:
sys = frappe.db.sql('''SELECT min(`tabSystem Mapping_Sub System`.idx) as systemdisplayorder,tabSystems.system_name,tabSystems.icon_file,tabSystems.myid,tabSystems.active_status sys = frappe.db.sql('''SELECT min(`tabSystem Mapping_Sub System`.idx) as systemdisplayorder,tabSystems.system_name,tabSystems.icon_file,
FROM {0}.tabSystems inner join {0}.`tabSystem Mapping_Sub System` on tabSystems.system_name = `tabSystem Mapping_Sub System`.systems where system_name = '{1}' group by system_name ;''' tabSystems.myid,tabSystems.active_status FROM {0}.tabSystems inner join {0}.`tabSystem Mapping_Sub System` on
.format(current_db_name, i), as_dict=True) tabSystems.system_name = `tabSystem Mapping_Sub System`.systems where system_name = '{1}' group by system_name ;'''.format(current_db_name, i), as_dict=True)
if len(sys) > 0: if len(sys) > 0:
sys = sys[0] sys = sys[0]
@ -191,18 +194,18 @@ def check_vehicle_update(vehicle_list):
sys['active_status'] = False sys['active_status'] = False
# System Assets # System Assets
sysassets = frappe.db.sql( sysassets = frappe.db.sql(
'''SELECT idx as systemdisplayorder, system_asset FROM {3}.`tabSystem Mapping_System Assets` where parent like '{0}%' and language='{1}' and systems='{2}';'''.format( '''SELECT idx as systemdisplayorder, system_asset FROM {3}.`tabSystem Mapping_System Assets` where parent like '{0}%' and language='{1}'
d, l_id, i, current_db_name), as_dict=True) and systems='{2}';'''.format(d, l_id, i, current_db_name), as_dict=True)
sys['Assets'] = sysassets sys['Assets'] = sysassets
# Sub system # Sub system
subsystem_out = [] subsystem_out = []
for j in appendDict[d][i]: for j in appendDict[d][i]:
subsys = frappe.db.sql('''select `tabSystem Mapping_Sub System`.idx as subSystemdisplayorder, systems,sub_systems, symptom, component, estimated_time, rts, mat, cover_image, `tabSub Systems`.myid, subsys = frappe.db.sql('''select `tabSystem Mapping_Sub System`.idx as subSystemdisplayorder, systems,sub_systems, symptom,
`tabSystem Mapping_Sub System`.active_status,`tabSystem Mapping_Sub System`.cover_image component, estimated_time, rts, mat, cover_image, `tabSub Systems`.myid,`tabSystem Mapping_Sub System`.active_status,
from {4}.`tabSystem Mapping_Sub System` inner join {4}.`tabSub Systems` on `tabSystem Mapping_Sub System`.sub_systems = `tabSub Systems`.name `tabSystem Mapping_Sub System`.cover_image from {4}.`tabSystem Mapping_Sub System` inner join {4}.`tabSub Systems` on
where `tabSystem Mapping_Sub System`.parent like '{0}-{3}%' and systems='{1}' and sub_systems='{2}' and `tabSystem Mapping_Sub System`.active_status = 'Active';'''.format( `tabSystem Mapping_Sub System`.sub_systems = `tabSub Systems`.name where `tabSystem Mapping_Sub System`.parent like '{0}-{3}%' and
d, i, j, l_id, current_db_name), as_dict=True) systems='{1}' and sub_systems='{2}' and `tabSystem Mapping_Sub System`.active_status = 'Active';'''.format(d, i, j, l_id, current_db_name), as_dict=True)
if len(subsys) > 0: if len(subsys) > 0:
subsys = subsys[0] subsys = subsys[0]
@ -212,15 +215,19 @@ def check_vehicle_update(vehicle_list):
subsys['active_status'] = False subsys['active_status'] = False
kms = frappe.db.sql( kms = frappe.db.sql(
'''SELECT kilometer as kilometer_name, idx as kilometer_IDX, applicable as kilometers_applicable FROM {}.`tabKilometer Mapping_Items` where sub_systems='{}' '''SELECT kilometer as kilometer_name, idx as kilometer_IDX, applicable as kilometers_applicable FROM {}.`tabKilometer Mapping_Items`
and parent Like '{}' and substring(parent,-5,2) = '{}' order by kilometer_IDX;'''.format(current_db_name, j, d+"%",l_id), as_dict=True) where sub_systems='{}' and parent Like '{}' and substring(parent,-5,2) = '{}' order by kilometer_IDX;'''.format(current_db_name, j, d+"%",l_id), as_dict=True)
subsys['Config Kilometer'] = kms subsys['Config Kilometer'] = kms
for k in appendDict[d][i][j]: for k in appendDict[d][i][j]:
proc_details = frappe.db.sql('''select procedure_name, step_name, content_type, GROUP_CONCAT(content) as content, GROUP_CONCAT(file) as file,GROUP_CONCAT(DISTINCT idx order by idx) as display_order, idx from {}.tabProcedure_Details proc_details = frappe.db.sql('''select procedure_name, step_name, content_type,
where parent ='{}' group by procedure_name,step_name,content_type,content order by idx asc; '''.format( GROUP_CONCAT(case when content_type='Link' Then system_id else content end) as content,
current_db_name, k), as_dict=True) GROUP_CONCAT(file) as file,GROUP_CONCAT(DISTINCT idx order by idx) as display_order, idx from {}.tabProcedure_Details
where parent ='{}' group by procedure_name,step_name,content_type,content order by idx asc; '''.format(current_db_name, k),
as_dict=True)
temp_data = get_parent_map(proc_details, 'procedure_name') temp_data = get_parent_map(proc_details, 'procedure_name')
procedure_status = frappe.db.sql( procedure_status = frappe.db.sql(
'''SELECT workflow_state FROM {1}.tabProcedure where name='{0}';'''.format( '''SELECT workflow_state FROM {1}.tabProcedure where name='{0}';'''.format(
k, current_db_name)) k, current_db_name))

Loading…
Cancel
Save