Browse Source

Training Information Publish Changes

version2
venkata akhil 9 months ago
parent
commit
7511792331
  1. 4
      smart_service/apis/master_api.py
  2. 49
      smart_service/apis/v2/master.py
  3. 3
      smart_service/masters/doctype/module_master/module_master.json
  4. 5
      smart_service/phase_2/doctype/module_publish_mapping/module_publish_mapping.json
  5. 2
      smart_service/phase_2/doctype/qwik_service/qwik_service.json
  6. 2
      smart_service/phase_2/doctype/qwik_service/qwik_service.py
  7. 2
      smart_service/phase_2/doctype/torque_manual/torque_manual.js
  8. 4
      smart_service/phase_2/doctype/torque_manual/torque_manual.py
  9. 21
      smart_service/phase_2/doctype/torque_manual_mapping/torque_manual_mapping.js
  10. 2
      smart_service/phase_2/doctype/torque_manual_mapping/torque_manual_mapping.json
  11. 3
      smart_service/phase_2/doctype/training_information/training_information.js
  12. 5
      smart_service/phase_2/doctype/training_information/training_information.json
  13. 4
      smart_service/phase_2/doctype/training_information/training_information.py
  14. 68
      smart_service/transactions/doctype/publish/publish.js
  15. 3
      smart_service/transactions/doctype/publish/publish.json
  16. 330
      smart_service/transactions/doctype/publish/publish.py
  17. 50
      smart_service/transactions/doctype/variant_mapping/variant_mapping.py

4
smart_service/apis/master_api.py

@ -369,7 +369,7 @@ def variant(LSD, language, iid=None):
modules = frappe.db.sql(f'''select automotive_system as 'Automotive System',tsb as 'TSB',fsa as 'FSA',tekalert as 'TEKalert',
feature_finder as 'Feature Finder',repairservice_check_sheet as 'Repair/Service Check Sheet',
mahindra_special_tool_information as 'Mahindra Special Tool Information',training_information as 'Training Information',
qwik_service as 'QWIK Service',pdi_inspection as 'PDI Inspection',torque_information_nm as 'Torque Information NM'
qwik_service as 'QWIK Service',pdi_inspection as 'PDI Inspection',torque_information_nm as 'Torque Information'
FROM `tabModule Publish Mapping` where vehicle= '{d['vehicle']}' and variant='{d['variant_name']}'
and language = "{language}" and publish_type = '{publish_type}';''', as_dict=1)
if modules:
@ -385,7 +385,7 @@ def variant(LSD, language, iid=None):
return {"status": 0, "error": e, 'data': None}
@frappe.whitelist(methods=['POST'])
@frappe.whitelist(methods=['POST'],allow_guest =1)
def app_modules(LSD):
date_format = "%Y-%m-%d %H:%M:%S.%f"
if LSD != "":

49
smart_service/apis/v2/master.py

@ -356,10 +356,12 @@ def new_publish():
try:
module = req['module']
iid = req['iid']
vehicle = req['vehicle']
vehicle_name = req['vehicle']
vehicle = req['vehicle'].replace(' ','-')
variant = req['variant']
language = req['language']
val = input_validation(req)
# if val != '' or val != "":
@ -373,7 +375,7 @@ def new_publish():
if len(publish_type) > 0:
publish_type = publish_type[0]['publish_type']
else:
return {"status": 0, "error": "Publish Type Not Set For: " + iid}
return {"status": 0, "error": "Publish Type Not Set For: " + iid,"data":None}
BASE_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + str(publish_type) + '/'
if module == 'Feature Finder':
@ -400,15 +402,14 @@ def new_publish():
# data = filter_json
data = data.get('data')
data = data.get(variant)
else:
elif os.path.isfile(LATEST_GLOBAL_FILE):
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)
else:
frappe.local.response['http_status_code'] = 200
return {'status': 0, 'error':"No Data Published", 'data':None }
elif module == 'Repair/Service Check Sheet':
FULL_UPDATE_FOLDER = BASE_URL + "/files/json_files/phase2/" + \
@ -427,12 +428,15 @@ def new_publish():
data = data.get('data')
# data = data.get(variant)
else:
elif os.path.isfile(LATEST_GLOBAL_FILE):
with open(LATEST_GLOBAL_FILE) as outfile:
data = json.load(outfile)
data = data.get('data')
else:
frappe.local.response['http_status_code'] = 200
return {'status': 0, 'error': "No Data Published", 'data':None }
elif module == 'QWIK Service':
@ -457,7 +461,7 @@ def new_publish():
# data = filter_json
data = data.get('data')
data = data.get(variant)
else:
elif os.path.isfile(LATEST_GLOBAL_FILE):
with open(LATEST_GLOBAL_FILE) as outfile:
data = json.load(outfile)
@ -466,6 +470,9 @@ def new_publish():
# data = filter_json
data = data.get('data')
data = data.get(variant)
else:
frappe.local.response['http_status_code'] = 200
return {'status': 0, 'error': "No Data Published", 'data':None }
elif module == 'Training Information':
FULL_UPDATE_FOLDER = BASE_URL + "/files/json_files/phase2/" + \
@ -483,12 +490,16 @@ def new_publish():
data = json.load(outfile)
data = data.get('data')
else:
elif os.path.isfile(LATEST_GLOBAL_FILE):
with open(LATEST_GLOBAL_FILE) as outfile:
data = json.load(outfile)
data = data.get('data')
else:
frappe.local.response['http_status_code'] = 200
return {'status': 0, 'error': "No Data Published", 'data':None }
elif module == 'Mahindra Special Tool Information':
FULL_UPDATE_PATH = BASE_URL + "/files/json_files/phase2/" + \
@ -507,11 +518,15 @@ def new_publish():
data = data.get('data')
else:
elif os.path.isfile(LATEST_GLOBAL_FILE):
with open(LATEST_GLOBAL_FILE) as outfile:
data = json.load(outfile)
data = data.get('data')
else:
frappe.local.response['http_status_code'] = 200
return {'status': 0, 'error': "No Data Published", 'data':None }
elif module == 'PDI Inspection':
pass
@ -531,18 +546,19 @@ def new_publish():
if os.path.isfile(FULL_UPDATE_PATH_FILE):
with open(FULL_UPDATE_PATH_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)
else:
elif os.path.isfile(LATEST_GLOBAL_FILE):
with open(LATEST_GLOBAL_FILE) as outfile:
data = json.load(outfile)
data = data.get('data')
data = data.get(variant)
else:
frappe.local.response['http_status_code'] = 200
return {'status': 0, 'error': "No Data Published", 'data':None }
frappe.log_error(str(vehicle_name))
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)
f'''select idx as display_order, concat('col',idx) as column_id,column_name from `tabTorque Column Mapping` where parent = "{vehicle_name}" order by idx; ''', as_dict=1)
data = {'torque_manual_mapping': torque_column_mapping,
'torque_manual_data': data}
@ -599,6 +615,7 @@ def get_torque_information(variant, language):
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)
frappe
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)

3
smart_service/masters/doctype/module_master/module_master.json

@ -1,5 +1,4 @@
{
"_liked_by": "[\"Administrator\"]",
"actions": [],
"allow_rename": 1,
"autoname": "format:{module_name}",
@ -49,7 +48,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-08-07 11:29:32.921688",
"modified": "2024-01-03 16:04:06.524640",
"modified_by": "Administrator",
"module": "Masters",
"name": "Module Master",

5
smart_service/phase_2/doctype/module_publish_mapping/module_publish_mapping.json

@ -124,8 +124,7 @@
"default": "0",
"fieldname": "torque_information_nm",
"fieldtype": "Check",
"label": "Torque Information NM",
"read_only": 1
"label": "Torque Information NM"
},
{
"fieldname": "publish_type",
@ -159,7 +158,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-19 11:12:06.446425",
"modified": "2024-01-04 11:51:34.301304",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Module Publish Mapping",

2
smart_service/phase_2/doctype/qwik_service/qwik_service.json

@ -146,7 +146,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-15 15:38:01.887540",
"modified": "2024-01-04 12:59:07.934085",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Qwik Service",

2
smart_service/phase_2/doctype/qwik_service/qwik_service.py

@ -26,6 +26,8 @@ class QwikService(Document):
self.my_id = 1
if self.keywords:
self.keywords=self.keywords.strip()
if not self.is_new() and self.is_published == 1:
self.is_published = 0
except Exception as e:
raise e

2
smart_service/phase_2/doctype/torque_manual/torque_manual.js

@ -20,7 +20,7 @@ frappe.ui.form.on('Torque Manual', {
},
onload:function(frm){
if (frm.doc.vehicle){
get_column_data(frm)

4
smart_service/phase_2/doctype/torque_manual/torque_manual.py

@ -7,6 +7,8 @@ from frappe.model.document import Document
class TorqueManual(Document):
def validate(self):
try:
if len(self.torque_table) == 0:
frappe.throw(str('Column Rows Cannot Not Be Empty'))
if self.is_new():
if self.vehicle and self.language:
check_exe=frappe.db.sql('''select * from `tabTorque Manual` where vehicle='%s' and language ='en' and name !='%s'; '''%(self.vehicle,self.name),as_dict=1)
@ -23,6 +25,8 @@ class TorqueManual(Document):
self.my_id = count[0][0] + 1
else:
self.my_id = 1
if not self.is_new() and self.is_published == 1:
self.is_published = 0
except Exception as e:
raise e

21
smart_service/phase_2/doctype/torque_manual_mapping/torque_manual_mapping.js

@ -45,6 +45,13 @@ frappe.ui.form.on('Torque Manual Mapping', {
if (frm.doc.torque_table_columns && frm.doc.torque_table_columns.length==10) {
$('[data-fieldname="torque_table_columns"]').find('.grid-add-row').css('display', 'none')
}
setTimeout(function () {
var header_label = document.getElementsByClassName('control-label')[2]
header_label.innerHTML+=" (<b>Max.Column:10</b>)"
}, 50);
},
after_save:function(frm){
if (frm.doc.torque_table_columns.length==10) {
@ -55,3 +62,17 @@ frappe.ui.form.on('Torque Manual Mapping', {
}
});
frappe.ui.form.on('Torque Column Mapping', {
column_name:function(frm,cdt,cdn) {
var existing_data = cur_frm.doc.torque_table_columns;
var row = locals[cdt][cdn]
debugger
},
before_torque_table_columns_remove: function(frm) {
msgprint("Changes will be Reflected Once Published");
}
});

2
smart_service/phase_2/doctype/torque_manual_mapping/torque_manual_mapping.json

@ -34,7 +34,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-15 16:17:58.889238",
"modified": "2023-12-26 14:07:54.081593",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Manual Mapping",

3
smart_service/phase_2/doctype/training_information/training_information.js

@ -87,6 +87,7 @@ function set_display_order(frm){
}
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];
@ -101,6 +102,8 @@ frappe.ui.form.on('Training Information Content Reference',{
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') {

5
smart_service/phase_2/doctype/training_information/training_information.json

@ -94,8 +94,7 @@
"default": "0",
"fieldname": "is_published",
"fieldtype": "Check",
"label": "Published",
"read_only": 1
"label": "Published"
},
{
"fieldname": "keywords",
@ -105,7 +104,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-20 11:13:21.452077",
"modified": "2023-12-21 23:07:53.691024",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Training Information",

4
smart_service/phase_2/doctype/training_information/training_information.py

@ -30,7 +30,9 @@ class TrainingInformation(Document):
self.my_id = count[0][0] + 1
else:
self.my_id = 1
# extract_scrom_package(self.name,self.vehicle)
if not self.is_new() and self.is_published == 1:
self.is_published = 0
except Exception as e:
raise e

68
smart_service/transactions/doctype/publish/publish.js

@ -147,7 +147,7 @@ frappe.ui.form.on("Publish", {
if (frm.doc.docstatus == 1 && frm.doc.publish_module == "Repair service") {
cur_frm.set_df_property("repiar_checksheet_publish_docs", "read_only", 1);
cur_frm.refresh_field("repiar_checksheet_publish_docs");
cur_frm.set_df_property("feature_finder_publish_docs", "hidden", 1);
cur_frm.set_df_property("repiar_checksheet_publish_docs", "hidden", 1);
cur_frm.remove_custom_button("Add To Publish");
if (frm.doc.repiar_checksheet_publish_docs.length > 0) {
frm.set_df_property("repiar_checksheet_publish_docs", "hidden", 0);
@ -166,7 +166,7 @@ frappe.ui.form.on("Publish", {
cur_frm.refresh_field("training_information_publish_docs");
cur_frm.set_df_property("training_information_publish_docs", "hidden", 1);
cur_frm.remove_custom_button("Add To Publish");
if (frm.doc.repiar_checksheet_publish_docs.length > 0) {
if (frm.doc.training_information_publish_docs.length > 0) {
frm.set_df_property("training_information_publish_docs", "hidden", 0);
frm.refresh_field("training_information_publish_docs");
cur_frm.set_df_property(
@ -175,8 +175,8 @@ frappe.ui.form.on("Publish", {
1
);
}
// cur_frm.set_df_property('repiar_checksheet_publish_docs','hidden',0)
// cur_frm.refresh_field('repiar_checksheet_publish_docs')
cur_frm.set_df_property('training_information_publish_docs','hidden',1)
cur_frm.refresh_field('training_information_publish_docs')
}
if (frm.doc.docstatus == 1 && frm.doc.publish_module == "Qwik Service") {
// cur_frm.set_df_property("kilometer_mapping_details", "hidden", 1);
@ -327,6 +327,7 @@ frappe.ui.form.on("Publish", {
// if(frm.doc.variant_mapping_details){
// get_variant_mapping(frm)
// }
setTimeout(function mysam() {
$('[data-fieldname="special_tool_publish"]').find('.grid-add-row').css('display', 'none')
$('[data-fieldname="qwik_service_publish"]').find('.grid-add-row').css('display', 'none')
@ -398,6 +399,8 @@ frappe.ui.form.on("Publish", {
if (frm.doc.publish_module == "Automotive System") {
//Jeci comment
cur_frm.set_df_property("system_mapping", "read_only", 1);
cur_frm.set_df_property("system_mapping", "hidden", 0);
cur_frm.fields_dict["system_mapping"].grid.wrapper
.find(".grid-add-row")
.hide();
@ -752,7 +755,7 @@ frappe.ui.form.on("Publish", {
// cur_frm.reload_doc()
}
else {
frappe.msgprint("Failed To Publish")
frappe.msgprint("Failed To Generate Publish Version")
}
},
@ -794,21 +797,11 @@ 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_manual_publish") &&
!frm.doc.hasOwnProperty("torque_information_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() {
@ -1247,7 +1240,9 @@ frappe.ui.form.on("Publish", {
frm.refresh_field("repair_checksheet_publish");
frm.set_df_property("training_information_publish", "hidden", 0);
frm.refresh_field("training_information_publish");
window.location.reload()
},
vehicle: function (frm) {
setTimeout(function mysam() {
@ -1443,6 +1438,9 @@ frappe.ui.form.on("Publish", {
}
);
}
else {
lang_set_first_time = false;
}
if (!lang_set_first_time && frm.doc.publish_module == "Repair service") {
frappe.confirm(
"This will clear all the data, are you sure you want to proceed?",
@ -1456,6 +1454,9 @@ frappe.ui.form.on("Publish", {
}
);
}
else {
lang_set_first_time = false;
}
if (!lang_set_first_time && frm.doc.publish_module == "Training Information") {
frappe.confirm(
"This will clear all the data, are you sure you want to proceed?",
@ -1469,6 +1470,25 @@ frappe.ui.form.on("Publish", {
}
);
}
else {
lang_set_first_time = false;
}
if (!lang_set_first_time && frm.doc.publish_module == "Special Tool") {
frappe.confirm(
"This will clear all the data, are you sure you want to proceed?",
() => {
// action to perform if Yes is selected
frm.set_value("special_tool_publish", null);
lang_set_first_time = false;
},
() => {
// action to perform if No is selected
}
);
}
else {
lang_set_first_time = false;
}
if (!lang_set_first_time && frm.doc.publish_module == "Feature Finder") {
frappe.confirm(
"This will clear all the data, are you sure you want to proceed?",
@ -1484,6 +1504,9 @@ frappe.ui.form.on("Publish", {
);
}
else {
lang_set_first_time = false;
}
if (!lang_set_first_time && frm.doc.publish_module == "Torque Manual") {
frappe.confirm(
"This will clear all the data, are you sure you want to proceed?",
@ -1499,6 +1522,9 @@ frappe.ui.form.on("Publish", {
);
}
else {
lang_set_first_time = false;
}
if (!lang_set_first_time && frm.doc.publish_module == "Qwik Service") {
frappe.confirm(
"This will clear all the data, are you sure you want to proceed?",
@ -1518,6 +1544,7 @@ frappe.ui.form.on("Publish", {
lang_set_first_time = false;
}
},
// auto_version_update: function (frm) {
// if (
// frm.doc.vehicle &&
@ -1761,7 +1788,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 () {
@ -1814,6 +1841,9 @@ function add_training_information(frm) {
}
}
});
if(!frm.doc.training_information_publish){
frappe.throw("No Data Found To Publish");
}
if (added) {
frappe.msgprint(__(added + " Doc(s) Added"));
cur_frm.set_df_property(
@ -2386,3 +2416,7 @@ function add_special_tool(frm) {
}
}
// function reload_page() {
// window.location.reload()
// }

3
smart_service/transactions/doctype/publish/publish.json

@ -128,6 +128,7 @@
"label": "System & Sub Systems"
},
{
"depends_on": "// eval:doc.publish_module == 'Automotive System';",
"fieldname": "system_mapping",
"fieldtype": "Table",
"label": "System Mapping",
@ -444,7 +445,7 @@
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2023-12-20 16:11:51.876498",
"modified": "2024-01-02 10:48:10.167584",
"modified_by": "Administrator",
"module": "Transactions",
"name": "Publish",

330
smart_service/transactions/doctype/publish/publish.py

@ -61,30 +61,33 @@ class Publish(Document):
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,
pub_file_res = 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,
pub_file_res = repair_checksheet_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type,
self.release_description, self.variant,
self.repiar_checksheet_publish_docs)
variant_list=None
update_publish_mapping(self.vehicle, variant_list,
self.language, self.publish_module, self.publish_type)
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,
pub_file_res = qwik_service_publish(self.vehicle, self.vehicle_id, self.variant,
self.language, self.publish_type,
self.release_description, self.qwik_service_publish_docs)
@ -97,17 +100,19 @@ class Publish(Document):
""" 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,
pub_file_res = special_tool_publish(self.vehicle, self.vehicle_id,
self.publish_type,
self.release_description,
self.special_tool_publish_docs)
variant_list=None
update_publish_mapping(self.vehicle, variant_list,
self.language, self.publish_module, self.publish_type)
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,
pub_file_res = torque_manual_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type,
self.release_description, self.torque_manual_publish_docs, self.variant)
@ -117,17 +122,22 @@ class Publish(Document):
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,
pub_file_res = 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")
variant_list=None
update_publish_mapping(self.vehicle, variant_list,
self.language, self.publish_module, self.publish_type)
if self.publish_type == 'Global':
update_training_published_docs(self)
""" Update Publish status """
frappe.db.sql(
@ -155,7 +165,7 @@ class Publish(Document):
if self.publish_status == "Published":
frappe.throw('You can not <b>cancel</b> a Published Document!')
def update_procedure(vehicle, lang, publish_type, doc):
""" To validate updated procedure status """
doc = frappe.get_doc("Publish", doc)
@ -209,98 +219,170 @@ def update_procedure(vehicle, lang, publish_type, doc):
""" Generate Publish versions """
def update_publish_mapping(vehicle, variant_list, language, module, publish_type):
try:
if module == 'Repair service':
variant_list = None
pub_data = frappe.db.get_list('Module Publish Mapping', filters={
"vehicle": vehicle,
"language": language,
"publish_type": publish_type
}, fields=['name'])
if len(pub_data) > 0:
for d in pub_data:
if d['name']:
frappe.db.sql(
f"""UPDATE `tabModule Publish Mapping` set repairservice_check_sheet='1',publish_type='{publish_type}'
where name ='{d['name']}';""", as_dict=1)
frappe.db.commit()
elif module == 'Training Information':
variant_list = None
pub_data = frappe.db.get_list('Module Publish Mapping', filters={
"vehicle": vehicle,
"language": language,
"publish_type": publish_type
}, fields=['name'])
if len(pub_data) > 0:
for d in pub_data:
if d['name']:
frappe.db.sql(
f"""UPDATE `tabModule Publish Mapping` set training_information='1',publish_type='{publish_type}'
where name ='{d['name']}'; """, as_dict=1)
frappe.db.commit()
elif module == 'Special Tool':
variant_list = None
pub_data = frappe.db.get_list('Module Publish Mapping', filters={
"vehicle": vehicle,
"language": language,
"publish_type": publish_type
}, fields=['name'])
if len(pub_data) > 0:
for d in pub_data:
if d['name']:
frappe.db.sql(
f"""UPDATE `tabModule Publish Mapping` set mahindra_special_tool_information='1',publish_type='{publish_type}'
where name ='{d['name']}';""", as_dict=1)
frappe.db.commit()
else:
frappe.log_error('variant_list' + str(variant_list))
get_variant = frappe.db.sql('''select name from `tabVariant Mapping` where vehicle = "{}"'''.format(vehicle),as_dict =1)
if module == 'Repair service' or module == 'Training Information' or module == 'Special Tool':
for vari in get_variant:
pub_data = frappe.db.get_list('Module Publish Mapping', filters={
"vehicle": vehicle,
"language": language,
"variant":vari['name'],
"publish_type": publish_type
}, fields=['name'])
if len(pub_data) > 0:
# for d in pub_data:
if pub_data[0]['name']:
doc = frappe.get_doc('Module Publish Mapping', pub_data[0]['name'])
# frappe.db.sql(
# f"""UPDATE `tabModule Publish Mapping` set training_information='1',publish_type='{publish_type}'
# where name ='{pub_data[0]['name']}'; """, as_dict=1)
# frappe.db.commit()
else:
doc = frappe.get_doc({
'doctype': 'Module Publish Mapping',
"vehicle": vehicle,
"variant": vari['name'],
"language": language,
"publish_type": publish_type
})
if module == 'Repair service':
doc.repairservice_check_sheet = 1
doc.tsb = 1
doc.fsa = 1
doc.tekalert = 1
# frappe.db.sql(
# f"""UPDATE `tabModule Publish Mapping` set training_information='1',publish_type='{publish_type}'
# where name ='{pub_data[0]['name']}'; """, as_dict=1)
# frappe.db.commit()
elif module == 'Training Information':
doc.training_information = 1
doc.tsb = 1
doc.fsa = 1
doc.tekalert = 1
elif module == 'Special Tool':
doc.mahindra_special_tool_information = 1
doc.tsb = 1
doc.fsa = 1
doc.tekalert = 1
doc.save()
elif module == 'Automotive System' or module == 'Feature Finder' or module == 'Qwik Service' or module == 'Torque Manual':
frappe.log_error(str(variant_list))
for v in variant_list:
variant = v['variant']
pub_data = frappe.db.get_list('Module Publish Mapping', filters={
"vehicle": vehicle,
"variant": variant,
"language": language,
"publish_type": publish_type
}, fields=['name'])
if pub_data:
doc = frappe.get_doc(
'Module Publish Mapping', pub_data[0]['name'])
else:
doc = frappe.get_doc({
'doctype': 'Module Publish Mapping',
pub_data = frappe.db.get_list('Module Publish Mapping', filters={
"vehicle": vehicle,
"variant": variant,
"language": language,
"publish_type": publish_type
})
if module == 'Automotive System':
doc.automotive_system = 1
doc.tsb = 1
doc.fsa = 1
doc.tekalert = 1
elif module == 'Feature Finder':
doc.feature_finder = 1
elif module == 'Qwik Service':
doc.qwik_service = 1
}, fields=['name'])
elif module == 'Torque Manual':
doc.torque_information_nm = 1
doc.save()
if pub_data:
doc = frappe.get_doc(
'Module Publish Mapping', pub_data[0]['name'])
else:
doc = frappe.get_doc({
'doctype': 'Module Publish Mapping',
"vehicle": vehicle,
"variant": variant,
"language": language,
"publish_type": publish_type
})
if module == 'Automotive System':
doc.automotive_system = 1
doc.tsb = 1
doc.fsa = 1
doc.tekalert = 1
elif module == 'Feature Finder':
doc.feature_finder = 1
doc.tsb = 1
doc.fsa = 1
doc.tekalert = 1
elif module == 'Qwik Service':
doc.qwik_service = 1
doc.tsb = 1
doc.fsa = 1
doc.tekalert = 1
elif module == 'Torque Manual':
doc.torque_information_nm = 1
doc.tsb = 1
doc.fsa = 1
doc.tekalert = 1
doc.save()
# if module == 'Repair service':
# variant_list = None
# pub_data = frappe.db.get_list('Module Publish Mapping', filters={
# "vehicle": vehicle,
# "language": language,
# "publish_type": publish_type
# }, fields=['name'])
# if len(pub_data) > 0:
# for d in pub_data:
# if d['name']:
# frappe.db.sql(
# f"""UPDATE `tabModule Publish Mapping` set repairservice_check_sheet='1',publish_type='{publish_type}'
# where name ='{d['name']}';""", as_dict=1)
# frappe.db.commit()
# elif module == 'Training Information':
# for vari in get_variant:
# pub_data = frappe.db.get_list('Module Publish Mapping', filters={
# "vehicle": vehicle,
# "language": language,
# "variant":vari['name'],
# "publish_type": publish_type
# }, fields=['name'])
# if len(pub_data) > 0:
# # for d in pub_data:
# if pub_data[0]['name']:
# frappe.db.sql(
# f"""UPDATE `tabModule Publish Mapping` set training_information='1',publish_type='{publish_type}'
# where name ='{pub_data[0]['name']}'; """, as_dict=1)
# frappe.db.commit()
# else:
# doc = frappe.get_doc({
# 'doctype': 'Module Publish Mapping',
# "vehicle": vehicle,
# "variant": vari['name'],
# "language": language,
# "publish_type": publish_type
# })
# doc.save()
# elif module == 'Special Tool':
# variant_list = None
# pub_data = frappe.db.get_list('Module Publish Mapping', filters={
# "vehicle": vehicle,
# "language": language,
# "publish_type": publish_type
# }, fields=['name'])
# if len(pub_data) > 0:
# for d in pub_data:
# if d['name']:
# frappe.db.sql(
# f"""UPDATE `tabModule Publish Mapping` set mahindra_special_tool_information='1',publish_type='{publish_type}'
# where name ='{d['name']}';""", as_dict=1)
# frappe.db.commit()
except Exception as e:
frappe.throw(str("Failed To Publish"))
frappe.log_error("update_publish_mapping", str(e))
@frappe.whitelist()
def cal_ver(vehicle, lang, publish_type, doc, publish_module):
update_procedure(vehicle, lang, publish_type, doc)
@ -917,7 +999,7 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
logger.info(
f'Feature Data Append Start::{vehicle}-{language}-{publish_type}')
""" update existing global json file """
if os.path.isfile(global_file_path) and publish_type == 'Internal':
if os.path.isfile(check_glbl_full_updte) and publish_type == 'Internal':
frappe.log_error('internal')
if os.path.isfile(check_glbl_full_updte):
with open(check_glbl_full_updte) as f:
@ -940,17 +1022,17 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
vehi_data = add_new_val(
vehi_data, new_variant_name, feature_finder_tmp)
elif os.path.isfile(file_path) and publish_type == 'Global':
elif os.path.isfile(check_glbl_full_updte) and publish_type == 'Global':
frappe.log_error('gobal')
full_update_folder_url_internal = folder_url + "/" + "Internal_Full_Update"
# full_update_folder_url_internal = folder_url + "/" + "Internal_Full_Update"
""" Remove Internal Full Update File On Global Publish """
# """ Remove Internal Full Update File On Global Publish """
existing_internal_full_update = full_update_folder_url_internal+"/" + \
vehicle.replace(' ', '-') + \
'-feature_finder_full_update' + '.json'
if os.path.isfile(existing_internal_full_update):
os.remove(existing_internal_full_update)
# existing_internal_full_update = full_update_folder_url_internal+"/" + \
# vehicle.replace(' ', '-') + \
# '-feature_finder_full_update' + '.json'
# if os.path.isfile(existing_internal_full_update):
# os.remove(existing_internal_full_update)
with open(check_glbl_full_updte) as f:
published_data = json.load(f)
for i in parent:
@ -1037,7 +1119,8 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
os.remove(existing_internal_full_update)
""" Save publish file """
vehicle_data['data'] = vehi_data
# update_publish_mapping(vehicle, vehi_data,
# language, 'Feature',publish_type)
with open(file_path, 'w') as outfile:
outfile.write(json.dumps(latest_pub_data, indent=4, default=str))
@ -1130,14 +1213,14 @@ def qwik_service_publish(vehicle=None, vehicle_id=None, variant=None,
elif os.path.isfile(file_path) and publish_type == 'Global':
full_update_folder_url_internal = folder_url + "/" + "Internal_Full_Update"
full_update_folder_url_global = folder_url + "/" + "Global_Full_Update"
""" Remove Internal Full Update File On Global Publish """
existing_internal_full_update = full_update_folder_url_internal+"/" + \
existing_global_full_update = full_update_folder_url_global+"/" + \
vehicle.replace(' ', '-') + \
'-qwik_service_full_update' + '.json'
if os.path.isfile(existing_internal_full_update):
os.remove(existing_internal_full_update)
with open(check_glbl_full_updte) as f:
with open(existing_global_full_update) as f:
published_data = json.load(f)
for i in parent:
qwik_service = qwik_service_data(vehicle, language,
@ -1223,7 +1306,8 @@ def qwik_service_publish(vehicle=None, vehicle_id=None, variant=None,
os.remove(existing_internal_full_update)
""" Save publish file """
vehicle_data['data'] = vehi_data
# update_publish_mapping(vehicle, vehi_data,
# language,'Qwik Service',publish_type)
with open(file_path, 'w') as outfile:
outfile.write(json.dumps(latest_pub_data, indent=4, default=str))
@ -1405,7 +1489,8 @@ def torque_manual_publish(vehicle=None, vehicle_id=None,
""" Append Published Data to Json """
""" update existing global json file """
if os.path.isfile(global_file_path) and publish_type == 'Internal':
if os.path.isfile(check_glbl_full_updte) and publish_type == 'Internal':
frappe.log_error(str(full_update_file))
if os.path.isfile(check_glbl_full_updte):
with open(check_glbl_full_updte) as f:
published_data = json.load(f)
@ -1418,16 +1503,21 @@ def torque_manual_publish(vehicle=None, vehicle_id=None,
torque_manual['data'][0])
torque_manual_tmp = create_df(torque_manual_tmp)
latest_pub_data['data'] = torque_manual_tmp
vehi_data = compare_get_data({'data': published_data['data']}, {
'data': torque_manual_tmp})
if vehi_data:
find_distinct = set(exisitng_var)
new_variant_name = [
x for x in new_variant if x not in find_distinct]
vehi_data = add_new_val(
vehi_data, new_variant_name, torque_manual_tmp)
elif os.path.isfile(file_path) and publish_type == 'Global':
elif os.path.isfile(check_glbl_full_updte) and publish_type == 'Global':
frappe.log_error(str('Global'))
full_update_folder_url_internal = folder_url + "/" + "Internal_Full_Update"
""" Remove Internal Full Update File On Global Publish """
@ -1447,6 +1537,7 @@ def torque_manual_publish(vehicle=None, vehicle_id=None,
torque_manual_tmp.append(
torque_manual['data'][0])
torque_manual_tmp = create_df(torque_manual_tmp)
frappe.log_error('torque_manual_tmp'+str(torque_manual_tmp))
latest_pub_data['data'] = torque_manual_tmp
vehi_data = compare_get_data({'data': published_data['data']}, {
'data': torque_manual_tmp})
@ -1494,11 +1585,12 @@ def torque_manual_publish(vehicle=None, vehicle_id=None,
else:
""" First Time Global Or Internal """
for i in parent:
torque_manual = torque_manual_data(
vehicle, language, publish_type, i.parent1, i.variant)
if torque_manual['status'] == 1:
publish_torque_manual = 1
if len(torque_manual['data']) > 0:
@ -1506,10 +1598,11 @@ 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': []})
frappe.log_error('before'+str(torque_manual_tmp))
torque_manual_tmp = get_latest_data(
{'data': torque_manual_tmp}, {'data': []})
# frappe.log_error('after'+str(torque_manual_tmp))
vehi_data = create_df(torque_manual_tmp)
latest_pub_data['data'] = vehi_data
@ -1524,6 +1617,8 @@ def torque_manual_publish(vehicle=None, vehicle_id=None,
os.remove(existing_internal_full_update)
""" Save publish file """
vehicle_data['data'] = vehi_data
# update_publish_mapping(vehicle, vehi_data,
# language,'Torque Manual',publish_type)
with open(file_path, 'w') as outfile:
outfile.write(json.dumps(latest_pub_data, indent=4, default=str))
@ -1596,10 +1691,10 @@ def training_information_publish(vehicle, vehicle_id,
training_information['data'][0])
else:
frappe.throw(str('failed to publish'))
training_information_tmp = get_latest_data({'data': published_data['data']}, {
'data': training_information_tmp})
elif os.path.isfile(global_file_path) and publish_type == 'Global':
with open(global_file_path) as f:
published_data = json.load(f)
@ -1633,16 +1728,14 @@ 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)
if training_information['status'] == 1:
publish_training_information = 1
if len(training_information['data']):
training_information_tmp.append(
training_information['data'])
training_information['data'][0])
training_information_tmp = get_latest_data(
{'data': training_information_tmp}, {'data': []})
@ -1698,6 +1791,7 @@ def get_latest_data(prev_data, latest_data):
final_dic.update({d2: data_dic2[d2]})
final_list = list(final_dic.values())
frappe.log_error("final_list"+str(final_list))
logger.info("remove inactive end")
return final_list
except Exception as e:
@ -1995,12 +2089,12 @@ def torque_manual_data(vehicle=None, language=None,
logger.info(
f"start of fetching torque manual data - {vehicle} - {language} - {variant} - {module_name}")
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),
my_id from `tabTorque Manual` where name ='%s' && is_published =0;''' % (parent),
as_dict=1)
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)
`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

50
smart_service/transactions/doctype/variant_mapping/variant_mapping.py

@ -38,7 +38,7 @@ class VariantMapping(Document):
frappe.throw('Variant Mapping already created as {0} for {1}'.format(
data[0]['name'], self.variant))
create_module_publish(self.vehicle, self.variant)
# create_module_publish(self.vehicle, self.variant)
if self.assets:
for x in self.get("assets"):
@ -75,30 +75,30 @@ def drive(doctype, txt, searchfield, start, page_len, filters):
(name like "%%%(txt)s%%") order by modified desc limit %(start)s, %(page_len)s """.format(current_db_name) % {'txt': txt, 'start': start, 'page_len': page_len})
@frappe.whitelist(allow_guest=1)
def create_module_publish(vehicle, variant):
language_list = frappe.db.sql(
''' select lang_code from `tabCustom Languages`; ''', as_dict=1)
if language_list:
for l in language_list:
doc = frappe.get_doc({
'doctype': 'Module Publish Mapping',
"vehicle": vehicle,
"variant": variant,
"language": l['lang_code'],
"publish_type": "Internal"
})
doc.save()
doc1 = frappe.get_doc({
'doctype': 'Module Publish Mapping',
"vehicle": vehicle,
"variant": variant,
"language": l['lang_code'],
"publish_type": "Global"
})
doc1.save()
frappe.log_error('Doc Global', str(doc1))
# @frappe.whitelist(allow_guest=1)
# def create_module_publish(vehicle, variant):
# language_list = frappe.db.sql(
# ''' select lang_code from `tabCustom Languages`; ''', as_dict=1)
# if language_list:
# for l in language_list:
# doc = frappe.get_doc({
# 'doctype': 'Module Publish Mapping',
# "vehicle": vehicle,
# "variant": variant,
# "language": l['lang_code'],
# "publish_type": "Internal"
# })
# doc.save()
# doc1 = frappe.get_doc({
# 'doctype': 'Module Publish Mapping',
# "vehicle": vehicle,
# "variant": variant,
# "language": l['lang_code'],
# "publish_type": "Global"
# })
# doc1.save()
# frappe.log_error('Doc Global', str(doc1))
def update_repair_service(vehicle):

Loading…
Cancel
Save