Browse Source

Torque Manual and Training information

version2
venkata akhil 11 months ago
parent
commit
c0f7b47e16
  1. 14
      smart_service/apis/utils.py
  2. 226
      smart_service/apis/v2/master.py
  3. 2
      smart_service/overrides/overrides/override_file.py
  4. 2
      smart_service/phase_2/doctype/feature_finder/feature_finder.js
  5. 2
      smart_service/phase_2/doctype/feature_finder/feature_finder.py
  6. 0
      smart_service/phase_2/doctype/torque_column_mapping/__init__.py
  7. 30
      smart_service/phase_2/doctype/torque_column_mapping/torque_column_mapping.json
  8. 2
      smart_service/phase_2/doctype/torque_column_mapping/torque_column_mapping.py
  9. 0
      smart_service/phase_2/doctype/torque_column_ref/__init__.py
  10. 13
      smart_service/phase_2/doctype/torque_column_ref/torque_column_ref.json
  11. 8
      smart_service/phase_2/doctype/torque_column_ref/torque_column_ref.py
  12. 5
      smart_service/phase_2/doctype/torque_manual/torque_manual.js
  13. 9
      smart_service/phase_2/doctype/torque_manual/torque_manual.json
  14. 69
      smart_service/phase_2/doctype/torque_manual_details/torque_manual_details.json
  15. 0
      smart_service/phase_2/doctype/torque_manual_mapping/__init__.py
  16. 8
      smart_service/phase_2/doctype/torque_manual_mapping/test_torque_manual_mapping.py
  17. 57
      smart_service/phase_2/doctype/torque_manual_mapping/torque_manual_mapping.js
  18. 66
      smart_service/phase_2/doctype/torque_manual_mapping/torque_manual_mapping.json
  19. 8
      smart_service/phase_2/doctype/torque_manual_mapping/torque_manual_mapping.py
  20. 3
      smart_service/phase_2/doctype/torque_table_column/torque_table_column.json
  21. 9
      smart_service/phase_2/doctype/torque_table_column/torque_table_column.py
  22. 60
      smart_service/phase_2/doctype/training_information/training_information.js
  23. 141
      smart_service/phase_2/doctype/training_information/training_information.py
  24. 26
      smart_service/phase_2/doctype/training_information_content_reference/training_information_content_reference.json
  25. 26
      smart_service/transactions/doctype/publish/publish.js
  26. 4
      smart_service/transactions/doctype/publish/publish.json
  27. 564
      smart_service/transactions/doctype/publish/publish.py

14
smart_service/apis/utils.py

@ -58,6 +58,20 @@ def check_mp4_ext(path):
else:
return False
@frappe.whitelist()
def check_ppt_ext(path):
if path:
ext = path.split()[-1]
if ext.lower().endswith('.pptx'):
return True
elif ext.lower().endswith('.pptm'):
return True
elif ext.lower().endswith('.ppt'):
return True
else:
return False
def details_of_image(image_file):
try:

226
smart_service/apis/v2/master.py

@ -16,7 +16,7 @@ site_name = cstr(frappe.local.site)
BASE_URL = os.path.expanduser(
"~") + "/frappe-bench/sites/" + site_name + "/public"
# base = os.path.expanduser(
# "~") + "/frappe-bench/sites/" + site_name
# "~") + "/frappe-bench/sites/" + site_name
date_format = "%Y-%m-%d %H:%M:%S.%f"
@ -179,8 +179,8 @@ def get_training_information(vehicle, language):
return False, e
@frappe.whitelist(methods=['POST'],allow_guest=1)
def new_publish():
@frappe.whitelist(methods=['POST'], allow_guest=1)
def new_publish_old():
req = json.loads(frappe.request.data)
try:
module = req['module']
@ -296,25 +296,23 @@ def new_publish():
qp_rhs['content'] = cnverted_data
elif module == 'Training Information':
base_path = BASE_URL + "/" + "training" +"/"+ vehicle
scrom_path = base_path +"/"+ "scrom"
base_path = BASE_URL + "/" + "training" + "/" + vehicle
scrom_path = base_path + "/" + "scrom"
# html_path = base_path +"/"+ "/html"
frappe.log_error(str(base_path))
flag, data = get_training_information(vehicle, language)
for d in data:
if len(d['content']) > 0:
for ch in d['content']:
if ch['topic'] == 'SCROM':
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']:
frappe.log_error(str(ch['content']))
with zipfile.ZipFile(BASE_URL+ch['content'], 'r') as zip_ref:
zip_ref.extractall(path=scrom_folder_path)
ch['content'] = scrom_folder_path + ch['content'].split("/")[2].split(".")[0]
# cont=frappe.db.sql('''select content from `tabTraining Information Content Reference` where parent = %s and topic = 'SCROM' '''%(d['name']),as_dict=1)
# 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']:
# frappe.log_error(str(ch['content']))
# with zipfile.ZipFile(BASE_URL+ch['content'], 'r') as zip_ref:
# zip_ref.extractall(path=scrom_folder_path)
# ch['content'] = scrom_folder_path + ch['content'].split("/")[2].split(".")[0]
# cont=frappe.db.sql('''select content from `tabTraining Information Content Reference` where parent = %s and topic = 'SCROM' '''%(d['name']),as_dict=1)
elif module == 'Mahindra Special Tool Information':
CLEANR_back_slash = re.compile("\"")
@ -337,7 +335,7 @@ def new_publish():
elif module == 'Torque Information':
flag, data = get_torque_information(variant, language)
else:
flag = False
data = 'No Module found'
@ -355,7 +353,7 @@ def new_publish():
@frappe.whitelist(methods=['POST'], allow_guest=1)
def new_publish1():
def new_publish():
req = json.loads(frappe.request.data)
try:
module = req['module']
@ -366,8 +364,8 @@ def new_publish1():
val = input_validation(req)
if val != '' or val != "":
return {"status": 0, "error": "Input parameter Missing: " + val}
# if val != '' or val != "":
# return {"status": 0, "error": "Input parameter Missing: " + val}
data = []
# Get Publish Type
publish_type = frappe.db.get_list(
@ -377,21 +375,20 @@ def new_publish1():
publish_type = publish_type[0]['publish_type']
else:
return {"status": 0, "error": "Publish Type Not Set For: " + iid}
BASE_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + str(publish_type) + '/'
FULL_UPDATE_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + \
"{}".format(publish_type)+"_Full_Update/"
str(vehicle) + '/' + str(language) + '/' + str(publish_type) + '/'
if module == 'Feature Finder':
FULL_UPDATE_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + \
"{}".format(publish_type)+"_Full_Update/"
FULL_UPDATE_PATH_FILE = FULL_UPDATE_PATH + \
vehicle.replace(' ', '-') + '-feature_finder_full_update' + '.json'
LATEST_GLOBAL_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + "Global_Full_Update/"
LATEST_GLOBAL_FILE = LATEST_GLOBAL_PATH + \
vehicle.replace(' ', '-') + '-feature_finder_full_update' + '.json'
FULL_UPDATE_PATH_FILE = FULL_UPDATE_PATH + \
vehicle.replace(' ', '-') + '-feature_finder_full_update' + '.json'
LATEST_GLOBAL_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + "Global_Full_Update/"
LATEST_GLOBAL_FILE = LATEST_GLOBAL_PATH + \
vehicle.replace(' ', '-') + '-feature_finder_full_update' + '.json'
if module == 'Feature Finder':
# if publish_type == 'Internal':
if os.path.isfile(FULL_UPDATE_PATH_FILE):
with open(FULL_UPDATE_PATH_FILE) as outfile:
@ -412,50 +409,145 @@ def new_publish1():
data = data.get(variant)
elif module == 'Repair/Service Check Sheet':
with open(BASE_PATH + str(vehicle) + '-repair_check_sheet.json') as outfile:
data = json.load(outfile)
# data = data['data']
# filter_json = filter_publish_json(data, variant)
# data = filter_json
data = data.get('data')
data = data.get(variant)
FULL_UPDATE_FOLDER = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + \
"{}".format(publish_type)+"/"
FULL_UPDATE_PATH_FILE = FULL_UPDATE_FOLDER + \
vehicle.replace(' ', '-') + '-repair_check_sheet.json'
LATEST_GLOBAL_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + "Global/"
LATEST_GLOBAL_FILE = LATEST_GLOBAL_PATH + \
vehicle.replace(' ', '-') + '-repair_check_sheet.json'
if os.path.isfile(FULL_UPDATE_PATH_FILE):
with open(FULL_UPDATE_PATH_FILE) as outfile:
data = json.load(outfile)
data = data.get('data')
# data = data.get(variant)
else:
with open(LATEST_GLOBAL_FILE) as outfile:
data = json.load(outfile)
data = data.get('data')
elif module == 'QWIK Service':
with open(BASE_PATH + str(vehicle) + '-qwik_service.json') as outfile:
data = json.load(outfile)
frappe.log_error(str(publish_type))
FULL_UPDATE_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + \
"{}".format(publish_type)+"_Full_Update/"
FULL_UPDATE_PATH_FILE = FULL_UPDATE_PATH + \
vehicle.replace(' ', '-') + '-qwik_service_full_update.json'
LATEST_GLOBAL_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + "Global_Full_Update/"
LATEST_GLOBAL_FILE = LATEST_GLOBAL_PATH + \
vehicle.replace(' ', '-') + '-qwik_service_full_update.json'
# if publish_type == 'Internal':
if os.path.isfile(FULL_UPDATE_PATH_FILE):
with open(FULL_UPDATE_PATH_FILE) as outfile:
data = json.load(outfile)
# data = data['data']
# filter_json = filter_publish_json(data, variant)
# data = filter_json
data = data.get('data')
data = data.get(variant)
data = data.get('data')
data = data.get(variant)
else:
with open(LATEST_GLOBAL_FILE) as outfile:
data = json.load(outfile)
# data = data['data']
# filter_json = filter_publish_json(data, variant)
# data = filter_json
data = data.get('data')
data = data.get(variant)
elif module == 'Training Information':
with open(BASE_PATH + str(vehicle) + '-training_information.json') as outfile:
data = json.load(outfile)
data = data.get('data')
# data = data.get(variant)
FULL_UPDATE_FOLDER = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + \
"{}".format(publish_type)+"/"
FULL_UPDATE_PATH_FILE = FULL_UPDATE_FOLDER + \
vehicle.replace(' ', '-') + '-training_information.json'
LATEST_GLOBAL_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + "Global/"
LATEST_GLOBAL_FILE = LATEST_GLOBAL_PATH + \
vehicle.replace(' ', '-') + '-training_information.json'
if os.path.isfile(FULL_UPDATE_PATH_FILE):
with open(FULL_UPDATE_PATH_FILE) as outfile:
data = json.load(outfile)
data = data.get('data')
else:
with open(LATEST_GLOBAL_FILE) as outfile:
data = json.load(outfile)
data = data.get('data')
elif module == 'Mahindra Special Tool Information':
FULL_UPDATE_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + \
"{}".format(publish_type)+"_Full_Update/"
FULL_UPDATE_PATH_FILE = FULL_UPDATE_PATH + \
vehicle.replace(' ', '-') + '-special_tool.json'
LATEST_GLOBAL_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/'+ "Global_Full_Update/"
LATEST_GLOBAL_FILE = LATEST_GLOBAL_PATH + \
vehicle.replace(' ', '-') + '-special_tool.json'
if os.path.isfile(FULL_UPDATE_PATH_FILE):
with open(FULL_UPDATE_PATH_FILE) as outfile:
data = json.load(outfile)
data = data.get('data')
with open(BASE_PATH + str(vehicle) + '-special_tool_information.json') as outfile:
data = json.load(outfile)
# data = data['data']
# filter_json = filter_publish_json(data, variant)
# data = filter_json
data = data.get('data')
data = data.get(variant)
else:
with open(LATEST_GLOBAL_FILE) as outfile:
data = json.load(outfile)
data = data.get('data')
elif module == 'PDI Inspection':
pass
elif module == 'Torque Manual':
with open(BASE_PATH + str(vehicle) + '-torque_manual.json') as outfile:
data = json.load(outfile)
FULL_UPDATE_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + \
"{}".format(publish_type)+"_Full_Update/"
FULL_UPDATE_PATH_FILE = FULL_UPDATE_PATH + \
vehicle.replace(' ', '-') + '-torque_manual_full_update.json'
LATEST_GLOBAL_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + \
'/' + "Global_Full_Update/"
LATEST_GLOBAL_FILE = LATEST_GLOBAL_PATH + \
vehicle.replace(' ', '-') + '-torque_manual_full_update.json'
# if publish_type == 'Internal':
if os.path.isfile(FULL_UPDATE_PATH_FILE):
with open(FULL_UPDATE_PATH_FILE) as outfile:
data = json.load(outfile)
# data = data['data']
# filter_json = filter_publish_json(data, variant)
# data = filter_json
data = data.get('data')
data = data.get(variant)
else:
else:
data = 'No Module found'
with open(LATEST_GLOBAL_FILE) as outfile:
data = json.load(outfile)
# data = data['data']
# filter_json = filter_publish_json(data, variant)
# data = filter_json
data = data.get('data')
data = data.get(variant)
torque_column_mapping = frappe.db.sql(
f''' select idx as display_order, concat('col',idx) as column_id,column_name from `tabTorque Column Mapping` where parent = '{variant}' order by idx; ''', as_dict=1)
data = {'torque_manual_mapping': torque_column_mapping, 'torque_manual_data': data}
return {'status': 1, 'error': None, 'data': data}
@ -525,8 +617,9 @@ def get_training_information(vehicle, language):
training_information_details = frappe.db.sql('''select name,vehicle,category,display_order,active_status,my_id,keywords from
`tabTraining Information` where vehicle = '%s' && language = '%s';''' % (vehicle, language), as_dict=1)
for i in training_information_details:
i['content'] = frappe.db.sql('''select idx as 'display_order',topic,content from `tabTraining Information Content Reference`
i['content'] = frappe.db.sql('''select idx as 'display_order',topic as file_type,file_url,file_name,scrom_file_url from `tabTraining Information Content Reference`
where parent = '%s' order by display_order;''' % (i['name']), as_dict=1)
return True, training_information_details
except Exception as e:
raise e
@ -536,7 +629,7 @@ def get_training_information(vehicle, language):
# def test_html(vehicle):
# base_path = BASE_URL + "/" + "/training" +"/"+ vehicle
# # Folder creation
# scrom_path = base_path +"/"+ "/scrom"
# scrom_path = base_path +"/"+ "/scrom"
# html_path = base_path +"/"+ "/html"
# try:
# # if not os.path.exists(base_path):
@ -547,7 +640,7 @@ def get_training_information(vehicle, language):
# if not os.path.exists(html_path):
# os.makedirs(html_path)
# # Create zip file
# # try:
# # if path:
@ -626,9 +719,6 @@ def input_validation(req):
return sts
@frappe.whitelist()
def get_published_data():
data = frappe.db.sql("""select vehicle,variant,language,publish_type from `tabPublish` where not in (select vehicle,variant,language,publish_type from

2
smart_service/overrides/overrides/override_file.py

@ -3,7 +3,7 @@ import frappe, json
import json
from frappe.utils import cstr, flt, cint, random_string
def validate(doc=None,method=None):
data = ['.jpg', '.png','.mp4', '.docx','.xls', '.pdf','.tiff','.ppt','.m4v','.doc','.pps','.pptx']
data = ['.jpg', '.png','.mp4', '.docx','.xls', '.pdf','.tiff','.m4v','.doc','.pps']
file_name = doc.file_name
total_count = 0
for i in data:

2
smart_service/phase_2/doctype/feature_finder/feature_finder.js

@ -566,7 +566,7 @@ function custom_tab_html(frm) {
//buttons
spec_custom_dt += '</tbody>'
spec_custom_dt += '</table>'
spec_custom_dt += '<button class="btn btn-xs btn-secondary grid-add-row spec_custom_delete">Deletee</button>'
spec_custom_dt += '<button class="btn btn-xs btn-secondary grid-add-row spec_custom_delete">Delete</button>'
spec_custom_dt += '<button class="btn btn-xs btn-secondary btn-primary grid-add-row spec_custom_add">Add Row</button>'
spec_custom_dt += '<button class="btn btn-xs btn-secondary grid-add-row spec_custom_save">Save</button>'

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

@ -308,7 +308,7 @@ def file_validation(image=None):
if image:
res = check_img_ext(image)
res1 = check_png_ext(image)
if res == True:
if res == True or res1==True:
(width, height, size) = details_of_image(image)
if width > 1920 or height > 1080 and image:

0
smart_service/phase_2/doctype/torque_table_column_child_table/__init__.py → smart_service/phase_2/doctype/torque_column_mapping/__init__.py

30
smart_service/phase_2/doctype/torque_column_mapping/torque_column_mapping.json

@ -0,0 +1,30 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-12-12 15:05:16.121060",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"column_name"
],
"fields": [
{
"fieldname": "column_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Column Name"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-12-12 17:54:15.341459",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Column Mapping",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}

2
smart_service/phase_2/doctype/torque_table_column_child_table/torque_table_column_child_table.py → smart_service/phase_2/doctype/torque_column_mapping/torque_column_mapping.py

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

0
smart_service/phase_2/doctype/torque_column_ref/__init__.py

13
smart_service/phase_2/doctype/torque_table_column_child_table/torque_table_column_child_table.json → smart_service/phase_2/doctype/torque_column_ref/torque_column_ref.json

@ -1,19 +1,18 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-12-08 14:39:31.936009",
"creation": "2023-12-12 12:00:20.112565",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"column_name",
"column_number"
"column",
"column_name"
],
"fields": [
{
"fieldname": "column_number",
"fieldname": "column",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Column Number"
},
{
@ -26,10 +25,10 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-12-08 15:41:50.141820",
"modified": "2023-12-12 12:02:49.911584",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Table Column Child Table",
"name": "Torque Column Ref",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",

8
smart_service/phase_2/doctype/torque_column_ref/torque_column_ref.py

@ -0,0 +1,8 @@
# 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 TorqueColumnRef(Document):
pass

5
smart_service/phase_2/doctype/torque_manual/torque_manual.js

@ -6,10 +6,9 @@ var vehicle_count = 0;
frappe.ui.form.on('Torque Manual', {
refresh: function(frm) {
set_display_order(frm)
},
onload: function (frm) {
set_display_order(frm)
},
});
function set_display_order(frm){
if (frm.is_new()) {

9
smart_service/phase_2/doctype/torque_manual/torque_manual.json

@ -19,6 +19,7 @@
"display_order",
"keywords",
"section_break_cmyhs",
"torque_coulmn_name",
"torque_table"
],
"fields": [
@ -111,11 +112,17 @@
"fieldtype": "Table",
"label": "Torque Table",
"options": "Torque Manual Details"
},
{
"fieldname": "torque_coulmn_name",
"fieldtype": "Table",
"label": "Torque Coulmn Name",
"options": "Torque Column Ref"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-07 16:54:27.415271",
"modified": "2023-12-12 12:03:24.953779",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Manual",

69
smart_service/phase_2/doctype/torque_manual_details/torque_manual_details.json

@ -1,53 +1,88 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-12-07 14:52:59.613295",
"creation": "2023-12-12 15:11:46.238422",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"fastener_description",
"specification",
"qty",
"torque_nm",
"remark"
"col1",
"col2",
"col3",
"col4",
"col5",
"col6",
"col7",
"col8",
"col9",
"col10"
],
"fields": [
{
"fieldname": "fastener_description",
"fieldname": "col1",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Fastener Description"
"label": "Col1"
},
{
"fieldname": "specification",
"fieldname": "col2",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Specification"
"label": "Col2"
},
{
"fieldname": "qty",
"fieldname": "col3",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Qty"
"label": "Col3"
},
{
"fieldname": "torque_nm",
"fieldname": "col4",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Torque NM"
"label": "Col4"
},
{
"fieldname": "remark",
"fieldname": "col5",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Remark"
"label": "Col5"
},
{
"fieldname": "col6",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Col6"
},
{
"fieldname": "col7",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Col7"
},
{
"fieldname": "col8",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Col8"
},
{
"fieldname": "col9",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Col9"
},
{
"fieldname": "col10",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Col10"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-12-09 10:34:51.374165",
"modified": "2023-12-12 15:11:46.238422",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Manual Details",

0
smart_service/phase_2/doctype/torque_manual_mapping/__init__.py

8
smart_service/phase_2/doctype/torque_manual_mapping/test_torque_manual_mapping.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and Contributors
# See license.txt
# import frappe
import unittest
class TestTorqueManualMapping(unittest.TestCase):
pass

57
smart_service/phase_2/doctype/torque_manual_mapping/torque_manual_mapping.js

@ -0,0 +1,57 @@
// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
// For license information, please see license.txt
frappe.ui.form.on('Torque Manual Mapping', {
refresh: function(frm) {
if (frm.doc.torque_table_columns && frm.doc.torque_table_columns.length==10) {
$('[data-fieldname="torque_table_columns"]').find('.grid-add-row').css('display', 'none')
}
$('.grid-add-row').click(function () {
if (frm.doc.torque_table_columns && frm.doc.torque_table_columns.length >=10) {
$('.grid-row-open').find('.grid-duplicate-row').css('display', 'none')
$('[data-fieldname="torque_table_columns"]').find('.grid-add-row').css('display', 'none')
}
});
$('[data-fieldname="torque_table_columns"]').find('.grid-row').find('.data-row').find('.row-index').click(function () {
if (frm.doc.torque_table_columns && frm.doc.torque_table_columns.length ==10) {
$('.grid-row-open').find('.grid-duplicate-row').css('display', 'none')
$('.grid-row-open').find('.grid-insert-row-below').css('display', 'none')
$('.grid-row-open').find('.grid-insert-row').css('display', 'none')
}
$('[data-fieldname="torque_table_columns"]').find('.grid-row-open').find('.grid-duplicate-row').click(function () {
frm.save()
})
})
$('[data-fieldname="torque_table_columns"]').find('.grid-row').find('.data-row').find('.btn-open-row').click(function () {
if (frm.doc.torque_table_columns && frm.doc.torque_table_columns.length ==10) {
$('.grid-row-open').find('.grid-duplicate-row').css('display', 'none')
$('.grid-row-open').find('.grid-insert-row-below').css('display', 'none')
$('.grid-row-open').find('.grid-insert-row').css('display', 'none')
}
$('[data-fieldname="torque_table_columns"]').find('.grid-row-open').find('.grid-duplicate-row').click(function () {
frm.save()
})
})
},
onload: function (frm) {
// set_display_order(frm)
if (frm.doc.torque_table_columns && frm.doc.torque_table_columns.length==10) {
$('[data-fieldname="torque_table_columns"]').find('.grid-add-row').css('display', 'none')
}
},
after_save:function(frm){
if (frm.doc.torque_table_columns.length==10) {
$('.grid-row-open').find('.grid-duplicate-row').css('display', 'none')
$('.grid-row-open').find('.grid-insert-row-below').css('display', 'none')
$('.grid-row-open').find('.grid-insert-row').css('display', 'none')
}
}
});

66
smart_service/phase_2/doctype/torque_manual_mapping/torque_manual_mapping.json

@ -0,0 +1,66 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "format:{variant}",
"creation": "2023-12-12 14:44:55.388191",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"variant",
"vehicle",
"section_break_bytf4",
"torque_table_columns"
],
"fields": [
{
"fieldname": "variant",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Variant",
"options": "Variant Mapping",
"reqd": 1
},
{
"fetch_from": "variant.vehicle",
"fieldname": "vehicle",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Vehicle",
"reqd": 1
},
{
"fieldname": "section_break_bytf4",
"fieldtype": "Section Break"
},
{
"fieldname": "torque_table_columns",
"fieldtype": "Table",
"label": "Torque Table Columns",
"options": "Torque Column Mapping"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-12 15:05:37.251699",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Manual Mapping",
"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"
}

8
smart_service/phase_2/doctype/torque_manual_mapping/torque_manual_mapping.py

@ -0,0 +1,8 @@
# 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 TorqueManualMapping(Document):
pass

3
smart_service/phase_2/doctype/torque_table_column/torque_table_column.json

@ -1,6 +1,7 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "format:{variant}",
"creation": "2023-12-08 14:40:14.464142",
"doctype": "DocType",
"editable_grid": 1,
@ -41,7 +42,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-08 15:09:13.185244",
"modified": "2023-12-12 12:09:57.530576",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Table Column",

9
smart_service/phase_2/doctype/torque_table_column/torque_table_column.py

@ -6,3 +6,12 @@ from frappe.model.document import Document
class TorqueTableColumn(Document):
pass
# def generate_col_seq(col_data):
# try:
# except Exception as e:
# return str(e)

60
smart_service/phase_2/doctype/training_information/training_information.js

@ -21,25 +21,47 @@ frappe.ui.form.on('Training Information', {
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.extract_scrom_package",
args: {
data: frm.doc.name,
vehicle:frm.doc.vehicle
},
callback: function (r) {
debugger
console.log(r.message, "----file validation size-------")
// if (r.message && r.message[0] == false) {
// if (r.message[1]) {
// frappe.validated = false;
// 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:"file_url"
},
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()
console.log(frm.doc.content,"content")
frappe.throw("In Training Information content " + r.message[1] + " row was invalid file type")
}
}
}
})
}
}
});
function set_display_order(frm){

141
smart_service/phase_2/doctype/training_information/training_information.py

@ -3,7 +3,14 @@
import frappe
from frappe.model.document import Document
from frappe.utils import cstr
import zipfile
import os
from smart_service.apis.utils import check_png_ext, check_img_ext, check_zip_ext, check_pdf_ext, details_of_image, checking_image,check_mp4_ext,check_ppt_ext,get_file_size
site_name = cstr(frappe.local.site)
BASE_URL = os.path.expanduser(
"~") + "/frappe-bench/sites/" + site_name + "/public"
class TrainingInformation(Document):
def validate(self):
try:
@ -23,6 +30,7 @@ class TrainingInformation(Document):
self.my_id = count[0][0] + 1
else:
self.my_id = 1
# extract_scrom_package(self.name,self.vehicle)
except Exception as e:
raise e
@ -89,3 +97,136 @@ class TrainingInformation(Document):
# d['image_video'], 'Training Information', value, name, 1)
# frappe.delete_doc('Training Information Content Reference', d['name'])
# return (ret, d['idx'])
@frappe.whitelist()
def extract_scrom_package(data,vehicle):
training_information = training_information_data(data)
frappe.log_error(str(training_information))
BASE_URL1 = os.path.expanduser(
"~") + "/frappe-bench/sites/" + site_name + "/public/files"
base_path = BASE_URL1 + "/" + "training" +"/"+ vehicle
scrom_path = base_path +"/"+ "scrom/"
scrom_file_url= ""
for d in training_information['data']:
if d['file_url']:
# for ch in d['content']:
if d['topic'] == 'SCROM' and d['file_url']!=None:
scrom_folder_path =scrom_path+d['file_url'].split("/")[2].split(".")[0]+"/"
file_name = d['file_name']
name = d['name']
if not os.path.exists(scrom_folder_path):
os.makedirs(scrom_folder_path)
if d['file_url']:
frappe.log_error(str(scrom_folder_path))
with zipfile.ZipFile(BASE_URL+d['file_url'], 'r') as zip_ref:
zip_ref.extractall(path=scrom_folder_path)
base_path_url = "/files/training/"+vehicle+"/scrom/"+ d['file_url'].split("/")[2].split(".")[0]+"/"
file_path_url="/files/training/"+vehicle+"/scrom/"+ d['file_url'].split("/")[2].split(".")[0]+"/"
# for file in os.listdir(scrom_folder_path):
# d = os.path.join(scrom_folder_path, file)
# if os.path.isdir(d):
# base_folder_name = d.split('/')[-1]
for root, dirs, files in os.walk(scrom_folder_path):
if file_name in files:
base_folder_name = os.path.join(root, file_name)
scrom_file_url = base_folder_name.split("/public")[1:][0]
# return os.path.join(root, file_name)
frappe.log_error('scrom_file_url'+str(scrom_file_url))
update_base_path = frappe.db.sql(f"""update `tabTraining Information Content Reference` set base_path = '{base_path_url}', scrom_file_url ='{scrom_file_url}' where name='{name}'""")
return {"success":1,"data":data}
# except Exception as e:
# return "Extarction Failed"+str(e)
def training_information_data(parent=None):
try:
# training_information_details = frappe.db.sql(f"""select name,vehicle,category,language,display_order,keywords,my_id,active_status from
# `tabTraining Information` where name='{parent}' """, as_dict=1)
# for d in training_information_details:
training_information_details = frappe.db.sql(f"""select idx as 'display_order',name,topic,scrom_file_url,base_path,file_url,file_name from `tabTraining Information Content Reference`
where parent = '{parent}'
order by display_order ;""", as_dict=1)
return {"success" :1 ,"data":training_information_details}
except Exception as e:
return {"success" :0 ,"data":None,"msg":str(e)}
@frappe.whitelist()
def file_validation_child(name, value=None):
try:
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['topic'] and d['file_url']:
res = False
res1 = False
if d['topic'] =="PDF":
res = check_pdf_ext(d['file_url'])
if d['topic'] =="PPT":
res = check_ppt_ext(d['file_url'])
if d['topic'] =="Video":
res = check_mp4_ext(d['file_url'])
if d['topic'] =="Image":
res = check_img_ext(d['file_url'])
res1 = check_png_ext(d['file_url'])
if d['topic'] =="SCROM":
res = check_zip_ext(d['file_url'])
if res==True or res1==True:
valuess,idx = get_file_details(d['topic'],d['file_url'],value,name,1,d['idx'],d['name'])
else:
valuess,idx = delete_child_image(d['file_url'],value,name,1,d['idx'],d['name'])
if valuess==False:
return valuess,idx
return child_data
except Exception as e:
frappe.log_error("file validation child",frappe.get_traceback())
def get_file_details(topic,file_url,value,name,is_child,idx,child_doc):
if topic=="Image":
width, height, size = details_of_image(file_url)
if width > 1280 or height > 720 or size > 1*1024 and file_url:
delete_child_image(file_url,value,name,is_child,idx,child_doc)
else:
return True,idx
else:
size = get_file_size(file_url)
frappe.log_error("file_size",str(size))
if size>500 and file_url:
valuess,idx = delete_child_image(file_url,value,name,is_child,idx,child_doc)
return valuess,idx
else:
return True,idx
def delete_child_image(file_url,value,name,is_child,idx,child_doc):
try:
val = checking_image(
file_url, "Training Information", value, name, is_child)
doc = frappe.get_doc('Training Information Content Reference', child_doc)
doc.file_url = ''
doc.save()
if val == True:
return False, idx
except Exception as e:
frappe.log_error("delete_child_image",frappe.get_traceback())

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

@ -7,17 +7,13 @@
"engine": "InnoDB",
"field_order": [
"topic",
"content",
"file_url",
"base_path",
"file_name",
"file_url"
"scrom_file_url",
"scrom_index_page"
],
"fields": [
{
"fieldname": "content",
"fieldtype": "Attach",
"label": "Content"
},
{
"fieldname": "topic",
"fieldtype": "Select",
@ -28,6 +24,7 @@
{
"fieldname": "base_path",
"fieldtype": "Data",
"hidden": 1,
"in_list_view": 1,
"label": "Base Path"
},
@ -39,15 +36,26 @@
},
{
"fieldname": "file_url",
"fieldtype": "Attach",
"label": "File Url"
},
{
"fieldname": "scrom_file_url",
"fieldtype": "Data",
"hidden": 1,
"label": "Scrom File Url"
},
{
"fieldname": "scrom_index_page",
"fieldtype": "Data",
"in_list_view": 1,
"label": "File Url"
"label": "Scrom Index Page"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-12-08 17:19:25.723894",
"modified": "2023-12-12 13:48:55.828272",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Training Information Content Reference",

26
smart_service/transactions/doctype/publish/publish.js

@ -377,7 +377,7 @@ frappe.ui.form.on("Publish", {
module_name: frm.doc.publish_module,
},
callback: function (r) {
window.location.href =
r.message.url +
"/app/publish" +
@ -492,9 +492,9 @@ frappe.ui.form.on("Publish", {
},
callback: function (r) {
if (r.message) {
debugger
if (r.message == frm.doc.version) {
debugger
frm.add_custom_button(__("Global Publish"), function () {
frappe.call({
method:
@ -1213,6 +1213,13 @@ frappe.ui.form.on("Publish", {
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"));
}
},
km_report: function (frm, cdt, cdn) {
if (frm.doc.publish_module == "Automotive System") {
@ -1754,20 +1761,22 @@ function add_training_information(frm) {
if (frm.doc.training_information_publish_docs) {
frm.doc.training_information_publish_docs.forEach(
(publishrow) => {
if (row.parent_name == publishrow.parent_name) {
if (row.parent1 == publishrow.parent1) {
dulicate = true;
}
}
);
}
if (dulicate === false) {
let child = cur_frm.add_child("training_information_publish_docs");
let child = cur_frm.add_child(
"training_information_publish_docs"
);
child.vehicle = frm.doc.vehicle;
child.parent1 = row.parent1;
child.language = row.language;
child.category = row.category;
child.active_status = row.active_status;
refresh_field("training_information_publish_docs");
// refresh_field("training_information_publish_docs");
added += 1;
frm.set_df_property(
"training_information_publish_docs",
@ -1785,8 +1794,9 @@ function add_training_information(frm) {
"btn btn-xs btn-secondary grid-add-row"
)[5]
.setAttribute("style", "display:none;");
} else {
frappe.msgprint(__(row.parent_name + "Alraeady Added"));
}
else {
frappe.msgprint(__(row.parent1 + "Alraeady Added"));
}
}
});

4
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';",
"depends_on": "eval:doc.variant_mapping && doc.publish_type == \"Internal\" && doc.docstatus == 0 && doc.publish_module=='Automotive System' || doc.publish_module=='Torque Manual'",
"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-06 15:38:46.908708",
"modified": "2023-12-12 23:25:19.477106",
"modified_by": "Administrator",
"module": "Transactions",
"name": "Publish",

564
smart_service/transactions/doctype/publish/publish.py

File diff suppressed because it is too large
Loading…
Cancel
Save