Browse Source

mst html changes

version2
venkata akhil 1 year ago
parent
commit
f4f8b6057c
  1. 34
      smart_service/apis/v2/master.py
  2. 8
      smart_service/phase_2/doctype/instructions/instructions.json
  3. 8
      smart_service/phase_2/doctype/instructions/instructions.py
  4. 21
      smart_service/phase_2/doctype/special_tool_information/special_tool_information.js
  5. 14
      smart_service/phase_2/doctype/special_tool_information/special_tool_information.json
  6. 13
      smart_service/phase_2/doctype/special_tool_information/special_tool_information.py

34
smart_service/apis/v2/master.py

@ -204,15 +204,33 @@ def new_publish():
find_last_ul='<span style="width: 0;height: 0;border-top: 6px solid transparent;border-left: 8px solid red;border-bottom: 6px solid transparent;position: absolute;margin-top: 3px;"></span></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 len(dt['pre_work'])>0:
# if len(dt['pre_work'])>0:
for pw in dt['pre_work']:
reg_str = "<p>"
res = re.findall(reg_str, pw['content'])
if res:
reg_str1 = "<div>"
if pw['content']:
res = str(pw['content']).find('<div>')
res1 = str(pw['content']).find('<p>')
if res == 1:
pw['content'] = re.sub('<div>','',pw['content'])
pw['content'] = re.sub('</div>','',pw['content'])
pw['content'] = re.sub('<p>','<div style="color: #fff;margin:0px !important;">',pw['content'] )
pw['content'] = re.sub('</p>','</div>',pw['content'] )
cnverted_data = re.sub(CLEANR_back_slash,"'",pw['content'])
pw['content'] = cnverted_data
else:
pw['content'] = '<div style="color: #fff;margin:0px !important;">'+pw['content']+'</div>'
cnverted_data = re.sub(CLEANR_back_slash,"'",pw['content'])
frappe.log_error(str('if')+pw['content'])
pw['content'] = cnverted_data
if res1 == 1:
pw['content'] = re.sub('<div>','',pw['content'])
pw['content'] = re.sub('</div>','',pw['content'])
pw['content'] = re.sub('<p>','<div style="color: #fff;margin:0px !important;">',pw['content'] )
@ -220,16 +238,12 @@ def new_publish():
cnverted_data = re.sub(CLEANR_back_slash,"'",pw['content'])
pw['content'] = cnverted_data
else:
frappe.log_error(str('else')+pw['content'])
pw['content'] = '<div style="color: #fff;margin:0px !important;">'+pw['content']+'</div>'
cnverted_data = re.sub(CLEANR_back_slash,"'",pw['content'])
frappe.log_error(str('if')+pw['content'])
pw['content'] = cnverted_data
# VALID_TAGS = ['div', 'p']
# soup = BeautifulSoup(pw['content'])
# for tag in soup.findAll('p'):
# if tag.name in VALID_TAGS:
# pw['content'] = re.sub('<p>','<p style="color: #fff">',pw['content'] )
# else:
# pw['content'] = '<p style="color: #fff">'+pw['content']+'</p>'
if dt['qwik_procedure']:
for qp in dt['qwik_procedure']['LHS']:

8
smart_service/phase_2/doctype/instructions/instructions.json

@ -31,14 +31,14 @@
"fieldname": "content",
"fieldtype": "Small Text",
"in_list_view": 1,
"label": "Content",
"mandatory_depends_on": "eval:doc.step_name && doc.content_type !='Image'||doc.content_type !='Video'||doc.content_type !='PDF';"
"label": "Content"
},
{
"fieldname": "attach_file",
"fieldtype": "Attach",
"in_list_view": 1,
"label": "Attach File"
"label": "Attach File",
"mandatory_depends_on": "eval:((doc.step_name) && (doc.content_type=='Image')||(doc.content_type=='Video')||(doc.content_type=='PDF'))"
},
{
"fieldname": "title",
@ -50,7 +50,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-10-19 17:11:44.433031",
"modified": "2023-10-20 16:06:35.499348",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Instructions",

8
smart_service/phase_2/doctype/instructions/instructions.py

@ -5,4 +5,12 @@
from frappe.model.document import Document
class Instructions(Document):
# def validate(self):
# if self.instructions:
# for d in self.instructions:
# # frappe.thorow("call")
# 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.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 not d.content:
# frappe.throw("Content should not be empty" + str(d.content_type))
pass

21
smart_service/phase_2/doctype/special_tool_information/special_tool_information.js

@ -244,6 +244,27 @@ function teb_validation(frm){
//end
}
// else{
// var is_content =1
// if(frm.doc.instructions && frm.doc.instructions.length>0){
// frm.doc.instructions.map(v=>{
// if(v.step_name && v.content_type=="Image"||v.content_type=="Video"||v.content_type=="PDF"){
// is_content=0
// if(is_content==0){
// var df = frappe.meta.get_docfield("Instructions", "attach_file", cur_frm.doc.name);
// df.reqd = 1;
// cur_frm.refresh_fields("instructions");
// }
// }
// })
// }
// if(is_content==1){
// var df = frappe.meta.get_docfield("Instructions", "content", cur_frm.doc.name);
// df.reqd = 1;
// cur_frm.refresh_fields("instructions");
// cur_frm.refresh_fields("category");
// }
// }
}

14
smart_service/phase_2/doctype/special_tool_information/special_tool_information.json

@ -25,8 +25,7 @@
"image_preview",
"my_id",
"section_break_e91wx",
"instructions",
"category_display_order"
"instructions"
],
"fields": [
{
@ -106,7 +105,8 @@
"in_standard_filter": 1,
"label": "Category",
"options": "Special Tool Information Category Master",
"reqd": 1
"reqd": 1,
"set_only_once": 1
},
{
"depends_on": "eval:doc.category !='TEB';",
@ -169,17 +169,11 @@
"in_standard_filter": 1,
"label": "Tool Name",
"mandatory_depends_on": "eval:doc.category!=\"TEB\";"
},
{
"fetch_from": "category.display_order",
"fieldname": "category_display_order",
"fieldtype": "Int",
"label": "Category Display Order"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-10-19 16:14:57.349719",
"modified": "2023-10-20 10:45:07.376037",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Special Tool Information",

13
smart_service/phase_2/doctype/special_tool_information/special_tool_information.py

@ -29,12 +29,13 @@ 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")
if self.instructions:
for d in self.instructions:
# frappe.thorow("call")
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.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 not d.content:
frappe.throw("Content should not be empty" + str(d.content_type))
@frappe.whitelist()

Loading…
Cancel
Save