Browse Source

torque manual doctype

version2
venkata akhil 10 months ago
parent
commit
ab5c03a6fa
  1. 15
      smart_service/phase_2/doctype/feature_finder/feature_finder.js
  2. 2
      smart_service/phase_2/doctype/feature_finder/feature_finder.py
  3. 2
      smart_service/phase_2/doctype/qwik_service/qwik_service.js
  4. 4
      smart_service/phase_2/doctype/qwik_service/qwik_service.py
  5. 0
      smart_service/phase_2/doctype/torque_manual/__init__.py
  6. 2
      smart_service/phase_2/doctype/torque_manual/test_torque_manual.py
  7. 84
      smart_service/phase_2/doctype/torque_manual/torque_manual.js
  8. 134
      smart_service/phase_2/doctype/torque_manual/torque_manual.json
  9. 43
      smart_service/phase_2/doctype/torque_manual/torque_manual.py
  10. 0
      smart_service/phase_2/doctype/torque_manual_category/__init__.py
  11. 2
      smart_service/phase_2/doctype/torque_manual_category/test_torque_manual_category.py
  12. 2
      smart_service/phase_2/doctype/torque_manual_category/torque_manual_category.js
  13. 7
      smart_service/phase_2/doctype/torque_manual_category/torque_manual_category.json
  14. 2
      smart_service/phase_2/doctype/torque_manual_category/torque_manual_category.py
  15. 0
      smart_service/phase_2/doctype/torque_manual_details/__init__.py
  16. 6
      smart_service/phase_2/doctype/torque_manual_details/torque_manual_details.json
  17. 2
      smart_service/phase_2/doctype/torque_manual_details/torque_manual_details.py
  18. 0
      smart_service/phase_2/doctype/torque_manual_subcategory/__init__.py
  19. 2
      smart_service/phase_2/doctype/torque_manual_subcategory/test_torque_manual_subcategory.py
  20. 2
      smart_service/phase_2/doctype/torque_manual_subcategory/torque_manual_subcategory.js
  21. 7
      smart_service/phase_2/doctype/torque_manual_subcategory/torque_manual_subcategory.json
  22. 2
      smart_service/phase_2/doctype/torque_manual_subcategory/torque_manual_subcategory.py
  23. 68
      smart_service/phase_2/doctype/torque_master/torque_master.json
  24. 90
      smart_service/phase_2/doctype/training_information/training_information.js
  25. 31
      smart_service/phase_2/doctype/training_information/training_information.json
  26. 130
      smart_service/phase_2/doctype/training_information/training_information.py
  27. 0
      smart_service/phase_2/doctype/training_information_category/__init__.py
  28. 2
      smart_service/phase_2/doctype/training_information_category/test_training_information_category.py
  29. 2
      smart_service/phase_2/doctype/training_information_category/training_information_category.js
  30. 22
      smart_service/phase_2/doctype/training_information_category/training_information_category.json
  31. 2
      smart_service/phase_2/doctype/training_information_category/training_information_category.py
  32. 26
      smart_service/phase_2/doctype/training_information_content_reference/training_information_content_reference.json
  33. 32
      smart_service/phase_2/doctype/training_information_master/training_information_master.js
  34. 22
      smart_service/phase_2/doctype/training_information_master/training_information_master.py

15
smart_service/phase_2/doctype/feature_finder/feature_finder.js

@ -985,7 +985,10 @@ function custom_tab_html(frm) {
},
callback: function (r) {
if (r.message.status == "success") {
frappe.msgprint("Submited data will be auto saved")
frappe.show_alert({
message: __('Submited data will be auto saved'),
indicator: 'green'
}, 15);
cur_frm.reload_doc()
cur_frm.refresh()
}
@ -1077,7 +1080,10 @@ function custom_tab_html(frm) {
},
callback: function (r) {
if (r.message.status == "success") {
frappe.msgprint("Submited data will be auto saved")
frappe.show_alert({
message: __('Submited data will be auto saved'),
indicator: 'green'
}, 15);
cur_frm.reload_doc()
cur_frm.refresh()
}
@ -1154,7 +1160,10 @@ function custom_tab_html(frm) {
},
callback: function (r) {
if (r.message.status == "success") {
frappe.msgprint("Submited data will be auto saved")
frappe.show_alert({
message: __('Submited data will be auto saved'),
indicator: 'green'
}, 15);
cur_frm.reload_doc()
cur_frm.refresh()
}

2
smart_service/phase_2/doctype/feature_finder/feature_finder.py

@ -203,7 +203,7 @@ def delete_image_data(values,doc_name):
@frappe.whitelist()
def insert_content_data(doc_name, values, tab_ref):
def insert_content_data(doc_name, values, tab_ref=None):
try:
val = json.loads(values)
get_count = frappe.db.sql("""select name from `tabFeature Finder Content` where parent='%s' and

2
smart_service/phase_2/doctype/qwik_service/qwik_service.js

@ -412,7 +412,7 @@ function custom_tab_html(frm){
function set_display_order(frm){
if (frm.is_new()) {
if (frm.is_new()) {
frm.set_df_property('display_order', 'read_only', 1);
} else {
frm.set_df_property('display_order', 'read_only', 0);

4
smart_service/phase_2/doctype/qwik_service/qwik_service.py

@ -16,10 +16,10 @@ class QwikService(Document):
for d in check_exe:
self.display_order = d['display_order']
self.active_status = d['active_status']
if not check_exe:
if not check_exe:
if self.language != "en":
frappe.throw("First language will be english only")
count = frappe.db.sql('''select max(my_id) as max_count from `tabSpecial Tool Information`;''')
count = frappe.db.sql('''select max(my_id) as max_count from `tabQwik Service`;''')
if count[0][0] is not None:
self.my_id = count[0][0] + 1
else:

0
smart_service/phase_2/doctype/torque_category/__init__.py → smart_service/phase_2/doctype/torque_manual/__init__.py

2
smart_service/phase_2/doctype/torque_master/test_torque_master.py → smart_service/phase_2/doctype/torque_manual/test_torque_manual.py

@ -4,5 +4,5 @@
# import frappe
import unittest
class TestTorqueMaster(unittest.TestCase):
class TestTorqueManual(unittest.TestCase):
pass

84
smart_service/phase_2/doctype/torque_manual/torque_manual.js

@ -0,0 +1,84 @@
// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
// For license information, please see license.txt
var vehicle_count = 0;
var original_display_order = 0;
frappe.ui.form.on('Torque Manual', {
refresh: function(frm) {
frm.set_query("variant", function() {
return {
"filters": {
"active_status": "Active",
}
};
});
set_display_order(frm)
},
onload:function(frm){
set_display_order(frm)
},
validate:function(frm){
cur_frm.refresh_fields("display_order")
if (frm.doc.display_order && frm.doc.name && !frm.is_new()) {
//***check if there is same display_order
frappe.db.get_list('Torque Manual', {
fields: ['display_order', 'name'],
filters: {
display_order: frm.doc.display_order,
name: ["!=", frm.doc.name],
variant: frm.doc.variant,
language: frm.doc.language
}
}).then(records => {
console.log(records)
if (records.length) {
frappe.db.set_value('Torque Manual', records[0].name, {
display_order: original_display_order
}).then(r => {
// console.log("display",str(r))
let doc = r.message;
frappe.show_alert({
message: __('Swapped display order with: ' + records[0].name),
indicator: 'green'
}, 5);
});
} else {
// if (frm.doc.display_order >= vehicle_count) {
// let display_vehicle_count = vehicle_count - 1;
// msgprint('There are only ' + display_vehicle_count + " " + frm.doc.doctype);
// frappe.validated = false;
// }
}
});
}
},
after_save: function (frm) {
cur_frm.refresh_fields("display_order")
},
vehicle: function(frm){
set_display_order(frm)
},
});
function set_display_order(frm){
if (frm.is_new()) {
frm.set_df_property('display_order', 'read_only', 1);
} else {
frm.set_df_property('display_order', 'read_only', 0);
}
frappe.db.count('Torque Manual', {
filters: {
"variant": frm.doc.variant,
"language": frm.doc.language
}
}).then(count => {
console.log("counts",count)
vehicle_count = count + 1;
if (frm.is_new()) {
frm.set_value("display_order", vehicle_count);
} else {
original_display_order = frm.doc.display_order;
}
});
}

134
smart_service/phase_2/doctype/torque_manual/torque_manual.json

@ -0,0 +1,134 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "format:{variant}-{category}-{sub_category}-{language}",
"creation": "2023-12-01 10:31:27.784999",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"is_published",
"section_break_qg2b0",
"variant",
"vehicle",
"language",
"active_status",
"column_break_gkwxt",
"category",
"sub_category",
"my_id",
"display_order",
"section_break_cmyhs",
"torque_table"
],
"fields": [
{
"fieldname": "category",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Category",
"options": "Torque Manual Category",
"reqd": 1,
"set_only_once": 1
},
{
"fieldname": "column_break_gkwxt",
"fieldtype": "Column Break"
},
{
"fieldname": "sub_category",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Sub Category",
"options": "Torque Manual Subcategory",
"reqd": 1,
"set_only_once": 1
},
{
"fieldname": "section_break_cmyhs",
"fieldtype": "Section Break"
},
{
"fieldname": "torque_table",
"fieldtype": "Table",
"label": "Torque Table",
"options": "Torque Manual Details"
},
{
"fieldname": "display_order",
"fieldtype": "Int",
"label": "Display Order"
},
{
"fieldname": "my_id",
"fieldtype": "Int",
"hidden": 1,
"label": "My ID"
},
{
"fieldname": "variant",
"fieldtype": "Link",
"in_standard_filter": 1,
"label": "Variant",
"options": "Variant Mapping",
"reqd": 1,
"set_only_once": 1
},
{
"fetch_from": "variant.vehicle",
"fieldname": "vehicle",
"fieldtype": "Data",
"label": "Vehicle"
},
{
"fieldname": "language",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Language",
"options": "Custom Languages",
"set_only_once": 1
},
{
"fieldname": "active_status",
"fieldtype": "Select",
"label": "Active Status",
"options": "Active\nInactive"
},
{
"default": "0",
"fieldname": "is_published",
"fieldtype": "Check",
"label": "Published"
},
{
"fieldname": "section_break_qg2b0",
"fieldtype": "Section Break"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-01 12:59:18.226290",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Manual",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC"
}

43
smart_service/phase_2/doctype/torque_manual/torque_manual.py

@ -0,0 +1,43 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
import frappe
from frappe.model.document import Document
class TorqueManual(Document):
def validate(self):
try:
if self.is_new():
if self.variant and self.language:
check_exe=frappe.db.sql('''select * from `tabTorque Manual` where variant='%s' and language ='en' and name !='%s'; '''%(self.variant,self.name),as_dict=1)
if check_exe:
if self.language != "en":
for d in check_exe:
self.display_order = d['display_order']
self.active_status = d['active_status']
if not check_exe:
if self.language != "en":
frappe.throw("First language will be english only")
count = frappe.db.sql('''select max(my_id) as max_count from `tabTorque Manual`;''')
if count[0][0] is not None:
self.my_id = count[0][0] + 1
else:
self.my_id = 1
except Exception as e:
raise e
def on_update(self):
if self.language == "en":
try:
check_exe = frappe.db.get_list("Torque Manual",
filters={"variant": self.variant, "language": ["!=", "en"],
"name": ["!=", self.name]},
fields={"name", "language", "display_order", "active_status"})
if check_exe:
for i in check_exe:
res = frappe.get_doc(
"Torque Manual", i['name'])
res.display_order = self.display_order
res.active_status = self.active_status
res.save()
except Exception as e:
raise e

0
smart_service/phase_2/doctype/torque_details/__init__.py → smart_service/phase_2/doctype/torque_manual_category/__init__.py

2
smart_service/phase_2/doctype/torque_category/test_torque_category.py → smart_service/phase_2/doctype/torque_manual_category/test_torque_manual_category.py

@ -4,5 +4,5 @@
# import frappe
import unittest
class TestTorqueCategory(unittest.TestCase):
class TestTorqueManualCategory(unittest.TestCase):
pass

2
smart_service/phase_2/doctype/torque_subcategory/torque_subcategory.js → smart_service/phase_2/doctype/torque_manual_category/torque_manual_category.js

@ -1,7 +1,7 @@
// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
// For license information, please see license.txt
frappe.ui.form.on('Torque Subcategory', {
frappe.ui.form.on('Torque Manual Category', {
// refresh: function(frm) {
// }

7
smart_service/phase_2/doctype/torque_category/torque_category.json → smart_service/phase_2/doctype/torque_manual_category/torque_manual_category.json

@ -1,7 +1,8 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-11-24 17:09:08.707664",
"autoname": "format:{category}",
"creation": "2023-12-01 10:33:34.472251",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
@ -17,10 +18,10 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-11-24 17:09:08.707664",
"modified": "2023-12-01 11:55:06.400326",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Category",
"name": "Torque Manual Category",
"owner": "Administrator",
"permissions": [
{

2
smart_service/phase_2/doctype/torque_master/torque_master.py → smart_service/phase_2/doctype/torque_manual_category/torque_manual_category.py

@ -4,5 +4,5 @@
# import frappe
from frappe.model.document import Document
class TorqueMaster(Document):
class TorqueManualCategory(Document):
pass

0
smart_service/phase_2/doctype/torque_master/__init__.py → smart_service/phase_2/doctype/torque_manual_details/__init__.py

6
smart_service/phase_2/doctype/torque_details/torque_details.json → smart_service/phase_2/doctype/torque_manual_details/torque_manual_details.json

@ -1,7 +1,7 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-11-24 17:09:41.181853",
"creation": "2023-12-01 10:31:58.622549",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
@ -47,10 +47,10 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-11-24 17:11:33.158796",
"modified": "2023-12-01 10:31:58.622549",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Details",
"name": "Torque Manual Details",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",

2
smart_service/phase_2/doctype/torque_category/torque_category.py → smart_service/phase_2/doctype/torque_manual_details/torque_manual_details.py

@ -4,5 +4,5 @@
# import frappe
from frappe.model.document import Document
class TorqueCategory(Document):
class TorqueManualDetails(Document):
pass

0
smart_service/phase_2/doctype/torque_subcategory/__init__.py → smart_service/phase_2/doctype/torque_manual_subcategory/__init__.py

2
smart_service/phase_2/doctype/torque_subcategory/test_torque_subcategory.py → smart_service/phase_2/doctype/torque_manual_subcategory/test_torque_manual_subcategory.py

@ -4,5 +4,5 @@
# import frappe
import unittest
class TestTorqueSubcategory(unittest.TestCase):
class TestTorqueManualSubcategory(unittest.TestCase):
pass

2
smart_service/phase_2/doctype/torque_category/torque_category.js → smart_service/phase_2/doctype/torque_manual_subcategory/torque_manual_subcategory.js

@ -1,7 +1,7 @@
// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
// For license information, please see license.txt
frappe.ui.form.on('Torque Category', {
frappe.ui.form.on('Torque Manual Subcategory', {
// refresh: function(frm) {
// }

7
smart_service/phase_2/doctype/torque_subcategory/torque_subcategory.json → smart_service/phase_2/doctype/torque_manual_subcategory/torque_manual_subcategory.json

@ -1,7 +1,8 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-11-24 17:09:21.527639",
"autoname": "format:{sub_category}",
"creation": "2023-12-01 10:32:52.875051",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
@ -17,10 +18,10 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-11-24 17:09:21.527639",
"modified": "2023-12-01 11:55:42.941736",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Subcategory",
"name": "Torque Manual Subcategory",
"owner": "Administrator",
"permissions": [
{

2
smart_service/phase_2/doctype/torque_subcategory/torque_subcategory.py → smart_service/phase_2/doctype/torque_manual_subcategory/torque_manual_subcategory.py

@ -4,5 +4,5 @@
# import frappe
from frappe.model.document import Document
class TorqueSubcategory(Document):
class TorqueManualSubcategory(Document):
pass

68
smart_service/phase_2/doctype/torque_master/torque_master.json

@ -1,68 +0,0 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-11-24 17:10:52.598215",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"category",
"column_break_gkwxt",
"sub_category",
"section_break_cmyhs",
"torque_table"
],
"fields": [
{
"fieldname": "category",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Category",
"options": "Torque Category"
},
{
"fieldname": "sub_category",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Sub Category",
"options": "Torque Subcategory"
},
{
"fieldname": "torque_table",
"fieldtype": "Table",
"label": "Torque Table",
"options": "Torque Details"
},
{
"fieldname": "column_break_gkwxt",
"fieldtype": "Column Break"
},
{
"fieldname": "section_break_cmyhs",
"fieldtype": "Section Break"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-11-24 17:12:07.675053",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Master",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC"
}

90
smart_service/phase_2/doctype/training_information/training_information.js

@ -9,37 +9,37 @@ frappe.ui.form.on('Training Information', {
},
refresh: function (frm) {
set_display_order(frm)
frm.set_query("category", function() {
return {
"filters": {
"active_status": "Active",
}
};
});
// frm.set_query("category", function() {
// return {
// "filters": {
// "active_status": "Active",
// }
// };
// });
},
validate:function(frm){
cur_frm.refresh_fields("display_order")
},
after_save: function (frm) {
if (frm.doc.content) {
frappe.call({
method: "smart_service.phase_2.doctype.training_information.training_information.file_validation_child",
args: {
name: frm.doc.name,
value:"content"
},
callback: function (r) {
console.log(r.message, "----file validation size-------")
if (r.message && r.message[0] == false) {
if (r.message[1]) {
frappe.validated = false;
frm.reload_doc()
frappe.throw("In training information content " + r.message[1] + " row was invalid file type")
}
}
}
})
}
// if (frm.doc.content) {
// frappe.call({
// method: "smart_service.phase_2.doctype.training_information.training_information.file_validation_child",
// args: {
// name: frm.doc.name,
// value:"content"
// },
// callback: function (r) {
// console.log(r.message, "----file validation size-------")
// if (r.message && r.message[0] == false) {
// if (r.message[1]) {
// frappe.validated = false;
// frm.reload_doc()
// frappe.throw("In training information content " + r.message[1] + " row was invalid file type")
// }
// }
// }
// })
// }
}
});
function set_display_order(frm){
@ -64,24 +64,24 @@ function set_display_order(frm){
}
});
}
frappe.ui.form.on('Training Information Content Reference',{
content_type: function (frm, cdt, cdn) {
var select_value = locals[cdt][cdn]
var x = select_value.idx - 1;
let my_row = frm.fields_dict.content.grid.grid_rows[x];
if (select_value.content_type == 'Image' || select_value.content_type == 'Video'){
cur_frm.get_field("content").grid.grid_rows[x].columns.image_video.df.read_only = 0;
cur_frm.get_field("content").grid.grid_rows[x].columns.content.df.read_only = 1;
cur_frm.refresh_fields("content")
}
else {
cur_frm.get_field("content").grid.grid_rows[x].columns.image_video.df.read_only = 1;
cur_frm.get_field("content").grid.grid_rows[x].columns.content.df.read_only = 0;
cur_frm.refresh_fields("content")
}
cur_frm.refresh_field("content");
cur_frm.refresh_field();
},
// frappe.ui.form.on('Training Information Content Reference',{
// content_type: function (frm, cdt, cdn) {
// var select_value = locals[cdt][cdn]
// var x = select_value.idx - 1;
// let my_row = frm.fields_dict.content.grid.grid_rows[x];
// if (select_value.content_type == 'Image' || select_value.content_type == 'Video'){
// cur_frm.get_field("content").grid.grid_rows[x].columns.image_video.df.read_only = 0;
// cur_frm.get_field("content").grid.grid_rows[x].columns.content.df.read_only = 1;
// cur_frm.refresh_fields("content")
// }
// else {
// cur_frm.get_field("content").grid.grid_rows[x].columns.image_video.df.read_only = 1;
// cur_frm.get_field("content").grid.grid_rows[x].columns.content.df.read_only = 0;
// cur_frm.refresh_fields("content")
// }
// cur_frm.refresh_field("content");
// cur_frm.refresh_field();
// },
// validate:function(frm){
// let task_index = row.docfields.findIndex(x => x.fieldname === "content");
// if (row.doc.asset_type == 'Image' || row.doc.asset_type == 'Video') {
@ -96,4 +96,4 @@ frappe.ui.form.on('Training Information Content Reference',{
// refresh_field();
// }
})
// })

31
smart_service/phase_2/doctype/training_information/training_information.json

@ -1,6 +1,4 @@
{
"_comments": "[]",
"_liked_by": "[]",
"actions": [],
"allow_rename": 1,
"autoname": "format:{vehicle}-{category}-{topic}-{language}",
@ -9,15 +7,14 @@
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"published",
"is_published",
"section_break_jqjts",
"vehicle",
"category",
"topic",
"display_order",
"column_break_tweld",
"language",
"active_status",
"display_order",
"section_break_6ucxv",
"content",
"section_break_6kjyf",
@ -30,6 +27,7 @@
"in_list_view": 1,
"label": "Vehicle",
"options": "Vehicle",
"reqd": 1,
"set_only_once": 1
},
{
@ -37,15 +35,9 @@
"fieldtype": "Link",
"in_list_view": 1,
"label": "Category",
"options": "Training Information Master",
"options": "Training Information Category",
"set_only_once": 1
},
{
"fetch_from": "category.topic",
"fieldname": "topic",
"fieldtype": "Data",
"label": "Topic"
},
{
"fieldname": "language",
"fieldtype": "Link",
@ -94,21 +86,20 @@
"in_list_view": 1,
"label": "Display Order"
},
{
"default": "0",
"fieldname": "published",
"fieldtype": "Check",
"label": "Published",
"read_only": 1
},
{
"fieldname": "section_break_jqjts",
"fieldtype": "Section Break"
},
{
"default": "0",
"fieldname": "is_published",
"fieldtype": "Check",
"label": "Published"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-09-04 17:41:29.001031",
"modified": "2023-12-01 13:19:50.127628",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Training Information",

130
smart_service/phase_2/doctype/training_information/training_information.py

@ -6,60 +6,86 @@ from frappe.model.document import Document
class TrainingInformation(Document):
def validate(self):
if self.topic:
self.topic=self.topic.strip()
try:
if self.is_new():
if self.vehicle and self.language:
check_exe=frappe.db.sql('''select * from `tabTraining Information` where vehicle='%s' and language ='en' and name !='%s'; '''%(self.vehicle,self.name),as_dict=1)
if check_exe:
if self.language != "en":
for d in check_exe:
self.display_order = d['display_order']
self.active_status = d['active_status']
if not check_exe:
if self.language != "en":
frappe.throw("First language will be english only")
count = frappe.db.sql('''select max(my_id) as max_count from `tabTraining Information`;''')
if count[0][0] is not None:
self.my_id = count[0][0] + 1
else:
self.my_id = 1
except Exception as e:
raise e
if self.is_new():
count = frappe.db.sql('''select max(my_id) as max_count from `tabTraining Information`;''')
if count[0][0] is not None:
self.my_id = count[0][0] + 1
else:
self.my_id = 1
if not self.is_new() and self.published == 1:
self.published = 0
def on_update(self):
if self.language == "en":
try:
check_exe = frappe.db.get_list("Training Information",
filters={"vehicle": self.vehicle, "language": ["!=", "en"],
"name": ["!=", self.name]},
fields={"name", "language", "display_order", "active_status"})
if check_exe:
for i in check_exe:
res = frappe.get_doc(
"Training Information", i['name'])
res.display_order = self.display_order
res.active_status = self.active_status
res.save()
except Exception as e:
raise e
@frappe.whitelist()
def file_validation_child(name=None, value=None):
from smart_service.apis.utils import check_png_ext, check_img_ext, check_zip_ext, check_pdf_ext, details_of_image, checking_image, check_mp4_ext, get_file_size
if name:
child_data = frappe.db.sql(
"""select * from `tabTraining Information Content Reference` where parent='%s'"""%(name), as_dict=1)
for d in child_data:
if d['image_video']:
res = False
res1 = False
res2= False
if d['content_type'] == "Image":
res = check_img_ext(d['image_video'])
res1 = check_png_ext(d['image_video'])
else:
res2 = check_mp4_ext(d['image_video'])
# @frappe.whitelist()
# def file_validation_child(name=None, value=None):
# from smart_service.apis.utils import check_png_ext, check_img_ext, check_zip_ext, check_pdf_ext, details_of_image, checking_image, check_mp4_ext, get_file_size
# if name:
# child_data = frappe.db.sql(
# """select * from `tabTraining Information Content Reference` where parent='%s'"""%(name), as_dict=1)
# for d in child_data:
# if d['image_video']:
# res = False
# res1 = False
# res2= False
# if d['content_type'] == "Image":
# res = check_img_ext(d['image_video'])
# res1 = check_png_ext(d['image_video'])
# else:
# res2 = check_mp4_ext(d['image_video'])
if res == True or res1 == True:
width, height, size = details_of_image(
d['image_video'])
if width > 1280 or height > 720 or size > 1*1024 and d['image_video']:
val = checking_image(
d['image_video'], "Training Information", value, name, 1)
frappe.delete_doc("Training Information Content Reference", d['name'])
if val == True:
return False, d['idx']
else:
return True
elif res2 == True:
video_size_mb = get_file_size(d['image_video'])
if video_size_mb > 10:
frappe.delete_doc('Training Information Content Reference', d['name'])
return (False, d['idx'])
else:
if res == False and res1==False:
ret = res
else:
ret = res2
# if res == True or res1 == True:
# width, height, size = details_of_image(
# d['image_video'])
# if width > 1280 or height > 720 or size > 1*1024 and d['image_video']:
# val = checking_image(
# d['image_video'], "Training Information", value, name, 1)
# frappe.delete_doc("Training Information Content Reference", d['name'])
# if val == True:
# return False, d['idx']
# else:
# return True
# elif res2 == True:
# video_size_mb = get_file_size(d['image_video'])
# if video_size_mb > 10:
# frappe.delete_doc('Training Information Content Reference', d['name'])
# return (False, d['idx'])
# else:
# if res == False and res1==False:
# ret = res
# else:
# ret = res2
val = checking_image(
d['image_video'], 'Training Information', value, name, 1)
frappe.delete_doc('Training Information Content Reference', d['name'])
return (ret, d['idx'])
# val = checking_image(
# d['image_video'], 'Training Information', value, name, 1)
# frappe.delete_doc('Training Information Content Reference', d['name'])
# return (ret, d['idx'])

0
smart_service/phase_2/doctype/training_information_master/__init__.py → smart_service/phase_2/doctype/training_information_category/__init__.py

2
smart_service/phase_2/doctype/training_information_master/test_training_information_master.py → smart_service/phase_2/doctype/training_information_category/test_training_information_category.py

@ -4,5 +4,5 @@
# import frappe
import unittest
class TestTrainingInformationMaster(unittest.TestCase):
class TestTrainingInformationCategory(unittest.TestCase):
pass

2
smart_service/phase_2/doctype/torque_master/torque_master.js → smart_service/phase_2/doctype/training_information_category/training_information_category.js

@ -1,7 +1,7 @@
// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
// For license information, please see license.txt
frappe.ui.form.on('Torque Master', {
frappe.ui.form.on('Training Information Category', {
// refresh: function(frm) {
// }

22
smart_service/phase_2/doctype/training_information_master/training_information_master.json → smart_service/phase_2/doctype/training_information_category/training_information_category.json

@ -1,16 +1,13 @@
{
"_comments": "[]",
"_liked_by": "[]",
"actions": [],
"allow_rename": 1,
"autoname": "format:{category}-{topic}",
"creation": "2023-08-04 13:06:01.847663",
"autoname": "format:{category}",
"creation": "2023-12-01 12:46:26.720660",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"category",
"topic",
"column_break_75wva",
"active_status",
"my_id"
@ -24,11 +21,8 @@
"reqd": 1
},
{
"fieldname": "topic",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Topic",
"reqd": 1
"fieldname": "column_break_75wva",
"fieldtype": "Column Break"
},
{
"fieldname": "active_status",
@ -36,10 +30,6 @@
"label": "Active Status",
"options": "Active\nInactive"
},
{
"fieldname": "column_break_75wva",
"fieldtype": "Column Break"
},
{
"fieldname": "my_id",
"fieldtype": "Int",
@ -50,10 +40,10 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-09-04 17:40:09.769420",
"modified": "2023-12-01 13:24:36.539407",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Training Information Master",
"name": "Training Information Category",
"owner": "Administrator",
"permissions": [
{

2
smart_service/phase_2/doctype/torque_details/torque_details.py → smart_service/phase_2/doctype/training_information_category/training_information_category.py

@ -4,5 +4,5 @@
# import frappe
from frappe.model.document import Document
class TorqueDetails(Document):
class TrainingInformationCategory(Document):
pass

26
smart_service/phase_2/doctype/training_information_content_reference/training_information_content_reference.json

@ -6,35 +6,27 @@
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"content_type",
"content",
"image_video"
"topic",
"content"
],
"fields": [
{
"fieldname": "content_type",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Content Type",
"options": "Heading\nContent\nImage\nVideo"
},
{
"fieldname": "content",
"fieldtype": "Data",
"in_list_view": 1,
"fieldtype": "Attach",
"label": "Content"
},
{
"fieldname": "image_video",
"fieldtype": "Attach",
"in_list_view": 1,
"label": "Image/Video"
"fieldname": "topic",
"fieldtype": "Select",
"in_standard_filter": 1,
"label": "Topic",
"options": "Heading\nPDF\nPPT\nSCROM\nVideo\nImage\nAnimation\nWeb Links\nHTML"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-09-01 17:11:42.419851",
"modified": "2023-12-01 13:16:18.488344",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Training Information Content Reference",

32
smart_service/phase_2/doctype/training_information_master/training_information_master.js

@ -1,32 +0,0 @@
// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
// For license information, please see license.txt
frappe.ui.form.on('Training Information Master', {
// refresh: function(frm) {
// }
validate: function (frm) {
check_field_character(frm.doc.category)
check_field_character(frm.doc.topic)
}
});
function check_field_character(field_name) {
if (field_name) {
var alphanum = /^[a-zA-Z]+/;
if (field_name.length > 1) {
if (field_name.length > 100) {
frappe.throw("<b>Training Information Master:</b> Only <b> 100 </b> characters are allowed")
frappe.validated = false;
} else {
if (alphanum.test(field_name) === true) {
} else if (field_name) {
frappe.throw(__("<b>Training Information Master:</b> Enter letter or alpha numeric characters only."));
frappe.validated = false;
}
}
} else {
frappe.throw("<b>Training Information Master:</b> Single character not allowed")
frappe.validated = false;
}
}
}

22
smart_service/phase_2/doctype/training_information_master/training_information_master.py

@ -1,22 +0,0 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
import frappe
from frappe.model.document import Document
class TrainingInformationMaster(Document):
def validate(self):
if self.category:
self.category = self.category.strip()
if self.topic:
self.topic = self.topic.strip()
if self.is_new():
count = frappe.db.sql('''select max(my_id) as max_count from `tabTraining Information Master`;''')
if count[0][0] is not None:
self.my_id = count[0][0] + 1
else:
self.my_id = 1
Loading…
Cancel
Save