From 694c44e6d3b25c7f736c3baab003396997e51b9f Mon Sep 17 00:00:00 2001 From: venkataakhil Date: Wed, 12 Jul 2023 10:42:15 +0530 Subject: [PATCH] Add function to clear --- smart_service/apis/support.py | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/smart_service/apis/support.py b/smart_service/apis/support.py index dbdd28e..8679cf9 100644 --- a/smart_service/apis/support.py +++ b/smart_service/apis/support.py @@ -416,18 +416,18 @@ def set_procedure_false(): return False -@frappe.whitelist(allow_guest=1) -def clear_procedures(): - try: - set_procedure_false() - frappe.db.sql('''delete FROM `tabPublish`;''') - frappe.db.sql('''delete FROM `tabPublish_Docs`;''') - frappe.db.sql('''update `tabVariant Mapping_Assets` set published=0;''') - frappe.db.sql('''update `tabSystem Mapping_Sub System` set procedure_is_published=0;''') - frappe.db.sql('''update `tabSystem Mapping_System Assets` set published=0;''') - frappe.db.commit() - except Exception as e: - return e +# @frappe.whitelist(allow_guest=1) +# def clear_procedures(): +# try: +# set_procedure_false() +# frappe.db.sql('''delete FROM `tabPublish`;''') +# frappe.db.sql('''delete FROM `tabPublish_Docs`;''') +# frappe.db.sql('''update `tabVariant Mapping_Assets` set published=0;''') +# frappe.db.sql('''update `tabSystem Mapping_Sub System` set procedure_is_published=0;''') +# frappe.db.sql('''update `tabSystem Mapping_System Assets` set published=0;''') +# frappe.db.commit() +# except Exception as e: +# return e @frappe.whitelist(allow_guest=1) def circular_api(): @@ -465,3 +465,13 @@ def remove_html_tags(): return True, 'Done' except Exception as e: return False,e + + +@frappe.whitelist(allow_guest=1) +def clear_tables(table_name): + try: + set_procedure_false() + frappe.db.sql(f'''delete FROM `{table_name}`;''') + return 1 + except Exception as e: + return e \ No newline at end of file