diff --git a/smart_service/apis/v2/master.py b/smart_service/apis/v2/master.py index 40de1ba..446daba 100644 --- a/smart_service/apis/v2/master.py +++ b/smart_service/apis/v2/master.py @@ -204,32 +204,46 @@ def new_publish(): 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 len(dt['pre_work'])>0: + # if len(dt['pre_work'])>0: for pw in dt['pre_work']: - reg_str = "

" - res = re.findall(reg_str, pw['content']) - if res: - pw['content'] = re.sub('

','',pw['content']) - pw['content'] = re.sub('
','',pw['content']) - pw['content'] = re.sub('

','

',pw['content'] ) - pw['content'] = re.sub('

','
',pw['content'] ) - cnverted_data = re.sub(CLEANR_back_slash,"'",pw['content']) - pw['content'] = cnverted_data - else: - pw['content'] = '
'+pw['content']+'
' - cnverted_data = re.sub(CLEANR_back_slash,"'",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('

','

',pw['content'] ) - # else: - # pw['content'] = '

'+pw['content']+'

' + reg_str = "

" + reg_str1 = "

" + + if pw['content']: + res = str(pw['content']).find('
') + res1 = str(pw['content']).find('

') + if res == 1: + pw['content'] = re.sub('

','',pw['content']) + pw['content'] = re.sub('
','',pw['content']) + pw['content'] = re.sub('

','

',pw['content'] ) + pw['content'] = re.sub('

','
',pw['content'] ) + cnverted_data = re.sub(CLEANR_back_slash,"'",pw['content']) + pw['content'] = cnverted_data + else: + pw['content'] = '
'+pw['content']+'
' + 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('
','',pw['content']) + pw['content'] = re.sub('
','',pw['content']) + pw['content'] = re.sub('

','

',pw['content'] ) + pw['content'] = re.sub('

','
',pw['content'] ) + cnverted_data = re.sub(CLEANR_back_slash,"'",pw['content']) + pw['content'] = cnverted_data + else: + frappe.log_error(str('else')+pw['content']) + pw['content'] = '
'+pw['content']+'
' + cnverted_data = re.sub(CLEANR_back_slash,"'",pw['content']) + frappe.log_error(str('if')+pw['content']) + pw['content'] = cnverted_data + if dt['qwik_procedure']: for qp in dt['qwik_procedure']['LHS']: diff --git a/smart_service/phase_2/doctype/instructions/instructions.json b/smart_service/phase_2/doctype/instructions/instructions.json index 429a18c..870583f 100644 --- a/smart_service/phase_2/doctype/instructions/instructions.json +++ b/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", diff --git a/smart_service/phase_2/doctype/instructions/instructions.py b/smart_service/phase_2/doctype/instructions/instructions.py index 0327ff2..1a9ca8b 100644 --- a/smart_service/phase_2/doctype/instructions/instructions.py +++ b/smart_service/phase_2/doctype/instructions/instructions.py @@ -5,4 +5,12 @@ from frappe.model.document import Document class Instructions(Document): - pass + # 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 \ No newline at end of file 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 ae03e68..c4736aa 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 @@ -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"); + // } + // } } 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 67147da..eb2ae5a 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 @@ -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", 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 c5cff9b..f39cd99 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,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()