diff --git a/smart_service/transactions/doctype/publish/publish.js b/smart_service/transactions/doctype/publish/publish.js
index 8205f25..83fba1a 100644
--- a/smart_service/transactions/doctype/publish/publish.js
+++ b/smart_service/transactions/doctype/publish/publish.js
@@ -17,9 +17,9 @@ cur_frm.fields_dict["vehicle"].get_query = function (doc, cdt, cdn) {
let lang_set_first_time = true;
var html_variant = []
-function get_variant_mapping(frm){
+function get_variant_mapping(frm) {
var res = $(cur_frm.fields_dict.variant_mapping_html.wrapper).empty();
- var vm =`
+ var vm = `
# |
@@ -33,44 +33,44 @@ function get_variant_mapping(frm){
vm += `
`
res.append(vm)
- if(frm.doc.variant_mapping_details){
+ if (frm.doc.variant_mapping_details) {
var variant_mapping_details_ = frm.doc.variant_mapping_details
variant_mapping_details_ = variant_mapping_details_.split("\n")
- variant_mapping_details_.map(v=>{
- frappe.db.get_list('Variant Mapping', {
- fields: ['family_code', 'fuel','transmission','drive'],
- filters: { name: v }
- }).then(val => {
- if (val){
- var docv= `
+ variant_mapping_details_.map(v => {
+ frappe.db.get_list('Variant Mapping', {
+ fields: ['family_code', 'fuel', 'transmission', 'drive'],
+ filters: { name: v }
+ }).then(val => {
+ if (val) {
+ var docv = `
1 |
${val[0]['family_code']} |
${val[0]['fuel']} |
@${val[0]['transmission']} |
@${val[0]['drive']} |
`
- res.find('tbody').append(docv)
- }
-
- })
-
-
+ res.find('tbody').append(docv)
+ }
+
+ })
+
+
})
-
+
}
-
-
+
+
}
frappe.ui.form.on("Publish", {
-
+
onload: function (frm) {
-
-
- setTimeout(function mysam(){
+
+
+ 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')
}, 500);
-
+
if (
frm.doc.hasOwnProperty("repiar_checksheet_publish_docs") &&
@@ -231,7 +231,7 @@ frappe.ui.form.on("Publish", {
) {
cur_frm.refresh_field("torque_manual_publish_docs");
cur_frm.remove_custom_button("Add To Publish");
- cur_frm.set_df_property("torque_manual_publish_docs", "hidden", 0);
+ cur_frm.set_df_property("torque_manual_publish_docs", "hidden", 0);
cur_frm.refresh_field("torque_manual_publish_docs");
}
if (
@@ -327,7 +327,7 @@ frappe.ui.form.on("Publish", {
// if(frm.doc.variant_mapping_details){
// get_variant_mapping(frm)
// }
- setTimeout(function mysam(){
+ 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')
}, 500);
@@ -368,25 +368,25 @@ frappe.ui.form.on("Publish", {
if (r.message == frm.doc.version) {
frm.add_custom_button(__("Global Publish"), function () {
- frappe.confirm("Are you sure you want to Publish?", () => {
- frappe.call({
- method:
- "smart_service.transactions.doctype.publish.publish.generate_global_publish",
- args: {
- name: frm.doc.name,
- module_name: frm.doc.publish_module,
- },
- callback: function (r) {
-
- window.location.href =
- r.message.url +
- "/app/publish" +
- "/" +
- r.message.message;
- },
- });
+ frappe.confirm("Are you sure you want to Publish?", () => {
+ frappe.call({
+ method:
+ "smart_service.transactions.doctype.publish.publish.generate_global_publish",
+ args: {
+ name: frm.doc.name,
+ module_name: frm.doc.publish_module,
+ },
+ callback: function (r) {
+
+ window.location.href =
+ r.message.url +
+ "/app/publish" +
+ "/" +
+ r.message.message;
+ },
});
- })
+ });
+ })
.addClass("btn-warning")
.css({ "background-color": "#f5b0cd", color: "black" });
}
@@ -463,7 +463,7 @@ frappe.ui.form.on("Publish", {
frm.fields_dict.publish_documents.grid.wrapper
.find(".grid-append-row")
.hide();
-
+
// document.querySelectorAll(
// "[data-fieldname='km_report']"
// )[1].style.backgroundColor = "#e31a37";
@@ -483,7 +483,7 @@ frappe.ui.form.on("Publish", {
!frm.doc.global_publish &&
frappe.user.has_role("_Publisher")
) {
-
+
frappe.call({
method:
"smart_service.transactions.doctype.publish.publish.max_publish",
@@ -492,21 +492,21 @@ frappe.ui.form.on("Publish", {
},
callback: function (r) {
if (r.message) {
-
+
if (r.message == frm.doc.version) {
-
+
frm.add_custom_button(__("Global Publish"), function () {
- frappe.call({
- method:
- "smart_service.transactions.doctype.publish.publish.global_publish",
- args: {
- doc: frm.doc.name,
- },
- callback: function (r) {
- cur_frm.reload_doc();
- },
- });
- })
+ frappe.call({
+ method:
+ "smart_service.transactions.doctype.publish.publish.global_publish",
+ args: {
+ doc: frm.doc.name,
+ },
+ callback: function (r) {
+ cur_frm.reload_doc();
+ },
+ });
+ })
.addClass("btn-warning")
.css({ "background-color": "#f5b0cd", color: "black" });
}
@@ -514,7 +514,7 @@ frappe.ui.form.on("Publish", {
},
});
}
-
+
if (
frm.doc.docstatus === 1 &&
frm.doc.publish_status == "To Publish" &&
@@ -522,95 +522,95 @@ frappe.ui.form.on("Publish", {
frm.doc.publish_module == "Automotive System"
) {
console.log("call")
-
+
frm.add_custom_button(__("Publish"), function () {
- frappe.confirm(
- "Are you sure you want to Publish?",
- () => {
- // action to perform if Yes is selected
- if (
- frm.doc.vehicle &&
- frm.doc.language &&
- frm.doc.publish_type
- ) {
- frappe.call({
- method:
- "smart_service.transactions.doctype.publish.publish.cal_ver",
- args: {
- vehicle: frm.doc.vehicle,
- lang: frm.doc.language,
- publish_type: frm.doc.publish_type,
- doc: frm.doc.name,
- publish_module: frm.doc.publish_module,
- },
- callback: (r) => {
-
- frm.set_value("version", r.message);
- cur_frm.refresh_field("version");
- if (
- frm.doc.docstatus === 1 &&
- frm.doc.publish_status == "To Publish"
- ) {
- frappe.call({
- // method: "smart_service.apis.publish_api.api_procedure",
- method: "smart_service.apis.publish_api.new_publish",
- args: {
- args: frm.doc.name,
- publish_type: frm.doc.publish_type,
- vehicle: frm.doc.vehicle,
- language: frm.doc.language,
- version: frm.doc.version,
- },
- callback: function (r) {
-
- console.log(r.message,"r.message")
- if (r.message[0] == true) {
- console.log("calling",r.message)
- frm.set_value("publish_status", "Published");
- frm.page.clear_primary_action("Publish");
- frm.set_value(
- "actual_published_date",
- frappe.datetime.nowdate()
- );
- frappe.call({
- method:
- "smart_service.transactions.doctype.publish.publish.update_procedure_value",
- args: {
- name: frm.doc.name,
- file_path: r.message[1],
- },
- callback: (r) => {
- // frm.save('Update');
- // cur_frm.reload_doc()
- },
- });
- frappe.msgprint({
- title: __("Notification"),
- message: __(
- "Successfully Published: " + r.message[1]
- ),
- primary_action: {
- action(values) {
- frm.save("Update");
- },
+ frappe.confirm(
+ "Are you sure you want to Publish?",
+ () => {
+ // action to perform if Yes is selected
+ if (
+ frm.doc.vehicle &&
+ frm.doc.language &&
+ frm.doc.publish_type
+ ) {
+ frappe.call({
+ method:
+ "smart_service.transactions.doctype.publish.publish.cal_ver",
+ args: {
+ vehicle: frm.doc.vehicle,
+ lang: frm.doc.language,
+ publish_type: frm.doc.publish_type,
+ doc: frm.doc.name,
+ publish_module: frm.doc.publish_module,
+ },
+ callback: (r) => {
+
+ frm.set_value("version", r.message);
+ cur_frm.refresh_field("version");
+ if (
+ frm.doc.docstatus === 1 &&
+ frm.doc.publish_status == "To Publish"
+ ) {
+ frappe.call({
+ // method: "smart_service.apis.publish_api.api_procedure",
+ method: "smart_service.apis.publish_api.new_publish",
+ args: {
+ args: frm.doc.name,
+ publish_type: frm.doc.publish_type,
+ vehicle: frm.doc.vehicle,
+ language: frm.doc.language,
+ version: frm.doc.version,
+ },
+ callback: function (r) {
+
+ console.log(r.message, "r.message")
+ if (r.message[0] == true) {
+ console.log("calling", r.message)
+ frm.set_value("publish_status", "Published");
+ frm.page.clear_primary_action("Publish");
+ frm.set_value(
+ "actual_published_date",
+ frappe.datetime.nowdate()
+ );
+ frappe.call({
+ method:
+ "smart_service.transactions.doctype.publish.publish.update_procedure_value",
+ args: {
+ name: frm.doc.name,
+ file_path: r.message[1],
+ },
+ callback: (r) => {
+ // frm.save('Update');
+ // cur_frm.reload_doc()
+ },
+ });
+ frappe.msgprint({
+ title: __("Notification"),
+ message: __(
+ "Successfully Published: " + r.message[1]
+ ),
+ primary_action: {
+ action(values) {
+ frm.save("Update");
},
- });
- }
- else{
- frappe.msgprint('Failed To Publish')
- }
- },
- });
- }
- },
- });
- }
- },
- () => {
- // action to perform if No is selected
+ },
+ });
+ }
+ else {
+ frappe.msgprint('Failed To Publish')
+ }
+ },
+ });
+ }
+ },
+ });
}
- );
- })
+ },
+ () => {
+ // action to perform if No is selected
+ }
+ );
+ })
.addClass("btn-warning")
.css({ "background-color": "#f5b0cd", color: "black" });
} else if (frm.doc.publish_status == "Published") {
@@ -743,7 +743,7 @@ frappe.ui.form.on("Publish", {
doc: frm.doc.name,
},
callback: function (r) {
-
+
if (r.message['status'] == 1) {
frm.set_value("version", r.message['data']);
cur_frm.refresh_field("version");
@@ -751,9 +751,9 @@ frappe.ui.form.on("Publish", {
// window.location.reload();
// cur_frm.reload_doc()
}
- else{
+ else {
frappe.msgprint("Failed To Publish")
-
+
}
},
});
@@ -791,7 +791,7 @@ frappe.ui.form.on("Publish", {
if (
frm.doc.publish_module != "Automotive System" &&
!frm.doc.hasOwnProperty("repair_checksheet_publish") &&
- !frm.doc.hasOwnProperty("feature_finder_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") &&
@@ -801,7 +801,7 @@ frappe.ui.form.on("Publish", {
}
},
variant_mapping: function (frm) {
- setTimeout(function mysam(){
+ 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')
}, 100);
@@ -920,13 +920,13 @@ frappe.ui.form.on("Publish", {
if (frm.doc.publish_module == "Torque Manual") {
add_torque_manual(frm);
}
- if(frm.doc.publish_module == "Qwik Service"){
+ if (frm.doc.publish_module == "Qwik Service") {
add_qwik_service(frm)
}
- if(frm.doc.publish_module == "Training Information"){
+ if (frm.doc.publish_module == "Training Information") {
add_training_information(frm)
}
- if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish' && frm.doc.publish_module=='Feature Finder') {
+ if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish' && frm.doc.publish_module == 'Feature Finder') {
frm.get_field('feature_finder_publish').grid.add_custom_button(__('Add to Publish'), function () {
let added = 0;
@@ -949,29 +949,31 @@ frappe.ui.form.on("Publish", {
child.variant = row.variant;
child.active_status = row.active_status;
added += 1;
- frm.set_df_property('feature_finder_publish_docs','hidden',0)
- cur_frm.refresh_field("feature_finder_publish",'read_only',1);
+ frm.set_df_property('feature_finder_publish_docs', 'hidden', 0)
+ cur_frm.refresh_field("feature_finder_publish", 'read_only', 1);
refresh_field("feature_finder_publish_docs");
- cur_frm.set_df_property("feature_finder_publish",'read_only',1);
- document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[4] .setAttribute("style","display:none;");
- document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[5] .setAttribute("style","display:none;");
+ cur_frm.set_df_property("feature_finder_publish", 'read_only', 1);
+ document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[4].setAttribute("style", "display:none;");
+ document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[5].setAttribute("style", "display:none;");
}
- else{
+ else {
frappe.msgprint(__(row.parent1 + 'Alraeady Added'))
}
- cur_frm.refresh_field("feature_finder_publish_docs",'read_only',1);
+ cur_frm.refresh_field("feature_finder_publish_docs", 'read_only', 1);
}
});
- if (added) { frappe.msgprint(__(added + " Doc(s) Added"));
- cur_frm.set_df_property('feature_finder_publish','read_only',1)
- cur_frm.set_df_property("feature_finder_publish_docs",'read_only',1);
- cur_frm.refresh_field("feature_finder_publish"); }
- else if(added==0) { frappe.msgprint(__("No Doc Added")); }
+ if (added) {
+ frappe.msgprint(__(added + " Doc(s) Added"));
+ cur_frm.set_df_property('feature_finder_publish', 'read_only', 1)
+ cur_frm.set_df_property("feature_finder_publish_docs", 'read_only', 1);
+ cur_frm.refresh_field("feature_finder_publish");
+ }
+ else if (added == 0) { frappe.msgprint(__("No Doc Added")); }
});
frm.fields_dict.repair_checksheet_publish.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
}
- if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish' && frm.doc.publish_module=='Torque Manual') {
+ if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish' && frm.doc.publish_module == 'Torque Manual') {
frm.get_field('torque_manual_publish').grid.add_custom_button(__('Add to Publish'), function () {
let added = 0;
@@ -992,28 +994,30 @@ frappe.ui.form.on("Publish", {
child.parent1 = row.parent1;
child.language = row.language;
child.variant = row.variant;
- child.category= row.category;
- child.sub_category= row.sub_category;
+ child.category = row.category;
+ child.sub_category = row.sub_category;
child.active_status = row.active_status;
added += 1;
- frm.set_df_property('torque_manual_publish_docs','hidden',0)
- cur_frm.refresh_field("torque_manual_publish",'read_only',1);
+ frm.set_df_property('torque_manual_publish_docs', 'hidden', 0)
+ cur_frm.refresh_field("torque_manual_publish", 'read_only', 1);
refresh_field("torque_manual_publish_docs");
- cur_frm.set_df_property("torque_manual_publish",'read_only',1);
- document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[4] .setAttribute("style","display:none;");
- document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[5] .setAttribute("style","display:none;");
+ cur_frm.set_df_property("torque_manual_publish", 'read_only', 1);
+ document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[4].setAttribute("style", "display:none;");
+ document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[5].setAttribute("style", "display:none;");
}
- else{
+ else {
frappe.msgprint(__(row.parent1 + 'Alraeady Added'))
}
// cur_frm.refresh_field("torque_manual_publish_docs",'read_only',1);
}
});
- if (added) { frappe.msgprint(__(added + " Doc(s) Added"));
- cur_frm.set_df_property('torque_manual_publish','read_only',1)
- cur_frm.set_df_property("torque_manual_publish_docs",'read_only',1);
- cur_frm.refresh_field("torque_manual_publish"); }
- else if(added==0) { frappe.msgprint(__("No Doc Added")); }
+ if (added) {
+ frappe.msgprint(__(added + " Doc(s) Added"));
+ cur_frm.set_df_property('torque_manual_publish', 'read_only', 1)
+ cur_frm.set_df_property("torque_manual_publish_docs", 'read_only', 1);
+ cur_frm.refresh_field("torque_manual_publish");
+ }
+ else if (added == 0) { frappe.msgprint(__("No Doc Added")); }
});
frm.fields_dict.torque_manual_publish.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
@@ -1195,31 +1199,31 @@ frappe.ui.form.on("Publish", {
refresh_field("publish_documents");
frappe.msgprint(__(frm.doc.variant_mapping + " Added"));
}
- if(frm.doc.feature_finder_publish_docs && frm.doc.publish_module=='Feature Finder'){
- frm.doc.publish_documents.forEach(publishrow => {
- if (frm.doc.variant_mapping == publishrow.variant_mapping) {
- dulicate = true;
- }
- });
- frappe.msgprint("Variant Mapping already added");
+ // if(frm.doc.feature_finder_publish_docs && frm.doc.publish_module=='Feature Finder'){
+ // frm.doc.publish_documents.forEach(publishrow => {
+ // if (frm.doc.variant_mapping == publishrow.variant_mapping) {
+ // dulicate = true;
+ // }
+ // });
+ // frappe.msgprint("Variant Mapping already added");
- }
- if(frm.doc.torque_manual_publish_docs && frm.doc.publish_module=='Torque Manual'){
- frm.doc.publish_documents.forEach(publishrow => {
- if (frm.doc.variant_mapping == publishrow.variant_mapping) {
- dulicate = true;
- }
- });
- frappe.msgprint("Variant Mapping already added");
+ // }
+ // if(frm.doc.torque_manual_publish_docs && frm.doc.publish_module=='Torque Manual'){
+ // frm.doc.publish_documents.forEach(publishrow => {
+ // if (frm.doc.variant_mapping == publishrow.variant_mapping) {
+ // dulicate = true;
+ // }
+ // });
+ // frappe.msgprint("Variant Mapping already added");
- }
- if (dulicate === false && frm.doc.publish_module == "Torque Manual") {
- let child = cur_frm.add_child("publish_documents");
- child.variant_mapping = frm.doc.variant_mapping;
- child.item_category = "Variant Mapping";
- refresh_field("publish_documents");
- frappe.msgprint(__(frm.doc.variant_mapping + " Added"));
- }
+ // }
+ // if (dulicate === false && frm.doc.publish_module == "Torque Manual") {
+ // let child = cur_frm.add_child("publish_documents");
+ // child.variant_mapping = frm.doc.variant_mapping;
+ // child.item_category = "Variant Mapping";
+ // refresh_field("publish_documents");
+ // frappe.msgprint(__(frm.doc.variant_mapping + " Added"));
+ // }
},
km_report: function (frm, cdt, cdn) {
if (frm.doc.publish_module == "Automotive System") {
@@ -1236,7 +1240,7 @@ frappe.ui.form.on("Publish", {
},
vehicle: function (frm) {
- setTimeout(function mysam(){
+ 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')
}, 100);
@@ -1338,17 +1342,17 @@ frappe.ui.form.on("Publish", {
frm.refresh_field("vehicle");
frm.set_value("repair_checksheet_publish", "");
frm.set_value("feature_finder_publish", "");
- frm.set_value("qwik_service_publish","");
- frm.set_value("torque_manual_publish","");
- frm.set_value("training_information_publish","");
- frm.set_value("special_tool_publish","");
+ frm.set_value("qwik_service_publish", "");
+ frm.set_value("torque_manual_publish", "");
+ frm.set_value("training_information_publish", "");
+ frm.set_value("special_tool_publish", "");
frm.set_value("repiar_checksheet_publish_docs", "");
frm.set_value("feature_finder_publish_docs", "");
frm.set_value("qwik_service_publish_docs", "");
frm.set_value("torque_manual_publish_docs", "");
frm.set_value("special_tool_publish_docs", "");
frm.set_value("training_information_publish_docs", "");
-
+
if (frm.doc.publish_module == "Repair service" && frm.doc.vehicle) {
add_to_publish(frm);
@@ -1468,7 +1472,7 @@ frappe.ui.form.on("Publish", {
// action to perform if No is selected
}
);
-
+
}
if (!lang_set_first_time && frm.doc.publish_module == "Torque Manual") {
frappe.confirm(
@@ -1483,8 +1487,8 @@ frappe.ui.form.on("Publish", {
// action to perform if No is selected
}
);
-
- }
+
+ }
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?",
@@ -1498,7 +1502,7 @@ frappe.ui.form.on("Publish", {
// action to perform if No is selected
}
);
-
+
}
else {
lang_set_first_time = false;
@@ -1535,16 +1539,16 @@ frappe.ui.form.on("Publish", {
frm.doc.variant_mapping = "";
frm.doc.repair_checksheet_publish = "";
frm.doc.feature_finder_publish = "";
- frm.doc.qwik_service_publish="";
- frm.doc.special_tool_publish="";
- frm.doc.torque_manual_publish="";
- frm.doc.training_information_publish="";
+ frm.doc.qwik_service_publish = "";
+ frm.doc.special_tool_publish = "";
+ frm.doc.torque_manual_publish = "";
+ frm.doc.training_information_publish = "";
frm.set_value("feature_finder_publish_docs", "");
frm.set_value("repiar_checksheet_publish_docs", "");
frm.set_value("qwik_service_publish_docs", "");
- frm.set_value("special_tool_publish_docs","");
- frm.set_value("torque_manual_publish_docs","");
- frm.set_value("training_information_publish","");
+ frm.set_value("special_tool_publish_docs", "");
+ frm.set_value("torque_manual_publish_docs", "");
+ frm.set_value("training_information_publish", "");
frm.set_df_property("repiar_checksheet_publish_docs", "hidden", 1);
frm.refresh_fields();
if (frm.doc.publish_module == "Repair service") {
@@ -1562,8 +1566,8 @@ frappe.ui.form.on("Publish", {
if (frm.doc.publish_module == "Torque Manual") {
add_torque_manual(frm);
}
-
- if(frm.doc.publish_module == "Qwik Service"){
+
+ if (frm.doc.publish_module == "Qwik Service") {
add_qwik_service(frm)
}
if (frm.doc.publish_module == "special Tool") {
@@ -1770,7 +1774,7 @@ function add_training_information(frm) {
if (dulicate === false) {
let child = cur_frm.add_child(
"training_information_publish_docs"
- );
+ );
child.vehicle = frm.doc.vehicle;
child.parent1 = row.parent1;
child.language = row.language;
@@ -1795,7 +1799,7 @@ function add_training_information(frm) {
)[5]
.setAttribute("style", "display:none;");
}
- else {
+ else {
frappe.msgprint(__(row.parent1 + "Alraeady Added"));
}
}
@@ -2039,8 +2043,8 @@ function add_torque_manual(frm) {
child.parent1 = row.parent1;
child.language = row.language;
child.variant = row.variant;
- child.category= row.category;
- child.sub_category= row.sub_category;
+ child.category = row.category;
+ child.sub_category = row.sub_category;
child.active_status = row.active_status;
added += 1;
frm.set_df_property(
@@ -2115,18 +2119,18 @@ function add_torque_manual(frm) {
},
});
}
-function add_qwik_service(frm){
+function add_qwik_service(frm) {
cur_frm.clear_table("Qwik_service_publish");
cur_frm.refresh_fields();
frappe.call({
- method:"smart_service.transactions.doctype.publish.publish.get_qwik_service",
- args:{
+ method: "smart_service.transactions.doctype.publish.publish.get_qwik_service",
+ args: {
variant: frm.doc.variant_mapping,
language_label: frm.doc.language,
publish_type: frm.doc.publish_type
},
- callback:function(r){
- if (r.message.length > 0){
+ callback: function (r) {
+ if (r.message.length > 0) {
cur_frm.set_df_property("qwik_service_publish", "hidden", 0);
var records = r.message;
records.map((v) => {
@@ -2142,7 +2146,7 @@ function add_qwik_service(frm){
frm.doc.docstatus === 0 &&
frm.doc.publish_status == "To Publish" &&
frm.doc.publish_module == "Qwik Service"
- ){
+ ) {
frm
.get_field("qwik_service_publish")
.grid.add_custom_button(__("Add to Publish"), function () {
@@ -2204,7 +2208,7 @@ function add_qwik_service(frm){
.find(".btn-custom")
.removeClass("btn-default")
.addClass("btn-primary");
- }else {
+ } else {
frappe.msgprint(__(row.parent1 + "Alraeady Added"));
}
cur_frm.refresh_field(
@@ -2227,7 +2231,7 @@ function add_qwik_service(frm){
1
);
cur_frm.refresh_field("qwik_service_publish");
- }else if (added == 0) {
+ } else if (added == 0) {
frappe.msgprint(__("No Doc Added"));
}
});
diff --git a/smart_service/transactions/doctype/publish/publish.json b/smart_service/transactions/doctype/publish/publish.json
index fa6c62a..44abff6 100644
--- a/smart_service/transactions/doctype/publish/publish.json
+++ b/smart_service/transactions/doctype/publish/publish.json
@@ -209,7 +209,7 @@
"read_only": 1
},
{
- "depends_on": "eval:doc.variant_mapping && doc.publish_type == \"Internal\" && doc.docstatus == 0 && doc.publish_module=='Automotive System' || doc.publish_module=='Torque Manual'",
+ "depends_on": "eval:doc.variant_mapping && doc.publish_type == \"Internal\" && doc.docstatus == 0 && doc.publish_module=='Automotive System'",
"fieldname": "add_variant_mapping_to_publish",
"fieldtype": "Button",
"label": "Add Variant Mapping to Publish",
@@ -440,7 +440,7 @@
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
- "modified": "2023-12-12 23:25:19.477106",
+ "modified": "2023-12-15 18:57:55.788156",
"modified_by": "Administrator",
"module": "Transactions",
"name": "Publish",
diff --git a/smart_service/transactions/doctype/publish/publish.py b/smart_service/transactions/doctype/publish/publish.py
index 35117e3..dff505b 100644
--- a/smart_service/transactions/doctype/publish/publish.py
+++ b/smart_service/transactions/doctype/publish/publish.py
@@ -14,6 +14,7 @@ from datetime import date
from frappe.utils import cstr
from frappe.utils import logger
import re
+
current_db_name = frappe.conf.get("db_name")
sys.tracebacklimit = 0
site_name = cstr(frappe.local.site)
@@ -35,13 +36,9 @@ class Publish(Document):
self.published_date = str(date.today())
self.published_by = frappe.session.user
- # Selected variant and kilometer mapping details list
+ """ Selected variant and kilometer mapping details list """
variant = []
for vm in self.get('publish_documents'):
- # if vm.variant_mapping in variant:
- # pass
- # else:
- # variant.append(vm.variant_mapping)
if vm.variant_mapping not in variant:
variant.append(vm.variant_mapping)
if self.publish_module == 'Feature Finder' and self.feature_finder_publish_docs:
@@ -61,113 +58,83 @@ class Publish(Document):
str(km_mapping.name) + '\n'
def on_submit(self):
+ """ qwik_service """
- # qwik_service
- if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Qwik Service' and self.publish_type == 'Internal':
- qwik_service_publish(self.vehicle, self.vehicle_id, self.variant,
- self.language, self.publish_type,
- self.release_description, self.qwik_service_publish_docs)
-
- update_publish_status = frappe.db.sql(
- """update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
- if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Qwik Service' and self.publish_type == 'Global' and self.qwik_service_publish_docs:
+ 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)
- update_publish_status = frappe.db.sql(
- """update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
-
- update_qwik_published_docs(self)
- update_publish_status = frappe.db.sql(
- """update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
- # feature_finder
- if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Feature Finder' and self.publish_type == 'Internal' and self.feature_finder_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)
- update_publish_status = frappe.db.sql(
- """update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
+ frappe.db.sql(
+ """update `tabPublish` set publish_status='Published' where name='{0}';""".format(self.name))
- if self.docstatus == 1 and self.publish_module == 'Feature Finder' and self.publish_type == 'Global':
- feature_finder_publish(self.vehicle, self.vehicle_id,
- self.language, self.publish_type,
- self.release_description, self.feature_finder_publish_docs,
- self.variant)
- update_feature_published_docs(self)
- update_publish_status = frappe.db.sql(
- """update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
- # repair_service
- if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Repair service' and self.publish_type == 'Internal':
- repair_res_obj = repair_checksheet_publish(self.vehicle, self.vehicle_id,
- self.language, self.publish_type,
- self.release_description, self.variant,
- self.repiar_checksheet_publish_docs)
-
- update_publish_status = frappe.db.sql(
- """update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
- if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Repair service' and self.publish_type == 'Global' and self.repiar_checksheet_publish_docs:
+ 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)
- update_repair_published_docs(self)
- update_publish_status = frappe.db.sql(
- """update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
- # special tool
- if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Special Tool' and self.publish_type == 'Internal':
- special_tool_publish(self.vehicle, self.vehicle_id,
- self.publish_type,
- self.release_description,
- self.special_tool_publish_docs)
- update_publish_status = frappe.db.sql(
- """update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
- if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Special Tool' and self.publish_type == 'Global' and 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_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)
- update_special_tool_publish_docs(self)
- update_publish_status = frappe.db.sql(
- """update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
+ 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.publish_type == 'Internal' and self.torque_manual_publish_docs:
+ """ 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)
- update_publish_status = frappe.db.sql(
- """update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
+ frappe.db.sql(
+ """update `tabPublish` set publish_status='Published' where name='{0}';""".format(self.name))
- if self.docstatus == 1 and self.publish_module == 'Torque Manual' and self.publish_type == 'Global':
- torque_manual_publish(self.vehicle, self.vehicle_id,
- self.language, self.publish_type,
- self.release_description, self.torque_manual_publish_docs,
- self.variant)
- update_torque_manual_published_docs(self)
- update_publish_status = frappe.db.sql(
- """update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
- # training information
- if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Training Information' and self.publish_type == 'Internal':
- training_information_publish(self.vehicle, self.vehicle_id,
- self.language, self.publish_type,
- self.release_description, self.variant,
- self.training_information_publish_docs)
+ 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)
- update_publish_status = frappe.db.sql(
- """update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
- if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Training Information' and self.publish_type == 'Global' and self.training_information_publish_docs:
+ """ 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)
- update_training_published_docs(self)
- update_publish_status = frappe.db.sql(
- """update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
-
- variant = self.variant_mapping_details.split('/n')
-
- update_publish_mapping(self.vehicle, i,
- self.language, self.publish_module, self.publish_type)
+ 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)
if self.publish_type == 'Internal':
frappe.db.sql(
@@ -183,13 +150,13 @@ class Publish(Document):
'''update `tabCustom Languages` set global_publish = 1 where lang_code= '{0}'; '''.format(self.language))
def on_cancel(self):
- # Published document should not allow to cancel
+ """ Published document should not allow to cancel """
if self.publish_status == "Published":
frappe.throw('You can not cancel a Published Document!')
def update_procedure(vehicle, lang, publish_type, doc):
- # To validate updated procedure status
+ """ To validate updated procedure status """
doc = frappe.get_doc("Publish", 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,
@@ -238,7 +205,8 @@ def update_procedure(vehicle, lang, publish_type, doc):
if str(table_len) == str(len_publish):
frappe.throw("There is no item for global publish")
-# Generate Publish versions
+
+""" Generate Publish versions """
def update_qwik_published_docs(self):
@@ -262,10 +230,11 @@ def update_torque_manual_published_docs(self):
raise e
-def update_publish_mapping(vehicle, variant, language, module, publish_type):
-
+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,
@@ -276,11 +245,12 @@ def update_publish_mapping(vehicle, variant, language, module, publish_type):
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)
-
+ 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,
@@ -291,11 +261,13 @@ def update_publish_mapping(vehicle, variant, language, module, publish_type):
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)
+ 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,
@@ -305,9 +277,12 @@ def update_publish_mapping(vehicle, variant, language, module, publish_type):
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)
+ 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:
+ for v in variant_list:
+ variant = v['variant']
pub_data = frappe.db.get_list('Module Publish Mapping', filters={
"vehicle": vehicle,
"variant": variant,
@@ -345,13 +320,6 @@ def update_publish_mapping(vehicle, variant, language, module, publish_type):
except Exception as e:
frappe.log_error("update_publish_mapping", str(e))
-# def update_publish_status(self):
-# try:
-# update_status = frappe.db.sql(
-# """update `tabPublish Test` set publish_status="Published" where name='{0}' """.format(self.name))
-# except Exception as e:
-# return e
-
@frappe.whitelist()
def cal_ver(vehicle, lang, publish_type, doc, publish_module):
@@ -385,7 +353,8 @@ def cal_ver(vehicle, lang, publish_type, doc, publish_module):
frappe.db.commit()
return v
-# Create global publish document for publish ready procedures
+
+""" Create global publish document for publish ready procedures """
@frappe.whitelist()
@@ -442,7 +411,7 @@ def global_publish(doc):
def generate_global_publish(name, module_name):
try:
res = frappe.get_doc("Publish", name)
- # frappe.log_error('res'+str(res.variant_mapping))
+
if module_name == 'Feature Finder':
ret = frappe.get_doc({
"doctype": "Publish",
@@ -456,6 +425,7 @@ def generate_global_publish(name, module_name):
"feature_finder_publish_docs": res.feature_finder_publish_docs
})
ret.save()
+
elif module_name == 'Repair service':
ret = frappe.get_doc({
"doctype": "Publish",
@@ -463,13 +433,13 @@ def generate_global_publish(name, module_name):
"publish_type": "Global",
"language": res.language,
"variant_mapping_details": res.variant_mapping,
-
"publish_status": 'To Publish',
"release_description": res.release_description,
"publish_module": res.publish_module,
"repiar_checksheet_publish_docs": res.repiar_checksheet_publish_docs
})
ret.save()
+
elif module_name == 'Qwik Service':
ret = frappe.get_doc({
"doctype": "Publish",
@@ -480,9 +450,9 @@ def generate_global_publish(name, module_name):
"publish_status": 'To Publish',
"release_description": res.release_description,
"publish_module": res.publish_module
-
})
ret.save()
+
elif module_name == 'Special Tool':
ret = frappe.get_doc({
"doctype": "Publish",
@@ -492,11 +462,10 @@ def generate_global_publish(name, module_name):
"publish_status": 'To Publish',
"release_description": res.release_description,
"publish_module": res.publish_module
-
})
ret.save()
+
elif module_name == 'Torque Manual':
- # frappe.log_error(str(res))
ret = frappe.get_doc({
"doctype": "Publish",
"vehicle": res.vehicle,
@@ -510,7 +479,7 @@ def generate_global_publish(name, module_name):
"torque_manual_publish_docs": res.torque_manual_publish_docs
})
ret.save()
- # frappe.log_error('ret'+str(ret))
+
elif module_name == 'Training Information':
ret = frappe.get_doc({
"doctype": "Publish",
@@ -523,6 +492,7 @@ def generate_global_publish(name, module_name):
"training_information_publish_docs": res.training_information_publish_docs
})
ret.save()
+
return {"status": "success", "message": ret.name, "url": frappe.utils.get_url()}
except Exception as e:
frappe.throw(str(e))
@@ -542,13 +512,13 @@ def old_publish(vehicle, language):
if global_publish_record:
return global_publish_record
-# Update System and Variant Mapping and its called from publish client script
+
+""" Update System and Variant Mapping and its called from publish client script """
@frappe.whitelist()
def update_mapping(variant_mapping, doc):
doc = frappe.get_doc("Publish", doc)
- current_db_name = frappe.conf.get("db_name")
if doc.publish_documents:
for variant in doc.get('publish_documents'):
if variant.item_category == "Variant Mapping Assets":
@@ -556,21 +526,21 @@ def update_mapping(variant_mapping, doc):
for v in vm.get('assets'):
if v.category == variant.asset_category:
v.published = '1'
- frappe.db.sql("""update {0}.`tabVariant Mapping_Assets` set published = '1' where parent = "{1}" and category = "{2}";""".format(
- current_db_name, variant.variant_mapping, variant.asset_category))
+ frappe.db.sql("""update {0}.`tabVariant Mapping_Assets` set published = '1' where parent = "{1}" and category = "{2}";
+ """.format(current_db_name, variant.variant_mapping, variant.asset_category))
frappe.db.commit()
if variant.item_category == "System Mapping":
- system_mapping = frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping = "{1}" and language = "{2}";""".format(
- current_db_name, variant.variant_mapping, doc.language), as_dict=1)
+ system_mapping = frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping = "{1}" and language = "{2}";
+ """.format(current_db_name, variant.variant_mapping, doc.language), as_dict=1)
if system_mapping:
for system_map in system_mapping:
sm = frappe.get_doc("System Mapping", system_map.name)
for sys_asset in sm.get('systems_assets'):
if sys_asset.systems == variant.system:
sys_asset.published = '1'
- frappe.db.sql("""update {0}.`tabSystem Mapping_System Assets` set published = '1' where parent = "{1}" and systems = "{2}";""".format(
- current_db_name, sm.name, variant.system))
+ frappe.db.sql("""update {0}.`tabSystem Mapping_System Assets` set published = '1' where parent = "{1}" and
+ systems = "{2}";""".format(current_db_name, sm.name, variant.system))
frappe.db.commit()
for sm_item in sm.get("system_sub_systems"):
@@ -581,7 +551,8 @@ def update_mapping(variant_mapping, doc):
current_db_name, sm.name, variant.system, variant.sub_system))
frappe.db.commit()
-# Set filter for latest modified document
+
+""" Set filter for latest modified document """
@frappe.whitelist()
@@ -594,8 +565,8 @@ def get_vm_asset(doc, lang):
@frappe.whitelist()
def get_sm_asset(doc, name, lang):
- system_map = frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping="{1}" and name = "{2}" and language = '{3}'; """.format(
- current_db_name, doc, name, lang), as_dict=1)
+ system_map = frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping="{1}" and name = "{2}" and language = '{3}';
+ """.format(current_db_name, doc, name, lang), as_dict=1)
if system_map:
for s in system_map:
doc = frappe.get_doc("System Mapping", s.name)
@@ -606,22 +577,22 @@ def get_sm_asset(doc, name, lang):
@frappe.whitelist()
def get_system(doc, name, lang):
- system_map = frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping="{1}" and name = "{2}" and language = "{3}";""".format(
- current_db_name, doc, name, lang), as_dict=1)
+ system_map = frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping="{1}" and name = "{2}" and language = "{3}";
+ """.format(current_db_name, doc, name, lang), as_dict=1)
if system_map:
for s in system_map:
doc = frappe.get_doc("System Mapping", s.name)
system = frappe.db.sql("""select systems,sub_systems,active_status,symptom,component,estimate_time,rts,component,mat,
- procedure_status,`procedure` from {0}.`tabSystem Mapping_Sub System` where parent = "{1}" and procedure_status != "Draft" and
- procedure_is_published = "0";""".format(current_db_name, s.name), as_dict=1)
+ procedure_status,`procedure` from {0}.`tabSystem Mapping_Sub System` where parent = "{1}"
+ and procedure_status != "Draft" and procedure_is_published = "0";""".format(current_db_name, s.name), as_dict=1)
return system
@frappe.whitelist()
def max_publish(doc):
doc = frappe.get_doc("Publish", doc)
- ver = frappe.db.sql("""select max(version) from {0}.tabPublish where vehicle = "{1}" and language = "{2}" and publish_module = "Automotive System";""".format(
- current_db_name, doc.vehicle, doc.language))
+ ver = frappe.db.sql("""select max(version) from {0}.tabPublish where vehicle = "{1}" and language = "{2}" and
+ publish_module = "Automotive System";""".format(current_db_name, doc.vehicle, doc.language))
if ver:
return ver
@@ -643,12 +614,11 @@ def update_procedure_value(name, file_path):
f'''update `tabPublish` set file_path = "{file_path}" where name = "{name}";''')
frappe.db.commit()
current_db_name = frappe.conf.get("db_name")
- # To validate updated procedure status
+ """ To validate updated procedure status """
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 p.procedure_link is not null""".format(current_db_name, self.name), as_dict=1)
- # l = len(procedure_status)
+ p.procedure_link = pro.name and p.procedure_link is not null;""".format(current_db_name, self.name), as_dict=1)
if procedure_status:
for x in procedure_status:
@@ -672,7 +642,7 @@ def update_procedure_value(name, file_path):
y.save()
frappe.db.commit()
- # Update system and variant mapping ststus
+ """ Update system and variant mapping status """
if self.publish_type == "Global":
current_db_name = frappe.conf.get("db_name")
global_publish = frappe.db.sql("""select name from {0}.`tabPublish` where global_publish = "{1}";""".format(
@@ -696,7 +666,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:
@@ -705,20 +675,21 @@ def update_feature_published_docs(self):
def update_repair_published_docs(self):
try:
- # frappe.log_error(str(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_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))
@@ -728,7 +699,7 @@ def update_training_published_docs(self):
try:
for d in self.training_information_publish:
frappe.db.sql(
- """UPDATE `tabTraining Information` set published=1 where name='{0}'""".format(d.parent1))
+ """UPDATE `tabTraining Information` set published=1 where name='{0}';""".format(d.parent1))
frappe.db.commit()
except Exception as e:
@@ -755,7 +726,7 @@ def create_publish_folders(folder_url):
return False
-'''New Module Publish Section'''
+""" New Module Publish Section """
def create_df(data_set):
@@ -784,12 +755,12 @@ def repair_checksheet_publish(vehicle, vehicle_id,
folder_url = base_url+"/"+vehicle.replace(' ', '-') + "/"+language
logger.info(f'Created Folder-{vehicle}-{language}-{publish_type}')
- '''Publish Ready Flags'''
+ """ Publish Ready Flags """
publish_repair_checksheet = 0
repair_checksheet_tmp = []
repair_checksheet_tmp1 = []
- '''Create Folder For Publish'''
+ """ Create Folder For Publish """
create_publish_folders(folder_url)
file_path = folder_url + "/" + publish_type + "/" + \
vehicle.replace(' ', '-') + '-repair_check_sheet' + '.json'
@@ -798,7 +769,7 @@ def repair_checksheet_publish(vehicle, vehicle_id,
vehicle.replace(' ', '-') + '-repair_check_sheet' + '.json'
check_inter_file = folder_url + "/" + 'Internal' + "/" + \
vehicle.replace(' ', '-') + '-repair_check_sheet' + '.json'
- '''Append Published Data to Json'''
+ """ Append Published Data to Json """
logger.info(
f'Repair Checksheet Data Append Start::{vehicle}-{language}-{publish_type}')
vehicle_data = {
@@ -817,7 +788,7 @@ def repair_checksheet_publish(vehicle, vehicle_id,
published_data = json.load(f)
for i in parent:
repair_checksheet = repair_checksheet_data(vehicle, language,
- publish_type, i.parent_name)
+ publish_type, i.parent_name)
if repair_checksheet['status'] == 1:
publish_repair_checksheet = 1
repair_checksheet_tmp.append(
@@ -831,7 +802,7 @@ def repair_checksheet_publish(vehicle, vehicle_id,
published_data = json.load(f)
for i in parent:
repair_checksheet = repair_checksheet_data(vehicle, language,
- publish_type, i.parent_name)
+ publish_type, i.parent_name)
if repair_checksheet['status'] == 1:
publish_repair_checksheet = 1
repair_checksheet_tmp.append(
@@ -841,7 +812,7 @@ def repair_checksheet_publish(vehicle, vehicle_id,
'data': repair_checksheet_tmp})
if os.path.isfile(check_inter_file):
- # frappe.log_error(str('internal aleady exists'))
+
with open(check_inter_file) as f:
published_data = json.load(f)
for i in parent:
@@ -851,12 +822,11 @@ def repair_checksheet_publish(vehicle, vehicle_id,
publish_repair_checksheet = 1
repair_checksheet_tmp1.append(
repair_checksheet['data'][0])
- # frappe.log_error('before' + str(repair_checksheet_tmp1))
+
repair_checksheet_tmp = get_latest_data({'data': published_data['data']}, {
'data': repair_checksheet_tmp1})
-
+
else:
- # frappe.log_error(str('new internal publish'))
for i in parent:
repair_checksheet = repair_checksheet_data(
vehicle, language, publish_type, i.parent_name)
@@ -866,28 +836,25 @@ def repair_checksheet_publish(vehicle, vehicle_id,
if len(repair_checksheet['data']):
repair_checksheet_tmp.append(
repair_checksheet['data'][0])
- # frappe.msgprint(str(repair_checksheet['data'][0]))
+
repair_checksheet_tmp = get_latest_data(
{'data': repair_checksheet_tmp}, {'data': []})
- # frappe.log_error('new pub data' +str(repair_checksheet_tmp))
if publish_type == "Global":
- #Remove Internal File On Global Publish
- internal_check = folder_url + "/" + 'Internal' + "/" + \
- vehicle.replace(' ', '-') + '-repair_check_sheet' + '.json'
+ """ Remove Internal File On Global Publish """
+ internal_check = folder_url + "/" + 'Internal' + "/" + \
+ vehicle.replace(' ', '-') + '-repair_check_sheet' + '.json'
if os.path.isfile(internal_check):
os.remove(internal_check)
if publish_repair_checksheet == 1:
""" Save publish file """
vehicle_data['data'] = repair_checksheet_tmp
- # frappe.log_error(str(file_path))
with open(file_path, 'w') as outfile:
outfile.write(json.dumps(vehicle_data, indent=4, default=str))
return 1, file_path
-
except Exception as e:
logger.info(
@@ -900,6 +867,7 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
release_description=None, parent=None,
variant=None):
try:
+
logger_file = f'{vehicle} - {language} - {publish_type} - {module_name} - {variant}'
logger = frappe.logger(logger_file,
allow_site=True, file_count=100)
@@ -909,7 +877,7 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
folder_url = base_url+"/"+vehicle.replace(' ', '-') + "/"+language
logger.info(f'Created Folder-{vehicle}-{language}-{publish_type}')
- '''Final Json'''
+ """ Final Json """
vehicle_data = {
'vehicle': vehicle,
'vehicle_myid': vehicle_id,
@@ -921,28 +889,32 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
latest_pub_data = vehicle_data.copy()
- '''Publish Ready Flags'''
+ """ Publish Ready Flags """
publish_feature_finder = 0
feature_finder_tmp = []
- '''Create Folder For Publish'''
+ """ Create Folder For Publish """
create_publish_folders(folder_url)
- full_update_folder_url = folder_url + "/" + "{}".format(publish_type)+"_Full_Update"
+ full_update_folder_url = folder_url + "/" + \
+ "{}".format(publish_type)+"_Full_Update"
file_path = folder_url + "/" + publish_type + "/" + \
vehicle.replace(' ', '-') + '-feature_finder' + '.json'
global_file_path = folder_url + "/" + 'Global' + "/" + \
vehicle.replace(' ', '-') + '-feature_finder' + '.json'
- full_update_file = full_update_folder_url+"/" + vehicle.replace(' ', '-') + '-feature_finder_full_update' + '.json'
+ full_update_file = full_update_folder_url+"/" + \
+ vehicle.replace(' ', '-') + '-feature_finder_full_update' + '.json'
global_full_update_path = folder_url + "/" + "Global_Full_Update"
- check_glbl_full_updte = global_full_update_path+"/" + vehicle.replace(' ', '-') + '-feature_finder_full_update' + '.json'
+ check_glbl_full_updte = global_full_update_path+"/" + \
+ vehicle.replace(' ', '-') + '-feature_finder_full_update' + '.json'
- '''Append Published Data to Json'''
+ """ Append Published Data to Json """
logger.info(
f'Feature Data Append Start::{vehicle}-{language}-{publish_type}')
- '''update existing global json file'''
+ """ update existing global json file """
if os.path.isfile(global_file_path) and publish_type == 'Internal':
+ frappe.log_error('internal')
if os.path.isfile(check_glbl_full_updte):
with open(check_glbl_full_updte) as f:
published_data = json.load(f)
@@ -955,8 +927,8 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
feature_finder['data'][0])
feature_finder_tmp = create_df(feature_finder_tmp)
latest_pub_data['data'] = feature_finder_tmp
- vehi_data = compare_get_data({'data': latest_pub_data['data']}, {
- 'data': feature_finder_tmp})
+ vehi_data = compare_get_data({'data': published_data['data']}, {
+ 'data': feature_finder_tmp})
if vehi_data:
find_distinct = set(exisitng_var)
new_variant_name = [
@@ -965,10 +937,14 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
vehi_data, new_variant_name, feature_finder_tmp)
elif os.path.isfile(file_path) and publish_type == 'Global':
- # frappe.log_error('inside')
+ frappe.log_error('gobal')
full_update_folder_url_internal = folder_url + "/" + "Internal_Full_Update"
- #Remove Internal Full Update File On Global Publish
- existing_internal_full_update = full_update_folder_url_internal+"/" + vehicle.replace(' ', '-') + '-feature_finder_full_update' + '.json'
+
+ """ 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)
with open(check_glbl_full_updte) as f:
@@ -982,7 +958,7 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
feature_finder['data'][0])
feature_finder_tmp = create_df(feature_finder_tmp)
latest_pub_data['data'] = feature_finder_tmp
- vehi_data = compare_get_data({'data': latest_pub_data['data']}, {
+ vehi_data = compare_get_data({'data': published_data['data']}, {
'data': feature_finder_tmp})
if vehi_data:
find_distinct = set(exisitng_var)
@@ -991,15 +967,17 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
vehi_data = add_new_val(
vehi_data, new_variant_name, feature_finder_tmp)
else:
- #Existing Global or Internal Full Update
-
- internal_full_update_check = full_update_folder_url = folder_url + "/" +"Internal_Full_Update"
- check_full_update_file = internal_full_update_check+"/" + vehicle.replace(' ', '-') + '-feature_finder_full_update' + '.json'
- if os.path.isfile(check_full_update_file):
+ """ Existing Global or Internal Full Update """
+
+ internal_full_update_check = folder_url + "/" + "Internal_Full_Update"
+ check_full_update_file = internal_full_update_check+"/" + \
+ vehicle.replace(' ', '-') + \
+ '-feature_finder_full_update' + '.json'
+ if os.path.isfile(check_full_update_file) and publish_type != "Global":
+ frappe.log_error('already internal')
with open(check_full_update_file) as f:
published_data = json.load(f)
for i in parent:
- # frappe.log_error("i",str(parent))
feature_finder = feature_finder_data(
vehicle, language, publish_type, i.parent1, i.variant)
if feature_finder['status'] == 1:
@@ -1013,8 +991,8 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
feature_finder_tmp = create_df(feature_finder_tmp)
latest_pub_data['data'] = feature_finder_tmp
- vehi_data = compare_get_data({'data': published_data}, {
- 'data': feature_finder_tmp})
+ vehi_data = compare_get_data({'data': published_data['data']}, {
+ 'data': feature_finder_tmp})
if vehi_data:
find_distinct = set(exisitng_var)
new_variant_name = [
@@ -1023,50 +1001,49 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
vehi_data, new_variant_name, feature_finder_tmp)
vehicle_data['data'] = vehi_data
-
- #First Time Global Or Internal
+
else:
+ """ First Time Global Or Internal """
+ frappe.log_error("first time global")
for i in parent:
- # frappe.log_error("619",str(parent))
feature_finder = feature_finder_data(
vehicle, language, publish_type, i.parent1, i.variant)
-
+
if feature_finder['status'] == 1:
publish_feature_finder = 1
- if len(feature_finder['data'])>0:
+ if len(feature_finder['data']) > 0:
feature_finder_tmp.append(
feature_finder['data'][0])
else:
frappe.throw('failed to publish')
feature_finder_tmp = get_latest_data(
{'data': feature_finder_tmp}, {'data': []})
- # frappe.log_error(str(feature_finder_tmp))
vehi_data = create_df(feature_finder_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
- existing_internal_full_update = full_update_folder_url_internal+"/" + vehicle.replace(' ', '-') + '-feature_finder_full_update' + '.json'
- # frappe.log_error('file_path' + str(existing_internal_full_update))
+
+ """ 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)
""" Save publish file """
vehicle_data['data'] = vehi_data
-
+
with open(file_path, 'w') as outfile:
outfile.write(json.dumps(latest_pub_data, indent=4, default=str))
-
with open(full_update_file, 'w') as outfile:
outfile.write(json.dumps(vehicle_data, indent=4, default=str))
-
-
-
+
logger.info(
f'Repair Checksheet Data Append Start::{vehicle}-{language}-{publish_type}')
- return 1, file_path
+ return 1, full_update_file
except Exception as e:
logger.info(
@@ -1074,10 +1051,10 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
frappe.throw('Failed To Publish')
-def qwik_service_publish(vehicle=None, vehicle_id=None,variant=None,
- language=None, publish_type=None,
- release_description=None, parent=None
- ):
+def qwik_service_publish(vehicle=None, vehicle_id=None, variant=None,
+ language=None, publish_type=None,
+ release_description=None, parent=None
+ ):
try:
logger_file = f'{vehicle} - {language} - {publish_type} - {module_name} - {variant}'
logger = frappe.logger(logger_file,
@@ -1106,16 +1083,19 @@ def qwik_service_publish(vehicle=None, vehicle_id=None,variant=None,
'''Create Folder For Publish'''
create_publish_folders(folder_url)
- full_update_folder_url = folder_url + "/" + "{}".format(publish_type)+"_Full_Update"
+ full_update_folder_url = folder_url + "/" + \
+ "{}".format(publish_type)+"_Full_Update"
file_path = folder_url + "/" + publish_type + "/" + \
vehicle.replace(' ', '-') + '- qwik_service' + '.json'
global_file_path = folder_url + "/" + 'Global' + "/" + \
vehicle.replace(' ', '-') + '- qwik_service' + '.json'
- full_update_file = full_update_folder_url+"/" + vehicle.replace(' ', '-') + '-qwik_service_full_update' + '.json'
-
+ full_update_file = full_update_folder_url+"/" + \
+ vehicle.replace(' ', '-') + '-qwik_service_full_update' + '.json'
+
global_full_update_path = folder_url + "/" + "Global_Full_Update"
- check_glbl_full_updte = global_full_update_path+"/" + vehicle.replace(' ', '-') + '-qwik_service_full_update' + '.json'
+ check_glbl_full_updte = global_full_update_path+"/" + \
+ vehicle.replace(' ', '-') + '-qwik_service_full_update' + '.json'
'''Append Published Data to Json'''
@@ -1128,14 +1108,14 @@ def qwik_service_publish(vehicle=None, vehicle_id=None,variant=None,
published_data = json.load(f)
for i in parent:
qwik_service = qwik_service_data(vehicle, language,
- publish_type, i.parent1, i.variant)
+ publish_type, i.parent1, i.variant)
if qwik_service['status'] == 1:
publish_qwik_service = 1
qwik_service_tmp.append(
qwik_service['data'][0])
qwik_service_tmp = create_df(qwik_service_tmp)
latest_pub_data['data'] = qwik_service_tmp
- vehi_data = compare_get_data({'data': latest_pub_data['data']}, {
+ vehi_data = compare_get_data({'data': published_data['data']}, {
'data': qwik_service_tmp})
if vehi_data:
find_distinct = set(exisitng_var)
@@ -1145,18 +1125,19 @@ def qwik_service_publish(vehicle=None, vehicle_id=None,variant=None,
vehi_data, new_variant_name, qwik_service_tmp)
elif os.path.isfile(file_path) and publish_type == 'Global':
- # frappe.log_error('inside')
+
full_update_folder_url_internal = folder_url + "/" + "Internal_Full_Update"
- #Remove Internal Full Update File On Global Publish
- existing_internal_full_update = full_update_folder_url_internal+"/" + vehicle.replace(' ', '-') + '-qwik_service_full_update' + '.json'
- # frappe.log_error('file_path' + str(existing_internal_full_update))
+ """ Remove Internal Full Update File On Global Publish """
+ existing_internal_full_update = full_update_folder_url_internal+"/" + \
+ 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:
published_data = json.load(f)
for i in parent:
qwik_service = qwik_service_data(vehicle, language,
- publish_type, i.parent1, i.variant)
+ publish_type, i.parent1, i.variant)
if qwik_service['status'] == 1:
publish_qwik_service = 1
qwik_service_tmp.append(
@@ -1172,12 +1153,12 @@ def qwik_service_publish(vehicle=None, vehicle_id=None,variant=None,
vehi_data = add_new_val(
vehi_data, new_variant_name, qwik_service_tmp)
else:
- #Existing Global or Internal Full Update
- internal_full_update_check = folder_url + "/" +"Internal_Full_Update"
- check_full_update_file = internal_full_update_check+"/" + vehicle.replace(' ', '-') + '-qwik_service_full_update' + '.json'
- # frappe.log_error(str(check_full_update_file))
- if os.path.isfile(check_full_update_file):
- # frappe.log_error(str('inside internal publish'))
+ """ Existing Global or Internal Full Update """
+ internal_full_update_check = folder_url + "/" + "Internal_Full_Update"
+ check_full_update_file = internal_full_update_check+"/" + \
+ vehicle.replace(' ', '-') + \
+ '-qwik_service_full_update' + '.json'
+ if os.path.isfile(check_full_update_file) and publish_type != "Global":
with open(check_full_update_file) as f:
published_data = json.load(f)
for i in parent:
@@ -1186,7 +1167,6 @@ def qwik_service_publish(vehicle=None, vehicle_id=None,variant=None,
if qwik_service['status'] == 1:
publish_qwik_service = 1
-
if len(qwik_service['data']):
qwik_service_tmp.append(
qwik_service['data'][0])
@@ -1196,7 +1176,7 @@ def qwik_service_publish(vehicle=None, vehicle_id=None,variant=None,
latest_pub_data['data'] = qwik_service_tmp
vehi_data = compare_get_data({'data': published_data['data']}, {
- 'data': qwik_service_tmp})
+ 'data': qwik_service_tmp})
if vehi_data:
find_distinct = set(exisitng_var)
new_variant_name = [
@@ -1211,47 +1191,41 @@ def qwik_service_publish(vehicle=None, vehicle_id=None,variant=None,
vehi_data = add_new_val(
vehi_data, new_variant_name, qwik_service_tmp)
vehicle_data['data'] = vehi_data
-
- #First Time Global Or Internal
+
else:
-
- # frappe.log_error("211"+str(parent))
+ """ First Time Global Or Internal """
for i in parent:
-
qwik_service = qwik_service_data(
vehicle, language, publish_type, i.parent1, i.variant)
-
+
if qwik_service['status'] == 1:
publish_qwik_service = 1
- if len(qwik_service['data'])>0:
+ if len(qwik_service['data']) > 0:
qwik_service_tmp.append(
qwik_service['data'][0])
else:
frappe.throw('failed to publish')
qwik_service_tmp = get_latest_data(
{'data': qwik_service_tmp}, {'data': []})
- # frappe.log_error(str(qwik_service_tmp))
vehi_data = create_df(qwik_service_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
- existing_internal_full_update = full_update_folder_url_internal+"/" + vehicle.replace(' ', '-') + '-qwik_service_full_update' + '.json'
- # frappe.log_error('file_path' + str(existing_internal_full_update))
+ # Remove Internal Full Update File On Global Publish
+ existing_internal_full_update = full_update_folder_url_internal+"/" + \
+ vehicle.replace(' ', '-') + \
+ '-qwik_service_full_update' + '.json'
if os.path.isfile(existing_internal_full_update):
os.remove(existing_internal_full_update)
""" Save publish file """
vehicle_data['data'] = vehi_data
-
+
with open(file_path, 'w') as outfile:
outfile.write(json.dumps(latest_pub_data, indent=4, default=str))
-
with open(full_update_file, 'w') as outfile:
outfile.write(json.dumps(vehicle_data, indent=4, default=str))
-
-
-
+
logger.info(
f'Repair Checksheet Data Append Start::{vehicle}-{language}-{publish_type}')
@@ -1262,6 +1236,7 @@ def qwik_service_publish(vehicle=None, vehicle_id=None,variant=None,
f'{vehicle} - {language} - {publish_type} - {module_name} error in json creation' + str(e))
frappe.throw('Failed To Publish')
+
def special_tool_publish(vehicle, vehicle_id,
publish_type, release_description,
parent=None):
@@ -1274,18 +1249,18 @@ def special_tool_publish(vehicle, vehicle_id,
folder_url = base_url+"/"+vehicle.replace(' ', '-')
logger.info(f'Created Folder-{vehicle}-{publish_type}')
- '''Publish Ready Flags'''
+ """ Publish Ready Flags """
publish_special_tool = 0
special_tool_tmp = []
- '''Create Folder For Publish'''
+ """ Create Folder For Publish """
create_publish_folders(folder_url)
- file_path = folder_url + "/" + publish_type+"_Full_Update" + "/"+ \
+ file_path = folder_url + "/" + publish_type+"_Full_Update" + "/" + \
vehicle.replace(' ', '-') + '-special_tool' + '.json'
existing_global = folder_url + "/" + "Global_Full_Update" + "/" + \
vehicle.replace(' ', '-') + '-special_tool' + '.json'
- '''Append Published Data to Json'''
+ """ Append Published Data to Json """
logger.info(
f'Special tool Data Append Start::{vehicle}-{publish_type}')
vehicle_data = {
@@ -1296,7 +1271,7 @@ def special_tool_publish(vehicle, vehicle_id,
'data': ''
}
- '''update existing global json file'''
+ """ update existing global json file """
if os.path.isfile(existing_global) and publish_type == 'Internal':
with open(existing_global) as f:
published_data = json.load(f)
@@ -1325,14 +1300,13 @@ def special_tool_publish(vehicle, vehicle_id,
'data': special_tool_tmp})
else:
- internal_full_update_check = folder_url + "/" +"Internal_Full_Update"
- check_inter_full_update_file = internal_full_update_check +"/"+ \
- vehicle.replace(' ', '-') + '-special_tool' + '.json'
- # check if Internal Full Update Already Exist
- if os.path.isfile(check_inter_full_update_file):
- # frappe.log_error('inside_full_update')
+ internal_full_update_check = folder_url + "/" + "Internal_Full_Update"
+ check_inter_full_update_file = internal_full_update_check + "/" + \
+ vehicle.replace(' ', '-') + '-special_tool' + '.json'
+ """ check if Internal Full Update Already Exist """
+ if os.path.isfile(check_inter_full_update_file) and publish_type != "Global":
with open(check_inter_full_update_file) as f:
- published_data = json.load(f)
+ published_data = json.load(f)
for i in parent:
special_tool = special_tool_data(
@@ -1357,10 +1331,10 @@ def special_tool_publish(vehicle, vehicle_id,
special_tool_tmp = get_latest_data(
{'data': special_tool_tmp}, {'data': []})
if publish_type == "Global":
- #Remove Internal Full Update File On Global Publish
- internal_full_update_check = folder_url + "/" +"Internal_Full_Update"
- check_inter_full_update_file = internal_full_update_check +"/"+ \
- vehicle.replace(' ', '-') + '-special_tool' + '.json'
+ """ Remove Internal Full Update File On Global Publish """
+ internal_full_update_check = folder_url + "/" + "Internal_Full_Update"
+ check_inter_full_update_file = internal_full_update_check + "/" + \
+ vehicle.replace(' ', '-') + '-special_tool' + '.json'
if os.path.isfile(check_inter_full_update_file):
os.remove(check_inter_full_update_file)
@@ -1424,11 +1398,9 @@ def torque_manual_publish(vehicle=None, vehicle_id=None,
check_glbl_full_updte = global_full_update_path+"/" + \
vehicle.replace(' ', '-') + '-torque_manual_full_update' + '.json'
- '''Append Published Data to Json'''
+ """ Append Published Data to Json """
- # logger.info(
- # f'Feature Data Append Start::{vehicle}-{language}-{publish_type}')
- '''update existing global json file'''
+ """ update existing global json file """
if os.path.isfile(global_file_path) and publish_type == 'Internal':
if os.path.isfile(check_glbl_full_updte):
with open(check_glbl_full_updte) as f:
@@ -1442,7 +1414,7 @@ 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': latest_pub_data['data']}, {
+ vehi_data = compare_get_data({'data': published_data['data']}, {
'data': torque_manual_tmp})
if vehi_data:
find_distinct = set(exisitng_var)
@@ -1452,13 +1424,13 @@ def torque_manual_publish(vehicle=None, vehicle_id=None,
vehi_data, new_variant_name, torque_manual_tmp)
elif os.path.isfile(file_path) and publish_type == 'Global':
- # frappe.log_error('inside')
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(' ', '-') + \
'-torque_manual_full_update' + '.json'
- # frappe.log_error('file_path' + str(existing_internal_full_update))
if os.path.isfile(existing_internal_full_update):
os.remove(existing_internal_full_update)
with open(check_glbl_full_updte) as f:
@@ -1472,7 +1444,7 @@ 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': latest_pub_data['data']}, {
+ vehi_data = compare_get_data({'data': published_data['data']}, {
'data': torque_manual_tmp})
if vehi_data:
find_distinct = set(exisitng_var)
@@ -1481,14 +1453,14 @@ def torque_manual_publish(vehicle=None, vehicle_id=None,
vehi_data = add_new_val(
vehi_data, new_variant_name, torque_manual_tmp)
else:
- # Existing Global or Internal Full Update
+ """ Existing Global or Internal Full Update """
internal_full_update_check = full_update_folder_url = folder_url + \
"/" + "Internal_Full_Update"
check_full_update_file = internal_full_update_check+"/" + \
vehicle.replace(' ', '-') + \
'-torque_manual_full_update' + '.json'
- if os.path.isfile(check_full_update_file):
+ if os.path.isfile(check_full_update_file) and publish_type != 'Global':
with open(check_full_update_file) as f:
published_data = json.load(f)
for i in parent:
@@ -1505,7 +1477,7 @@ def torque_manual_publish(vehicle=None, vehicle_id=None,
torque_manual_tmp = create_df(torque_manual_tmp)
latest_pub_data['data'] = torque_manual_tmp
- vehi_data = compare_get_data({'data': latest_pub_data['data']}, {
+ vehi_data = compare_get_data({'data': published_data['data']}, {
'data': torque_manual_tmp})
if vehi_data:
find_distinct = set(exisitng_var)
@@ -1516,8 +1488,8 @@ def torque_manual_publish(vehicle=None, vehicle_id=None,
vehicle_data['data'] = vehi_data
- # First Time Global Or Internal
else:
+ """ First Time Global Or Internal """
for i in parent:
torque_manual = torque_manual_data(
@@ -1538,7 +1510,7 @@ def torque_manual_publish(vehicle=None, vehicle_id=None,
if publish_type == "Global":
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(' ', '-') + \
'-torque_manual_full_update' + '.json'
@@ -1564,6 +1536,7 @@ def torque_manual_publish(vehicle=None, vehicle_id=None,
f'{vehicle} - {language} - {publish_type} - {module_name} error in json creation' + str(e))
frappe.throw('Failed To Publish')
+
def training_information_publish(vehicle, vehicle_id,
language, publish_type, release_description,
variant, parent):
@@ -1637,7 +1610,7 @@ def training_information_publish(vehicle, vehicle_id,
training_information_tmp = get_latest_data({'data': published_data['data']}, {
'data': training_information_tmp})
- if os.path.isfile(check_inter_file):
+ if os.path.isfile(check_inter_file) and publish_type != "Global":
with open(check_inter_file) as f:
published_data = json.load(f)
for i in parent:
@@ -1654,7 +1627,6 @@ def training_information_publish(vehicle, vehicle_id,
'data': training_information_tmp1})
else:
- # frappe.log_error(str('new internal publish'))
for i in parent:
training_information = training_information_data(
vehicle, language, publish_type, i.parent1)
@@ -1664,13 +1636,11 @@ def training_information_publish(vehicle, vehicle_id,
if len(training_information['data']):
training_information_tmp.append(
training_information['data'][0])
- # frappe.msgprint(str(repair_checksheet['data'][0]))
training_information_tmp = get_latest_data(
{'data': training_information_tmp}, {'data': []})
- # frappe.log_error('new pub data' + str(training_information_tmp))
if publish_type == "Global":
- # Remove Internal File On Global Publish
+ """ Remove Internal File On Global Publish """
internal_check = folder_url + "/" + 'Internal' + "/" + \
vehicle.replace(' ', '-') + '-training_information' + '.json'
if os.path.isfile(internal_check):
@@ -1679,8 +1649,6 @@ def training_information_publish(vehicle, vehicle_id,
""" Save publish file """
vehicle_data['data'] = training_information_tmp
- # frappe.log_error(str(file_path))
-
with open(file_path, 'w') as outfile:
outfile.write(json.dumps(vehicle_data, indent=4, default=str))
@@ -1790,20 +1758,7 @@ def check_key(key_name, old_data, type=None):
new_dict.update(val)
new_dict_lst.append(new_dict)
old_data[key] = new_dict_lst
- # for key,val in key_name.items():
- # if key in old_data:
- # if val['name'] in old_data:
- # for old_key,old_val in old_data.items():
- # for i in old_val:
- # if val['name'] in old_val :
- # if old_key == key and val['name'] == i['name']:
- # i.update(val)
- # else:
- # old_data[key].append(val)
-
- # else:
- # new_dict.append(val)
- # old_data[key]=new_dict
+
logger.info(f"end of key data"+str(key_name))
except Exception as e:
logger.error(str(e))
@@ -2001,17 +1956,13 @@ def special_tool_data(vehicle=None,
logger.info(
f"start of fetching special tool data - {parent}")
- special_tool_information = frappe.db.sql(''' select name,vehicle,tool_type,
- category,tool_name,aggregate_name,aggregate_image,
- pdf,keywords,display_order,my_id,active_status from
- `tabSpecial Tool Information`
- where name= '%s' ;''' % (parent), as_dict=1)
+ special_tool_information = frappe.db.sql(''' select name,vehicle,tool_type,category,tool_name,aggregate_name,aggregate_image,
+ pdf,keywords,display_order,my_id,active_status from `tabSpecial Tool Information`
+ where name= '%s' ;''' % (parent), as_dict=1)
for s in special_tool_information:
- s['instructions'] = frappe.db.sql('''select idx as 'display_order',step_name,
- content_type,content,attach_file
- from `tabInstructions` where parent = '%s'
- order by display_order;''' % (s['name']), as_dict=1)
+ s['instructions'] = frappe.db.sql('''select idx as 'display_order',step_name,content_type,content,attach_file
+ from `tabInstructions` where parent = '%s' order by display_order;''' % (s['name']), as_dict=1)
logger.info(
f"end of fetching special tool data {vehicle}")
@@ -2021,8 +1972,7 @@ def special_tool_data(vehicle=None,
return success_reponse
except Exception as e:
- failure_reponse['error'] = f"{vehicle} has following error - " + str(
- e)
+ failure_reponse['error'] = f"{vehicle} has following error - " + str(e)
logger.error('error in special tool' + str(e))
return failure_reponse
@@ -2035,8 +1985,9 @@ def torque_manual_data(vehicle=None, language=None,
allow_site=True, file_count=100)
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), as_dict=1)
+ 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_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)
@@ -2066,12 +2017,12 @@ def training_information_data(vehicle=None, language=None,
training_information_details = frappe.db.sql(f"""select name,vehicle,category,language,display_order,keywords,my_id,active_status from
`tabTraining Information` where vehicle = '{vehicle}'
- and language = '{language}'and name='{parent}' """, as_dict=1)
+ 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 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)
+ d['content'] = frappe.db.sql(f"""select idx as 'display_order',topic as file_type,case when topic != 'SCROM' 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)
logger.info(
f"end of fetching training informataion data {vehicle} - {language}")
@@ -2090,8 +2041,8 @@ def training_information_data(vehicle=None, language=None,
@frappe.whitelist()
def max_publish_new_module(doc):
doc = frappe.get_doc("Publish", doc)
- ver = frappe.db.sql("""select max(version) from {0}.`tabPublish` where vehicle = "{1}" and language = "{2}" and publish_module!="Automotive System";""".format(
- current_db_name, doc.vehicle, doc.language))
+ ver = frappe.db.sql("""select max(version) from {0}.`tabPublish` where vehicle = "{1}" and language = "{2}"
+ and publish_module!="Automotive System";""".format(current_db_name, doc.vehicle, doc.language))
if ver:
return ver
@@ -2140,7 +2091,8 @@ def get_service_repair(vehicle,
def get_feature_finder(vehicle=None, variant=None, language_label=None):
try:
data = frappe.db.sql(
- f"""select * from `tabFeature Finder` where vehicle='{vehicle}' and variant_id='{variant}' and language='{language_label}' and is_published=0""", as_dict=1)
+ f"""select * from `tabFeature Finder` where vehicle='{vehicle}' and variant_id='{variant}' and language='{language_label}'
+ and is_published=0;""", as_dict=1)
return data
except Exception as e:
return str(e)
@@ -2150,7 +2102,8 @@ def get_feature_finder(vehicle=None, variant=None, language_label=None):
def get_training_information(vehicle=None, language_label=None):
try:
data = frappe.db.sql('''
- select * from `tabTraining Information` where vehicle = '%s' and language='%s' and is_published = '%s';''' % (vehicle, language_label, 0), as_dict=1)
+ select * from `tabTraining Information` where vehicle = '%s' and language='%s' and is_published = '%s';''' % (
+ vehicle, language_label, 0), as_dict=1)
return data
except Exception as e:
return str(e)
@@ -2182,31 +2135,3 @@ def get_torque_manual(variant=None, language_label=None):
return data
except Exception as e:
return str(e)
-
-
-def extract_scrom_package(data, vehicle):
- try:
- base_path = BASE_URL_PUBLIC + "/" + "training" + "/" + vehicle
- scrom_path = base_path + "/" + "scrom"
-
- for d in data:
- if d['content']:
- for ch in d['content']:
- if ch['topic'] == 'SCROM' and ch['content'] != None:
- scrom_folder_path = base_path + "/" + "scrom" + \
- "/" + ch['content'].split("/")[2].split(".")[0]
- if not os.path.exists(scrom_folder_path):
- os.makedirs(scrom_folder_path)
- if ch['content']:
-
- with zipfile.ZipFile(BASE_URL_PUBLIC+ch['content'], 'r') as zip_ref:
- zip_ref.extractall(path=scrom_folder_path)
- ch['base_path'] = scrom_folder_path + \
- ch['content'].split("/")[2].split(".")[0]
- ch['file_url'] = ch['base_path']+"/"+ch['file_name']
- update_base_path = frappe.db.sql(
- f"""update `tabTraining Information Content Reference` set base_path = '{ch['base_path']}' and file_url ='{ch['file_url']}' where name='{ch['content']}'""")
- return {"success": 1, "data": data}
-
- except Exception as e:
- return "Extarction Failed"+str(e)