Browse Source

torque.training info,publish changes

version2
venkata akhil 9 months ago
parent
commit
7ec7d3df88
  1. 3
      smart_service/apis/master_api.py
  2. 9
      smart_service/apis/utils.py
  3. 15
      smart_service/apis/v2/master.py
  4. 2
      smart_service/phase_2/doctype/module_publish_mapping/module_publish_mapping.json
  5. 48
      smart_service/phase_2/doctype/torque_manual/torque_manual.js
  6. 5
      smart_service/phase_2/doctype/torque_manual/torque_manual.json
  7. 2
      smart_service/phase_2/doctype/torque_manual/torque_manual.py
  8. 2
      smart_service/phase_2/doctype/torque_manual_details/torque_manual_details.json
  9. 47
      smart_service/phase_2/doctype/training_information/training_information.js
  10. 2
      smart_service/phase_2/doctype/training_information/training_information.json
  11. 53
      smart_service/phase_2/doctype/training_information/training_information.py
  12. 22
      smart_service/phase_2/doctype/training_information_content_reference/training_information_content_reference.json
  13. 18
      smart_service/transactions/doctype/publish/publish.js
  14. 6
      smart_service/transactions/doctype/publish/publish.json
  15. 266
      smart_service/transactions/doctype/publish/publish.py

3
smart_service/apis/master_api.py

@ -350,9 +350,8 @@ def old_variant(LSD, language):
return {"status": 0, "error": e, 'data': None}
@frappe.whitelist(methods=['POST'])
@frappe.whitelist(methods=['POST'],allow_guest = 1)
def variant(LSD, language, iid=None):
# frappe.log_error("variant")
date_format = "%Y-%m-%d %H:%M:%S.%f"
# if LSD != "null":
# try:

9
smart_service/apis/utils.py

@ -57,6 +57,15 @@ def check_mp4_ext(path):
return True
else:
return False
@frappe.whitelist()
def check_html_ext(path):
if path:
ext = path.split()[-1]
if ext.lower().endswith('.html'):
return True
else:
return False
@frappe.whitelist()

15
smart_service/apis/v2/master.py

@ -240,7 +240,7 @@ def new_publish_old():
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(
@ -255,12 +255,12 @@ def new_publish_old():
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'])
frappe.log_error(str('if')+pw['content'])
pw['content'] = cnverted_data
if dt['qwik_procedure']:
@ -341,13 +341,11 @@ def new_publish_old():
data = 'No Module found'
if flag:
frappe.log_error(str(data))
return {'status': 1, 'error': None, 'data': data}
else:
return {'status': 0, 'error': data, 'data': None}
except Exception as e:
frappe.log_error(str(e))
frappe.local.response['http_status_code'] = 400
return {'status': 0, 'error': "Parameter's missing: " + str(e), 'data': None}
@ -371,6 +369,7 @@ def new_publish():
publish_type = frappe.db.get_list(
'App Device', filters={'name': iid}, fields='publish_type')
if len(publish_type) > 0:
publish_type = publish_type[0]['publish_type']
else:
@ -436,7 +435,7 @@ 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/" + \
str(vehicle) + '/' + str(language) + '/' + \
"{}".format(publish_type)+"_Full_Update/"
@ -716,14 +715,12 @@ def input_validation(req):
sts = ""
i = 0
for key, value in req.items():
frappe.log_error("key"+str(key))
frappe.log_error("value"+str(value))
if value is None or value == "" or value == '':
if i != 0:
sts += ','
sts += str(key) + ""
i += 1
frappe.log_error(sts)
return sts

2
smart_service/phase_2/doctype/module_publish_mapping/module_publish_mapping.json

@ -159,7 +159,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-15 15:06:50.552181",
"modified": "2023-12-19 11:12:06.446425",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Module Publish Mapping",

48
smart_service/phase_2/doctype/torque_manual/torque_manual.js

@ -12,10 +12,17 @@ frappe.require('assets/smart_service/css/boostrap_table.css', () => {
frappe.ui.form.on('Torque Manual', {
refresh: function(frm) {
set_display_order(frm)
if (frm.doc.vehicle){
get_column_data(frm)
}
},
onload:function(frm){
if (frm.doc.vehicle){
get_column_data(frm)
}
@ -55,31 +62,31 @@ function set_display_order(frm){
function get_column_data(frm){
var selected_columns_for_grid=[]
frappe.call({
method: "smart_service.phase_2.doctype.torque_manual.torque_manual.get_column_details",
args: {vehicle: frm.doc.vehicle}
}).done((r) => {
let details = []
if(r.message.success == 1){
$.each(r.message.data, function(_i, e){
debugger
details.push({"columnid":e.column_id,"column_name":e.column_name});
debugger
details.push({"columnid":e.column_id,"column_name":e.column_name});
selected_columns_for_grid.push({"fieldname":e.column_id,"columns":1 })
})
console.log(details)
var res = $(cur_frm.fields_dict.column_details.wrapper).empty();
var html = ""
html = '<div class="table-responsive"><table id="tblEmployee" class="table table-striped"></table></div>'
$(res).append(html)
$('#tblEmployee').bootstrapTable({
var table_container = $(cur_frm.fields_dict.column_details.wrapper).empty();
var wrapper_html = ""
wrapper_html = '<div class="table-responsive"><table id="tblcolumdetails" class="table table-striped"></table></div>'
$(table_container).append(wrapper_html)
$('#tblcolumdetails').bootstrapTable({
data: details,
// height: 500,
pagination: false,
pagination: true,
pageSize: 10,
// pageList: [],
search: false,
search: true,
showExport: false,
exportTypes: ['json', 'xml', 'csv', 'txt', 'sql', 'excel', 'pdf'],
@ -102,10 +109,21 @@ function get_column_data(frm){
})
let value = {};
value['Torque Manual Details'] = selected_columns_for_grid
frappe.model.user_settings.save(frm.doctype, 'GridView', value)
.then((r) => {
frappe.model.user_settings[frm.doctype] = r.message || r;
var me = this;
cur_frm.refresh_field("torque_table")
});
}
})
}
}

5
smart_service/phase_2/doctype/torque_manual/torque_manual.json

@ -28,8 +28,7 @@
"default": "0",
"fieldname": "is_published",
"fieldtype": "Check",
"label": "Published",
"read_only": 1
"label": "Published"
},
{
"fieldname": "section_break_qg2b0",
@ -128,7 +127,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-15 18:31:16.172009",
"modified": "2023-12-21 11:12:41.126313",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Manual",

2
smart_service/phase_2/doctype/torque_manual/torque_manual.py

@ -48,7 +48,7 @@ class TorqueManual(Document):
@frappe.whitelist(allow_guest = 1)
def get_column_details(vehicle=None):
try:
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 = '{vehicle}' order by idx; ''', as_dict=1)
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 = '{vehicle}' order by idx; ''', as_dict=1)
return {"success":1,"data":torque_column_mapping}
except Exception as e:
return {"success":0,"data":None,msg:str(e)}

2
smart_service/phase_2/doctype/torque_manual_details/torque_manual_details.json

@ -82,7 +82,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-12-12 15:11:46.238422",
"modified": "2023-12-18 11:39:08.430406",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Manual Details",

47
smart_service/phase_2/doctype/training_information/training_information.js

@ -26,11 +26,11 @@ frappe.ui.form.on('Training Information', {
method: "smart_service.phase_2.doctype.training_information.training_information.extract_scrom_package",
args: {
data: frm.doc.name,
vehicle:frm.doc.vehicle
vehicle:frm.doc.vehicle,
language:frm.doc.language
},
callback: function (r) {
debugger
console.log(r.message, "----file validation size-------")
// if (r.message && r.message[0] == false) {
// if (r.message[1]) {
// frappe.validated = false;
@ -72,9 +72,8 @@ function set_display_order(frm){
}
frappe.db.count('Training Information',{
filters: {
"variant": cur_frm.doc.variant,
"language": frm.doc.language,
"vehicle": frm.doc.vehicle,
"vehicle": frm.doc.vehicle,
"language": frm.doc.language,
}
})
.then(count => {
@ -86,24 +85,22 @@ function set_display_order(frm){
}
});
}
// frappe.ui.form.on('Training Information Content Reference',{
// content_type: function (frm, cdt, cdn) {
// var select_value = locals[cdt][cdn]
// var x = select_value.idx - 1;
// let my_row = frm.fields_dict.content.grid.grid_rows[x];
// if (select_value.content_type == 'Image' || select_value.content_type == 'Video'){
// cur_frm.get_field("content").grid.grid_rows[x].columns.image_video.df.read_only = 0;
// cur_frm.get_field("content").grid.grid_rows[x].columns.content.df.read_only = 1;
// cur_frm.refresh_fields("content")
// }
// else {
// cur_frm.get_field("content").grid.grid_rows[x].columns.image_video.df.read_only = 1;
// cur_frm.get_field("content").grid.grid_rows[x].columns.content.df.read_only = 0;
// cur_frm.refresh_fields("content")
// }
// cur_frm.refresh_field("content");
// cur_frm.refresh_field();
// },
frappe.ui.form.on('Training Information Content Reference',{
topic: function (frm, cdt, cdn) {
var select_value = locals[cdt][cdn]
var x = select_value.idx - 1;
let my_row = frm.fields_dict.content.grid.grid_rows[x];
if (select_value.topic == 'SCROM' || select_value.topic == 'HTML'){
cur_frm.get_field("content").grid.grid_rows[x].columns.index_file_name.df.reqd = 1;
cur_frm.refresh_fields("content")
}
else {
cur_frm.get_field("content").grid.grid_rows[x].columns.index_file_name.df.reqd = 0;
cur_frm.refresh_fields("content")
}
cur_frm.refresh_field("content");
cur_frm.refresh_field();
},
// validate:function(frm){
// let task_index = row.docfields.findIndex(x => x.fieldname === "content");
// if (row.doc.asset_type == 'Image' || row.doc.asset_type == 'Video') {
@ -118,4 +115,4 @@ function set_display_order(frm){
// refresh_field();
// }
// })
})

2
smart_service/phase_2/doctype/training_information/training_information.json

@ -105,7 +105,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-15 15:38:53.271274",
"modified": "2023-12-20 11:13:21.452077",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Training Information",

53
smart_service/phase_2/doctype/training_information/training_information.py

@ -6,7 +6,7 @@ from frappe.model.document import Document
from frappe.utils import cstr
import zipfile
import os
from smart_service.apis.utils import check_png_ext, check_img_ext, check_zip_ext, check_pdf_ext, details_of_image, checking_image,check_mp4_ext,check_ppt_ext,get_file_size
from smart_service.apis.utils import check_png_ext, check_img_ext, check_zip_ext, check_pdf_ext, details_of_image, checking_image,check_mp4_ext,check_ppt_ext,get_file_size,check_html_ext
site_name = cstr(frappe.local.site)
BASE_URL = os.path.expanduser(
@ -99,42 +99,36 @@ class TrainingInformation(Document):
# return (ret, d['idx'])
@frappe.whitelist()
def extract_scrom_package(data,vehicle):
def extract_scrom_package(data,vehicle,language):
training_information = training_information_data(data)
frappe.log_error(str(training_information))
BASE_URL1 = os.path.expanduser(
"~") + "/frappe-bench/sites/" + site_name + "/public/files"
base_path = BASE_URL1 + "/" + "training" +"/"+ vehicle
scrom_path = base_path +"/"+ "scrom/"
scrom_file_url= ""
base_path = BASE_URL1 + "/" + "training" +"/"+ vehicle+"/"+language
scrom_path = base_path +"/"
scrom_file_url = ""
file_name = ""
for d in training_information['data']:
if d['file_url']:
# for ch in d['content']:
if d['topic'] == 'SCROM' and d['file_url']!=None:
scrom_folder_path =scrom_path+d['file_url'].split("/")[2].split(".")[0]+"/"
file_name = d['file_name']
if d['topic'] == 'SCROM' or d['topic'] == 'HTML' and d['file_url']!=None:
scrom_folder_path =scrom_path+'{}'.format(d['topic']+"/")+d['file_url'].split("/")[2].split(".")[0]+"/"
frappe.log_error('scrom_folder_path'+str(scrom_folder_path))
name = d['name']
if d['index_file_name']:
file_name = d['index_file_name']
if not os.path.exists(scrom_folder_path):
os.makedirs(scrom_folder_path)
if d['file_url']:
frappe.log_error(str(scrom_folder_path))
with zipfile.ZipFile(BASE_URL+d['file_url'], 'r') as zip_ref:
zip_ref.extractall(path=scrom_folder_path)
base_path_url = "/files/training/"+vehicle+"/scrom/"+ d['file_url'].split("/")[2].split(".")[0]+"/"
file_path_url="/files/training/"+vehicle+"/scrom/"+ d['file_url'].split("/")[2].split(".")[0]+"/"
# for file in os.listdir(scrom_folder_path):
# d = os.path.join(scrom_folder_path, file)
# if os.path.isdir(d):
# base_folder_name = d.split('/')[-1]
base_path_url = "/files/training/"+vehicle+'{}'.format(d['topic']+"/")+ d['file_url'].split("/")[2].split(".")[0]+"/"
file_path_url="/files/training/"+vehicle+'{}'.format(d['topic']+"/")+ d['file_url'].split("/")[2].split(".")[0]+"/"
for root, dirs, files in os.walk(scrom_folder_path):
if file_name in files:
base_folder_name = os.path.join(root, file_name)
scrom_file_url = base_folder_name.split("/public")[1:][0]
# return os.path.join(root, file_name)
frappe.log_error('scrom_file_url'+str(scrom_file_url))
update_base_path = frappe.db.sql(f"""update `tabTraining Information Content Reference` set base_path = '{base_path_url}', scrom_file_url ='{scrom_file_url}' where name='{name}'""")
return {"success":1,"data":data}
@ -150,7 +144,7 @@ def training_information_data(parent=None):
# `tabTraining Information` where name='{parent}' """, as_dict=1)
# for d in training_information_details:
training_information_details = frappe.db.sql(f"""select idx as 'display_order',name,topic,scrom_file_url,base_path,file_url,file_name from `tabTraining Information Content Reference`
training_information_details = frappe.db.sql(f"""select idx as 'display_order',name,topic,scrom_file_url,base_path,file_url,file_name,index_file_name from `tabTraining Information Content Reference`
where parent = '{parent}'
order by display_order ;""", as_dict=1)
@ -188,13 +182,26 @@ def file_validation_child(name, value=None):
if d['topic'] =="SCROM":
res = check_zip_ext(d['file_url'])
if d['topic'] == "HTML":
res = check_zip_ext(d['file_url'])
if res==True or res1==True:
valuess,idx = get_file_details(d['topic'],d['file_url'],value,name,1,d['idx'],d['name'])
else:
valuess,idx = delete_child_image(d['file_url'],value,name,1,d['idx'],d['name'])
if valuess==False:
return valuess,idx
if d['topic'] and d['index_file_name']:
ref=False
if d['topic'] =='SCROM':
ref = check_html_ext(d['index_file_name'])
if d['topic'] == 'HTML':
ref = check_html_ext(d['index_file_name'])
if ref == True:
return True
else:
frappe.throw("Index File Name Must Be In HTML Format")
return child_data
except Exception as e:
frappe.log_error("file validation child",frappe.get_traceback())

22
smart_service/phase_2/doctype/training_information_content_reference/training_information_content_reference.json

@ -11,7 +11,7 @@
"base_path",
"file_name",
"scrom_file_url",
"scrom_index_page"
"index_file_name"
],
"fields": [
{
@ -19,7 +19,8 @@
"fieldtype": "Select",
"in_standard_filter": 1,
"label": "Topic",
"options": "Heading\nPDF\nPPT\nSCROM\nVideo\nImage\nAnimation\nWeb Links\nHTML"
"options": "PDF\nPPT\nSCROM\nVideo\nImage\nAnimation\nWeb Links\nHTML",
"reqd": 1
},
{
"fieldname": "base_path",
@ -32,30 +33,33 @@
"fieldname": "file_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "File Name"
"label": "File Name",
"reqd": 1
},
{
"fieldname": "file_url",
"fieldtype": "Attach",
"label": "File Url"
"label": "File Url",
"mandatory_depends_on": "eval:doc.topic"
},
{
"fieldname": "scrom_file_url",
"fieldtype": "Data",
"fieldtype": "Long Text",
"hidden": 1,
"label": "Scrom File Url"
},
{
"fieldname": "scrom_index_page",
"fieldtype": "Data",
"fieldname": "index_file_name",
"fieldtype": "Long Text",
"in_list_view": 1,
"label": "Scrom Index Page"
"label": "Index File Name",
"mandatory_depends_on": "// eval:doc.topic =='SCROM'"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-12-12 13:48:55.828272",
"modified": "2023-12-21 10:38:23.351587",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Training Information Content Reference",

18
smart_service/transactions/doctype/publish/publish.js

@ -794,11 +794,21 @@ frappe.ui.form.on("Publish", {
!frm.doc.hasOwnProperty("feature_finder_publish") &&
!frm.doc.hasOwnProperty("qwik_service_publish") &&
!frm.doc.hasOwnProperty("special_tool_publish") &&
!frm.doc.hasOwnProperty("torque_information_publish") &&
!frm.doc.hasOwnProperty("torque_manual_publish") &&
!frm.doc.hasOwnProperty("training_information_publish")
) {
frappe.throw("No Data Found To Publish");
}
// if(
// ((!frm.doc.torque_manual_publish)&&(!frm.doc.torque_manual_publish_docs))||
// !frm.doc.training_information_publish ||
// !frm.doc.special_tool_publish ||
// !frm.doc.qwik_service_publish ||
// !frm.doc.feature_finder_publish ||
// !frm.doc.repair_checksheet_publish
// ){
// frappe.throw("No Data Found To Publish")
// }
},
variant_mapping: function (frm) {
setTimeout(function mysam() {
@ -1246,7 +1256,7 @@ frappe.ui.form.on("Publish", {
}, 100);
frm.set_df_property("vehicle", "set_only_once", "1");
frm.refresh_fields("vehicle");
if (frm.doc.publish_module == "Automotive System") {
// if (frm.doc.publish_module == "Automotive System") {
frappe.call({
method:
"smart_service.transactions.doctype.publish.publish.old_publish",
@ -1274,7 +1284,7 @@ frappe.ui.form.on("Publish", {
}
},
});
}
// }
if (frm.doc.publish_module == "Repair service") {
add_to_publish(frm);
}
@ -1751,7 +1761,7 @@ function add_training_information(frm) {
frm.doc.docstatus === 0 &&
frm.doc.publish_status == "To Publish" &&
frm.doc.publish_module == "Training Information"
) {
){
frm
.get_field("training_information_publish")
.grid.add_custom_button(__("Add to Publish"), function () {

6
smart_service/transactions/doctype/publish/publish.json

@ -412,6 +412,7 @@
"depends_on": "eval:doc.publish_module =='Torque Manual';",
"fieldname": "torque_manual_publish",
"fieldtype": "Table",
"hidden": 1,
"label": "Torque Manual Publish",
"options": "Torque Manual Publish Data"
},
@ -419,6 +420,7 @@
"depends_on": "eval:doc.publish_module =='Torque Manual';",
"fieldname": "torque_manual_publish_docs",
"fieldtype": "Table",
"hidden": 1,
"label": "Torque Manual Publish Docs",
"options": "Torque Manual Publish Docs"
},
@ -426,6 +428,7 @@
"depends_on": "eval:doc.publish_module =='Training Information';",
"fieldname": "training_information_publish",
"fieldtype": "Table",
"hidden": 1,
"label": "Training Information Publish",
"options": "Training Information Publish Data"
},
@ -433,6 +436,7 @@
"depends_on": "eval:doc.publish_module =='Training Information';",
"fieldname": "training_information_publish_docs",
"fieldtype": "Table",
"hidden": 1,
"label": "Training Information Publish Docs",
"options": "Training Information Publish Docs"
}
@ -440,7 +444,7 @@
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2023-12-15 18:57:55.788156",
"modified": "2023-12-20 16:11:51.876498",
"modified_by": "Administrator",
"module": "Transactions",
"name": "Publish",

266
smart_service/transactions/doctype/publish/publish.py

@ -51,103 +51,104 @@ class Publish(Document):
for v in variant:
self.variant_mapping_details = self.variant_mapping_details + \
str(v) + '\n'
km_mapping_record = frappe.db.sql("""select name from {0}.`tabKilometer Mapping` where variant_mapping = "{1}" and
language = '{2}'""".format(current_db_name, str(v), self.language), as_dict=1)
km_mapping_record = frappe.db.sql("""select name from `tabKilometer Mapping` where variant_mapping = "{0}" and
language = '{1}';""".format(str(v), self.language), as_dict=1)
for km_mapping in km_mapping_record:
self.kilometer_mapping_details = self.kilometer_mapping_details + \
str(km_mapping.name) + '\n'
def on_submit(self):
""" qwik_service """
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Qwik Service' and self.qwik_service_publish_docs:
qwik_service_publish(self.vehicle, self.vehicle_id, self.variant,
self.language, self.publish_type,
self.release_description, self.qwik_service_publish_docs)
frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}';""".format(self.name))
variant_list = frappe.db.sql(
f'''SELECT distinct(variant) as variant FROM `tabQwik Service Publish Docs` where parent = '{self.name}';''', as_dict=1)
update_publish_mapping(self.vehicle, variant_list,
self.language, self.publish_module, self.publish_type)
if self.publish_type == 'Global':
update_qwik_published_docs(self)
""" Feature Finder """
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Feature Finder' and self.feature_finder_publish_docs:
feature_finder_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type,
self.release_description, self.feature_finder_publish_docs, self.variant)
frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}';""".format(self.name))
variant_list = frappe.db.sql(
f'''SELECT distinct(variant) as variant FROM `tabFeature Finder Publish Docs` where parent = '{self.name}';''', as_dict=1)
update_publish_mapping(self.vehicle, variant_list,
self.language, self.publish_module, self.publish_type)
if self.publish_type == 'Global':
update_feature_published_docs(self)
""" Repair Service """
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Repair service' and self.repiar_checksheet_publish_docs:
repair_checksheet_publish(self.vehicle, self.vehicle_id,
try:
""" Feature Finder """
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Feature Finder' and self.feature_finder_publish_docs:
feature_finder_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type,
self.release_description, self.feature_finder_publish_docs, self.variant)
variant_list = frappe.db.sql(
f'''SELECT distinct(variant) as variant FROM `tabFeature Finder Publish Docs` where parent = '{self.name}';''', as_dict=1)
update_publish_mapping(self.vehicle, variant_list,
self.language, self.publish_module, self.publish_type)
if self.publish_type == 'Global':
update_feature_published_docs(self)
""" Repair Service """
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Repair service' and self.repiar_checksheet_publish_docs:
repair_checksheet_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type,
self.release_description, self.variant,
self.repiar_checksheet_publish_docs)
if self.publish_type == 'Global':
update_repair_published_docs(self)
""" qwik_service """
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Qwik Service' and self.qwik_service_publish_docs:
qwik_service_publish(self.vehicle, self.vehicle_id, self.variant,
self.language, self.publish_type,
self.release_description, self.qwik_service_publish_docs)
variant_list = frappe.db.sql(
f'''SELECT distinct(variant) as variant FROM `tabQwik Service Publish Docs` where parent = '{self.name}';''', as_dict=1)
update_publish_mapping(self.vehicle, variant_list,
self.language, self.publish_module, self.publish_type)
if self.publish_type == 'Global':
update_qwik_published_docs(self)
""" Special Tools Information """
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Special Tool' and self.special_tool_publish_docs:
special_tool_publish(self.vehicle, self.vehicle_id,
self.publish_type,
self.release_description,
self.special_tool_publish_docs)
if self.publish_type == 'Global':
update_special_tool_publish_docs(self)
""" Torque Manual """
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Torque Manual' and self.torque_manual_publish_docs:
torque_manual_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type,
self.release_description, self.variant,
self.repiar_checksheet_publish_docs)
frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}';""".format(self.name))
if self.publish_type == 'Global':
update_repair_published_docs(self)
""" Special Tools Information """
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Special Tool' and self.special_tool_publish_docs:
special_tool_publish(self.vehicle, self.vehicle_id,
self.publish_type,
self.release_description,
self.special_tool_publish_docs)
frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}';""".format(self.name))
if self.publish_type == 'Global':
update_special_tool_publish_docs(self)
""" Torque Manual """
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Torque Manual' and self.torque_manual_publish_docs:
torque_manual_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type,
self.release_description, self.torque_manual_publish_docs, self.variant)
self.release_description, self.torque_manual_publish_docs, self.variant)
variant_list = frappe.db.sql(
f'''SELECT distinct(variant) as variant FROM `tabTorque Manual Publish Docs` where parent = '{self.name}';''', as_dict=1)
update_publish_mapping(self.vehicle, variant_list,
self.language, self.publish_module, self.publish_type)
if self.publish_type == 'Global':
update_torque_manual_published_docs(self)
""" Training Information """
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Training Information' and self.training_information_publish_docs:
training_information_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type,
self.release_description, self.variant,
self.training_information_publish_docs)
# if not self.training_information_publish_docs:
# frappe.throw("no data added")
if self.publish_type == 'Global':
update_training_published_docs(self)
""" Update Publish status """
frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}';""".format(self.name))
variant_list = frappe.db.sql(
f'''SELECT distinct(variant) as variant FROM `tabTorque Manual Publish Docs` where parent = '{self.name}';''', as_dict=1)
update_publish_mapping(self.vehicle, variant_list,
self.language, self.publish_module, self.publish_type)
if self.publish_type == 'Global':
update_torque_manual_published_docs(self)
""" Training Information """
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Training Information' and self.training_information_publish_docs:
training_information_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type,
self.release_description, self.variant,
self.training_information_publish_docs)
frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}';""".format(self.name))
if self.publish_type == 'Global':
update_training_published_docs(self)
""" Update Vehicle and language Publihs Status """
if self.publish_type == 'Internal':
frappe.db.sql(
'''update `tabVehicle` set internal_publish = 1 where vehicle= '{0}'; '''.format(self.vehicle))
if self.publish_type == 'Internal':
frappe.db.sql(
'''update `tabVehicle` set internal_publish = 1 where vehicle= '{0}'; '''.format(self.vehicle))
frappe.db.sql(
'''update `tabCustom Languages` set internal_publish = 1 where lang_code= '{0}'; '''.format(self.language))
frappe.db.sql(
'''update `tabCustom Languages` set internal_publish = 1 where lang_code= '{0}'; '''.format(self.language))
else:
frappe.db.sql(
'''update `tabVehicle` set global_publish = 1 where vehicle= '{0}'; '''.format(self.vehicle))
frappe.db.sql(
'''update `tabCustom Languages` set global_publish = 1 where lang_code= '{0}'; '''.format(self.language))
else:
frappe.db.sql(
'''update `tabVehicle` set global_publish = 1 where vehicle= '{0}'; '''.format(self.vehicle))
frappe.db.sql(
'''update `tabCustom Languages` set global_publish = 1 where lang_code= '{0}'; '''.format(self.language))
except Exception as e:
frappe.throw(str(e))
def on_cancel(self):
""" Published document should not allow to cancel """
@ -161,9 +162,9 @@ def update_procedure(vehicle, lang, publish_type, doc):
current_db_name = frappe.conf.get("db_name")
procedure_status = frappe.db.sql("""select p.name,p.update_procedure_status,pro.name,p.variant_mapping,p.system,p.sub_system,p.asset_category,
p.item_category,p.variant,p.procedure_link,p.procedure_status,pro.name,pro.workflow_state
from {0}.`tabPublish_Docs` as p,{0}.`tabProcedure` as pro
where p.parent = "{1}" and p.procedure_link = pro.name and pro.workflow_state != p.update_procedure_status
and p.procedure_link is not null""".format(current_db_name, doc.name), as_dict=1)
from `tabPublish_Docs` as p,`tabProcedure` as pro
where p.parent = "{0}" and p.procedure_link = pro.name and pro.workflow_state != p.update_procedure_status
and p.procedure_link is not null""".format(doc.name), as_dict=1)
l = len(procedure_status)
if procedure_status:
for x in procedure_status:
@ -209,27 +210,6 @@ def update_procedure(vehicle, lang, publish_type, doc):
""" Generate Publish versions """
def update_qwik_published_docs(self):
try:
for d in self.qwik_service_publish_docs:
frappe.db.sql(
"""UPDATE `tabQwik Service` set is_published=1 where name='{0}'; """.format(d.parent1))
frappe.db.commit()
except Exception as ex:
return str(ex)
def update_torque_manual_published_docs(self):
try:
for d in self.torque_manual_publish_docs:
frappe.db.sql(
''' update `tabTorque Manual` set is_published=1 where name='{0}';'''.format(d.parent1))
frappe.db.commit()
except Exception as e:
raise e
def update_publish_mapping(vehicle, variant_list, language, module, publish_type):
try:
@ -666,7 +646,7 @@ def update_feature_published_docs(self):
try:
for d in self.feature_finder_publish_docs:
frappe.db.sql(
"""UPDATE `tabFeature Finder` set is_published=1 where name='{0}';""".format(d.parent1))
''' update `tabFeature Finder` set is_published=1 where name='{0}';'''.format(d.parent1))
frappe.db.commit()
except Exception as e:
@ -678,30 +658,50 @@ def update_repair_published_docs(self):
for d in self.repiar_checksheet_publish_docs:
frappe.db.sql(
"""UPDATE `tabRepair Service Mapping` set published=1 where name='{0}';""".format(d.parent_name))
''' update `tabRepair Service Mapping` set published=1 where name='{0}';'''.format(d.parent_name))
frappe.db.commit()
except Exception as e:
frappe.throw(str(e))
def update_qwik_published_docs(self):
try:
for d in self.qwik_service_publish_docs:
frappe.db.sql(
''' update `tabQwik Service` set is_published=1 where name='{0}'; '''.format(d.parent1))
frappe.db.commit()
except Exception as ex:
return str(ex)
def update_special_tool_publish_docs(self):
try:
for d in self.special_tool_publish_docs:
frappe.db.sql(
"""UPDATE `tabSpecial Tool Information` set published=1 where name='{0}';""".format(d.parent1))
''' update `tabSpecial Tool Information` set published=1 where name='{0}';'''.format(d.parent1))
frappe.db.commit()
except Exception as e:
frappe.throw(str(e))
def update_training_published_docs(self):
def update_torque_manual_published_docs(self):
try:
for d in self.training_information_publish:
for d in self.torque_manual_publish_docs:
frappe.db.sql(
"""UPDATE `tabTraining Information` set published=1 where name='{0}';""".format(d.parent1))
''' update `tabTorque Manual` set is_published=1 where name='{0}';'''.format(d.parent1))
frappe.db.commit()
except Exception as e:
raise e
def update_training_published_docs(self):
try:
for d in self.training_information_publish_docs:
frappe.db.sql(
''' update `tabTraining Information` set is_published=1 where name='{0}';'''.format(d.parent1))
frappe.db.commit()
except Exception as e:
frappe.throw(str(e))
@ -762,13 +762,16 @@ def repair_checksheet_publish(vehicle, vehicle_id,
""" Create Folder For Publish """
create_publish_folders(folder_url)
file_path = folder_url + "/" + publish_type + "/" + \
vehicle.replace(' ', '-') + '-repair_check_sheet' + '.json'
# full_update_folder_url = folder_url + "/" + "{}".format(publish_type)+"_Full_Update"
global_file_path = folder_url + "/" + 'Global' + "/" + \
vehicle.replace(' ', '-') + '-repair_check_sheet' + '.json'
check_inter_file = folder_url + "/" + 'Internal' + "/" + \
vehicle.replace(' ', '-') + '-repair_check_sheet' + '.json'
""" Append Published Data to Json """
logger.info(
f'Repair Checksheet Data Append Start::{vehicle}-{language}-{publish_type}')
@ -783,9 +786,9 @@ def repair_checksheet_publish(vehicle, vehicle_id,
'''update existing global json file'''
if os.path.isfile(global_file_path) and publish_type == 'Internal':
if os.path.isfile(global_file_path):
with open(global_file_path) as f:
published_data = json.load(f)
# if os.path.isfile(global_file_path):
with open(global_file_path) as f:
published_data = json.load(f)
for i in parent:
repair_checksheet = repair_checksheet_data(vehicle, language,
publish_type, i.parent_name)
@ -846,6 +849,7 @@ def repair_checksheet_publish(vehicle, vehicle_id,
vehicle.replace(' ', '-') + '-repair_check_sheet' + '.json'
if os.path.isfile(internal_check):
os.remove(internal_check)
if publish_repair_checksheet == 1:
""" Save publish file """
@ -1502,12 +1506,13 @@ def torque_manual_publish(vehicle=None, vehicle_id=None,
torque_manual['data'][0])
else:
frappe.throw('failed to publish')
torque_manual_tmp = get_latest_data(
{'data': torque_manual_tmp}, {'data': []})
# torque_manual_tmp = get_latest_data(
# {'data': torque_manual_tmp}, {'data': []})
frappe.log_error('before'+str(torque_manual_tmp))
vehi_data = create_df(torque_manual_tmp)
latest_pub_data['data'] = vehi_data
if publish_type == "Global":
full_update_folder_url_internal = folder_url + "/" + "Internal_Full_Update"
""" Remove Internal Full Update File On Global Publish """
@ -1577,6 +1582,7 @@ def training_information_publish(vehicle, vehicle_id,
'''update existing global json file'''
if os.path.isfile(global_file_path) and publish_type == 'Internal':
frappe.log_error(str('Global Exits'))
if os.path.isfile(global_file_path):
with open(global_file_path) as f:
published_data = json.load(f)
@ -1627,6 +1633,7 @@ def training_information_publish(vehicle, vehicle_id,
'data': training_information_tmp1})
else:
for i in parent:
training_information = training_information_data(
vehicle, language, publish_type, i.parent1)
@ -1635,9 +1642,11 @@ def training_information_publish(vehicle, vehicle_id,
publish_training_information = 1
if len(training_information['data']):
training_information_tmp.append(
training_information['data'][0])
training_information['data'])
training_information_tmp = get_latest_data(
{'data': training_information_tmp}, {'data': []})
frappe.log_error(str(training_information_tmp))
if publish_type == "Global":
""" Remove Internal File On Global Publish """
@ -1652,8 +1661,8 @@ def training_information_publish(vehicle, vehicle_id,
with open(file_path, 'w') as outfile:
outfile.write(json.dumps(vehicle_data, indent=4, default=str))
with open(file_path, 'w') as outfile:
outfile.write(json.dumps(vehicle_data, indent=4, default=str))
# with open(file_path, 'w') as outfile:
# outfile.write(json.dumps(vehicle_data, indent=4, default=str))
return 1, file_path
@ -1991,7 +2000,7 @@ def torque_manual_data(vehicle=None, language=None,
for t in torque_manual_details:
t['torque_table'] = frappe.db.sql('''select name,col1,col2,col3,col4,col5,col6,col7,col8,col9,col10,idx as display_order from
`tabTorque Manual Details` where parent = '%s' order by idx;''' % (t['name']), as_dict=1)
logger.info(
f"end of Torque Manual data {variant} - {language}")
success_reponse['data'] = torque_manual_details
@ -2020,7 +2029,7 @@ def training_information_data(vehicle=None, language=None,
and language = '{language}'and name='{parent}'; """, as_dict=1)
for d in training_information_details:
d['content'] = frappe.db.sql(f"""select idx as 'display_order',topic as file_type,case when topic != 'SCROM' then file_url
d['content'] = frappe.db.sql(f"""select idx as 'display_order',topic as file_type,case when topic != 'SCROM' and topic != 'HTML' then file_url
else scrom_file_url end as file_url,file_name from `tabTraining Information Content Reference`
where parent = '{d['name']}' order by display_order ;""", as_dict=1)
@ -2114,7 +2123,6 @@ def get_qwik_service(variant=None, language_label=None):
try:
data = frappe.db.sql("""select * from `tabQwik Service` where variant='%s'
and language = '%s' and is_published = '%s';""" % (variant, language_label, 0), as_dict=1)
return data
except Exception as e:
return e

Loading…
Cancel
Save