diff --git a/smart_service/apis/v2/master.py b/smart_service/apis/v2/master.py
index a15ca24..023418c 100644
--- a/smart_service/apis/v2/master.py
+++ b/smart_service/apis/v2/master.py
@@ -4,16 +4,39 @@ from urllib import request
import datetime
from frappe import utils
import json
+import html
import os
from smart_service.apis.app_user_login import input_validation
from frappe.utils import cstr
+
site_name = cstr(frappe.local.site)
BASE_URL = os.path.expanduser(
"~") + "/frappe-bench/sites/" + site_name + "/public"
+
date_format = "%Y-%m-%d %H:%M:%S.%f"
current_db_name = frappe.conf.get("db_name")
+# style=""""""
+
@frappe.whitelist(methods=["POST"], allow_guest=1)
def get_role_mapping():
@@ -171,12 +194,43 @@ def new_publish():
elif module == 'QWIK Service':
flag, data = get_qwik_service(variant, language)
- CLEANR = re.compile('<.*?>')
+ CLEANR = re.compile('<.*?>')
+ CLEANR_back_slash = re.compile("\"")
+ ul_html='
'
+ li_html='- '
+ cling_li='
'
+ cling_last='
'
+ find_last_ul=''
+
for dt in data:
if len(dt['consumables'])>0:
for con in dt['consumables']:
if con['content']:
con['content'] = re.sub(CLEANR, '', con['content'])
+ if dt['qwik_procedure']:
+ for qp in dt['qwik_procedure']['LHS']:
+ if qp['content']:
+ qp['content'] = re.sub('', ul_html,qp['content'] )
+ qp['content'] = re.sub('- ',li_html,qp['content'])
+ qp['content'] = re.sub('
',cling_li,qp['content'])
+ qp['content'] = re.sub(find_last_ul,cling_last,qp['content'])
+
+ cnverted_data = re.sub(CLEANR_back_slash,"'",qp['content'])
+ qp['content'] = cnverted_data
+
+
+ for qp_rhs in dt['qwik_procedure']['RHS']:
+ if qp_rhs:
+ qp_rhs['content'] = re.sub('', ul_html,qp_rhs['content'] )
+ qp_rhs['content'] = re.sub('- ',li_html,qp_rhs['content'])
+ qp_rhs['content'] = re.sub('
',cling_li,qp_rhs['content'])
+ qp_rhs['content'] = re.sub(find_last_ul,cling_last,qp_rhs['content'])
+ cnverted_data = re.sub(CLEANR_back_slash,"'",qp_rhs['content'])
+ qp_rhs['content'] = cnverted_data
+
+
+
+
diff --git a/smart_service/phase_2/doctype/instructions/instructions.json b/smart_service/phase_2/doctype/instructions/instructions.json
index 7490c4b..211c5b2 100644
--- a/smart_service/phase_2/doctype/instructions/instructions.json
+++ b/smart_service/phase_2/doctype/instructions/instructions.json
@@ -31,7 +31,8 @@
"fieldname": "content",
"fieldtype": "Small Text",
"in_list_view": 1,
- "label": "Content"
+ "label": "Content",
+ "mandatory_depends_on": "eval:doc.step_name && doc.content_type !='Image' ||doc.content_type !='Video'||doc.content_type !='PDF'"
},
{
"fieldname": "attach_file",
@@ -49,7 +50,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
- "modified": "2023-10-16 16:18:23.081846",
+ "modified": "2023-10-18 14:57:50.775053",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Instructions",
diff --git a/smart_service/phase_2/doctype/qwik_procedure/qwik_procedure.json b/smart_service/phase_2/doctype/qwik_procedure/qwik_procedure.json
index f3d1e70..46eab2f 100644
--- a/smart_service/phase_2/doctype/qwik_procedure/qwik_procedure.json
+++ b/smart_service/phase_2/doctype/qwik_procedure/qwik_procedure.json
@@ -35,7 +35,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
- "modified": "2023-09-05 14:43:56.463049",
+ "modified": "2023-10-19 11:41:22.915409",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Qwik Procedure",
diff --git a/smart_service/phase_2/doctype/qwik_service/qwik_service.js b/smart_service/phase_2/doctype/qwik_service/qwik_service.js
index 3679e2d..5a74be5 100644
--- a/smart_service/phase_2/doctype/qwik_service/qwik_service.js
+++ b/smart_service/phase_2/doctype/qwik_service/qwik_service.js
@@ -366,6 +366,7 @@ function custom_tab_html(frm){
fieldname: 'content',
fieldtype: 'Text Editor',
default: qwik_dialog_value.content,
+ reqd:1
},
{
label: 'Side',
diff --git a/smart_service/phase_2/doctype/qwik_service/qwik_service.py b/smart_service/phase_2/doctype/qwik_service/qwik_service.py
index cd3b4be..989709a 100644
--- a/smart_service/phase_2/doctype/qwik_service/qwik_service.py
+++ b/smart_service/phase_2/doctype/qwik_service/qwik_service.py
@@ -116,11 +116,3 @@ def file_validation(pdf=None):
else:
return False, 2
-# def delete_file(file_url, attached_to_doctype, attached_to_field, docname, is_child=None):
-# image_name = frappe.db.get_list("File", fields={"name"}, filters={"file_url": file_url,
-# "attached_to_doctype": attached_to_doctype,
-# "attached_to_field": attached_to_field,
-# "attached_to_name": docname})
-# if len(image_name) > 0:
-# frappe.delete_doc('File', image_name[0]['name'])
-# return True
\ No newline at end of file
diff --git a/smart_service/phase_2/doctype/qwik_service_content/qwik_service_content.json b/smart_service/phase_2/doctype/qwik_service_content/qwik_service_content.json
index 215f735..dea6765 100644
--- a/smart_service/phase_2/doctype/qwik_service_content/qwik_service_content.json
+++ b/smart_service/phase_2/doctype/qwik_service_content/qwik_service_content.json
@@ -14,7 +14,8 @@
"fieldname": "content",
"fieldtype": "Text Editor",
"in_list_view": 1,
- "label": "Content"
+ "label": "Content",
+ "mandatory_depends_on": "eval:doc.content_type;"
},
{
"fieldname": "content_type",
@@ -27,7 +28,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
- "modified": "2023-09-04 17:19:19.054634",
+ "modified": "2023-10-18 15:24:24.091233",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Qwik Service Content",
diff --git a/smart_service/phase_2/doctype/special_tool_information/special_tool_information.js b/smart_service/phase_2/doctype/special_tool_information/special_tool_information.js
index f4d606d..adc45dd 100644
--- a/smart_service/phase_2/doctype/special_tool_information/special_tool_information.js
+++ b/smart_service/phase_2/doctype/special_tool_information/special_tool_information.js
@@ -7,12 +7,14 @@ frappe.ui.form.on('Special Tool Information', {
onload: function (frm) {
// Set Display Order
set_display_order(frm),
- teb_validation(frm)
+ teb_validation(frm),
+ instructions(frm)
},
refresh: function (frm) {
// Set Display Order
set_display_order(frm),
- teb_validation(frm)
+ teb_validation(frm),
+ instructions(frm)
},
validate:function(frm){
@@ -244,7 +246,6 @@ function teb_validation(frm){
}
-
function set_display_order(frm){
if (frm.is_new()) {
frm.set_df_property('display_order', 'read_only', 1);
@@ -309,6 +310,20 @@ frappe.ui.form.on('Instructions', {
refresh_field("instructions");
cur_frm.refresh_fields();
},
+ // validate:function(frm, cdt, cdn){
+ // cur_frm.refresh_fields("step_name")
+ // var select_value = locals[cdt][cdn];
+ // var x = select_value.idx - 1;
+ // if (select_value.step_name || select_value.content_type == 'Image' || select_value.content_type == 'Video' || select_value.content_type == 'PDF'){
+ // cur_frm.get_field("instructions").grid.grid_rows[x].columns.content.df.reqd = 0;
+ // }
+ // else{
+ // cur_frm.get_field("instructions").grid.grid_rows[x].columns.content.df.reqd = 1;
+ // }
+ // cur_frm.refresh_fields("step_name")
+ // refresh_field("instructions");
+ // cur_frm.refresh_fields();
+ // }
})
function check_field_character(field_name) {
if (field_name) {
diff --git a/smart_service/phase_2/doctype/special_tool_information/special_tool_information.json b/smart_service/phase_2/doctype/special_tool_information/special_tool_information.json
index f0a13b6..5e92ddc 100644
--- a/smart_service/phase_2/doctype/special_tool_information/special_tool_information.json
+++ b/smart_service/phase_2/doctype/special_tool_information/special_tool_information.json
@@ -16,8 +16,6 @@
"column_break_m3p9i",
"category",
"aggregate_name",
- "aggregate_image",
- "aggregate_image_preview",
"column_break_wvkn2",
"active_status",
"display_order",
@@ -97,7 +95,7 @@
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Aggregate Name",
- "reqd": 1,
+ "mandatory_depends_on": "eval:doc.category !='TEB';",
"set_only_once": 1
},
{
@@ -107,15 +105,8 @@
"in_standard_filter": 1,
"label": "Category",
"options": "Maintenance Service Category (MS)\nRepair Service Category (RS)\nOverhaul Service Category (OS)\nTEB",
- "reqd": 1
- },
- {
- "depends_on": "eval:doc.category !='TEB';",
- "description": "Upload *.png(1280x720 pixel) 1 MB",
- "fieldname": "aggregate_image",
- "fieldtype": "Attach Image",
- "label": "Aggregate Image",
- "reqd": 1
+ "reqd": 1,
+ "set_only_once": 1
},
{
"depends_on": "eval:doc.category !='TEB';",
@@ -178,18 +169,11 @@
"in_standard_filter": 1,
"label": "Tool Name",
"reqd": 1
- },
- {
- "depends_on": "eval:doc.aggregate_image && doc.category!=\"TEB\";;",
- "fieldname": "aggregate_image_preview",
- "fieldtype": "Image",
- "label": "Aggregate Image Preview",
- "options": "aggregate_image"
}
],
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2023-10-16 17:24:43.937085",
+ "modified": "2023-10-18 12:43:38.818592",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Special Tool Information",
diff --git a/smart_service/phase_2/doctype/special_tool_information/special_tool_information.py b/smart_service/phase_2/doctype/special_tool_information/special_tool_information.py
index a81d4c2..c5cff9b 100644
--- a/smart_service/phase_2/doctype/special_tool_information/special_tool_information.py
+++ b/smart_service/phase_2/doctype/special_tool_information/special_tool_information.py
@@ -29,6 +29,12 @@ class SpecialToolInformation(Document):
if not self.is_new() and self.published == 1:
self.published = 0
+ # if self.instructions:
+ # for d in self.instructions:
+ # if(d.step_name and d.content_type == 'Heading' or d.content_type == 'Description' or d.content_type == 'Caution' or d.content_type == 'Warning' or d.content_type == 'Notice'):
+ # if d.content=="":
+ # frappe.msgprint(d.content)
+ # frappe.throw("Content should not be empty")
@frappe.whitelist()
diff --git a/smart_service/transactions/doctype/publish/publish.js b/smart_service/transactions/doctype/publish/publish.js
index 4a7d406..77946b3 100644
--- a/smart_service/transactions/doctype/publish/publish.js
+++ b/smart_service/transactions/doctype/publish/publish.js
@@ -618,12 +618,16 @@ frappe.ui.form.on("Publish", {
},
callback: function (r) {
- if (r.message) {
- frm.set_value("version", r.message);
+ if (r.message['status'] == 1) {
+ frm.set_value("version", r.message['data']);
cur_frm.refresh_field("version");
frm.set_value("actual_published_date", frappe.datetime.nowdate());
window.location.reload();
}
+ else{
+ frappe.msgprint("Failed To Publish")
+
+ }
},
});
}
diff --git a/smart_service/transactions/doctype/publish/publish.py b/smart_service/transactions/doctype/publish/publish.py
index 3096536..3ed18dd 100644
--- a/smart_service/transactions/doctype/publish/publish.py
+++ b/smart_service/transactions/doctype/publish/publish.py
@@ -12,6 +12,7 @@ import json
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)
@@ -199,64 +200,70 @@ def update_qwik_published_docs(self):
def update_publish_mapping(vehicle, variant, language, module, publish_type):
- frappe.set_user('Administrator')
- if module == 'Repair service':
- pub_data = frappe.db.get_list('Module Publish Mapping', filters={
- "vehicle": vehicle,
- "language": language,
- "publish_type": publish_type
- }, fields=['name'])
- if len(pub_data) > 0:
- for d in pub_data:
- if d['name']:
- frappe.db.sql(
- f"""UPDATE `tabModule Publish Mapping` set repairservice_check_sheet='1' and publish_type='1' where name ='{d['name']}'""", as_dict=1)
- frappe.db.commit()
-
- elif module == 'Special Tool':
- pub_data = frappe.db.get_list('Module Publish Mapping', filters={
- "vehicle": vehicle,
- "language": language,
- "publish_type": publish_type
- }, fields=['name'])
- if len(pub_data) > 0:
- for d in pub_data:
- if d['name']:
- frappe.db.sql(
- f"""UPDATE `tabModule Publish Mapping` set mahindra_special_tool_information='1' and publish_type='1' where name ='{d['name']}'""", as_dict=1)
- frappe.db.commit()
- else:
- pub_data = frappe.db.get_list('Module Publish Mapping', filters={
- "vehicle": vehicle,
- "variant": variant,
- "language": language,
- "publish_type": publish_type
- }, fields=['name'])
-
- if pub_data:
- doc = frappe.get_doc('Module Publish Mapping', pub_data[0]['name'])
+ # frappe.set_user('Administrator')
+ try:
+ frappe.log_error("calling module",str(module))
+ if module == 'Repair service':
+ pub_data = frappe.db.get_list('Module Publish Mapping', filters={
+ "vehicle": vehicle,
+ "language": language,
+ "publish_type": publish_type
+ }, fields=['name'])
+ frappe.log_error("pub_data",str(pub_data))
+ if len(pub_data) > 0:
+ for d in pub_data:
+ if d['name']:
+ frappe.log_error("kkkkkkkkkk")
+ frappe.db.sql(
+ f"""UPDATE `tabModule Publish Mapping` set repairservice_check_sheet='1',publish_type='{publish_type}' where name ='{d['name']}'""")
+
+ frappe.db.commit()
+
+ elif module == 'Special Tool':
+ pub_data = frappe.db.get_list('Module Publish Mapping', filters={
+ "vehicle": vehicle,
+ "language": language,
+ "publish_type": publish_type
+ }, fields=['name'])
+ if len(pub_data) > 0:
+ for d in pub_data:
+ if d['name']:
+ frappe.db.sql(
+ f"""UPDATE `tabModule Publish Mapping` set mahindra_special_tool_information='1',publish_type='{publish_type}' where name ='{d['name']}'""", as_dict=1)
+ frappe.db.commit()
else:
- doc = frappe.get_doc({
- 'doctype': 'Module Publish Mapping',
+ pub_data = frappe.db.get_list('Module Publish Mapping', filters={
"vehicle": vehicle,
"variant": variant,
"language": language,
"publish_type": publish_type
- })
- if module == 'Automotive System':
- doc.automotive_system = 1
- doc.tsb = 1
- doc.fsa = 1
- doc.tekalert = 1
-
- elif module == 'Feature Finder':
- doc.feature_finder = 1
-
- elif module == 'Qwik Service':
- doc.qwik_service = 1
-
- doc.save()
+ }, fields=['name'])
+ if pub_data:
+ doc = frappe.get_doc('Module Publish Mapping', pub_data[0]['name'])
+ else:
+ doc = frappe.get_doc({
+ 'doctype': 'Module Publish Mapping',
+ "vehicle": vehicle,
+ "variant": variant,
+ "language": language,
+ "publish_type": publish_type
+ })
+ if module == 'Automotive System':
+ doc.automotive_system = 1
+ doc.tsb = 1
+ doc.fsa = 1
+ doc.tekalert = 1
+
+ elif module == 'Feature Finder':
+ doc.feature_finder = 1
+
+ elif module == 'Qwik Service':
+ doc.qwik_service = 1
+
+ doc.save()
+ except Exception as e:
+ frappe.log_error("update_publish_mapping",str(e))
# def update_publish_status(self):
# try:
@@ -1290,22 +1297,40 @@ def qwik_service_data(language, publish_type, variant, parent, vehicle):
qwik_service_details = frappe.db.sql('''select name,variant,vehicle,kilometers,language,service_time,active_status,
pdf,display_order,keywords,my_id from `tabQwik Service` where name='%s';''' %
- (parent), as_dict=1)
+ (parent), as_dict=1)
+ CLEANR = re.compile('<.*?>')
for q in qwik_service_details:
q['pre_work'] = frappe.db.sql('''select idx as 'display_order', content from `tabQwik Service Content` where parent='%s'
&& content_type = 'Pre-work' order by display_order;''' % (q['name']), as_dict=1)
+ # if q['pre_work']:
+ # for con in q['pre_work']:
+ # if con['content']:
+ # con['content'] = re.sub(CLEANR, '', con['content'])
q['consumables'] = frappe.db.sql('''select idx as 'display_order', content from `tabQwik Service Content` where
parent='%s' && content_type = 'Consumables' order by display_order;''' % (q['name']), as_dict=1)
+ # if q['consumables']:
+ # for con in q['consumables']:
+ # if con['content']:
+ # con['content'] = re.sub(CLEANR, '', con['content'])
q['tools'] = frappe.db.sql('''select idx as 'display_order', content from `tabQwik Service Content` where
parent='%s' && content_type = 'Tools' order by display_order;''' % (q['name']), as_dict=1)
-
+ # if q['tools']:
+ # for con in q['tools']:
+ # if con['content']:
+ # con['content'] = re.sub(CLEANR, '', con['content'])
for p in qwik_service_details:
- # p['qwik_procedure'] = frappe.db.sql('''select idx as 'display_order',side,level,content from `tabQwik Procedure`
- # where parent ='%s';''' % (p['name']), as_dict=1)
LHS = frappe.db.sql('''select idx as 'display_order',side,level,content from `tabQwik Procedure`
where parent ='%s' and side = 'LHS';''' % (p['name']), as_dict=1)
+ # if LHS:
+ # for con in LHS:
+ # if con['content']:
+ # con['content'] = re.sub(CLEANR, '', con['content'])
RHS = frappe.db.sql('''select idx as 'display_order',side,level,content from `tabQwik Procedure`
where parent ='%s' and side = 'RHS';''' % (p['name']), as_dict=1)
+ # if RHS:
+ # for con in RHS:
+ # if con['content']:
+ # con['content'] = re.sub(CLEANR, '', con['content'])
p['qwik_procedure'] = {'LHS': LHS, 'RHS': RHS}
logger.info(
@@ -1366,29 +1391,32 @@ def max_publish_new_module(doc):
@frappe.whitelist()
def cal_ver_new_module(vehicle, lang, publish_type, doc):
- current_db_name = frappe.conf.get("db_name")
- doc = frappe.get_doc("Publish", doc)
- ver = frappe.db.sql("""select max(version) from `tabPublish` where vehicle = "{vehi}" and language = "{lang}" and
- publish_module!="Automotive System";"""
- .format(vehi=vehicle, lang=lang))
- v = 0.0
- if publish_type == 'Global':
- if ver[0][0] == None:
- v = 1.0
- else:
- v = int(float(ver[0][0])) + 1.0
+ try:
+ current_db_name = frappe.conf.get("db_name")
+ doc = frappe.get_doc("Publish", doc)
+ ver = frappe.db.sql("""select max(version) from `tabPublish` where vehicle = "{vehi}" and language = "{lang}" and
+ publish_module!="Automotive System";"""
+ .format(vehi=vehicle, lang=lang))
+ v = 0.0
+ if publish_type == 'Global':
+ if ver[0][0] == None:
+ v = 1.0
+ else:
+ v = int(float(ver[0][0])) + 1.0
- elif publish_type == 'Internal':
- if ver[0][0] == None:
- v = 0.01
- else:
- v = float(ver[0][0]) + 0.01
- v = "{:.2f}".format(v)
- doc.version = v
- frappe.db.sql("""update {0}.`tabPublish` set version = "{1}" where name = "{2}";""".format(
- current_db_name, v, doc.name))
- frappe.db.commit()
- return v
+ elif publish_type == 'Internal':
+ if ver[0][0] == None:
+ v = 0.01
+ else:
+ v = float(ver[0][0]) + 0.01
+ v = "{:.2f}".format(v)
+ doc.version = v
+ frappe.db.sql("""update {0}.`tabPublish` set version = "{1}" where name = "{2}";""".format(
+ current_db_name, v, doc.name))
+ frappe.db.commit()
+ return {"status":1,"data":v}
+ except Exception as e:
+ return {"status":0,"data":"None","error":str(e)}
@frappe.whitelist()