Compare commits

...

5 Commits

Author SHA1 Message Date
venkataakhil 76a06f54b5 post user feedback traceback 2 years ago
venkataakhil cd5024ad44 childa table updated 2 years ago
venkataakhil d0cd373bec db name globa; 2 years ago
venkataakhil 77e1a26a1a db name added 2 years ago
venkataakhil 20e5d75ae6 test doc update 2 years ago
  1. 79
      smart_service/apis/addon_api.py
  2. 4
      smart_service/transactions/doctype/publish/publish.json
  3. 6
      smart_service/transactions/doctype/publish/publish.py

79
smart_service/apis/addon_api.py

@ -194,45 +194,46 @@ def feedback(args=None, request=None):
return api
elif args == 'post_user_feedback':
# try:
request = json.loads(request)
usr_fdbk = frappe.new_doc('User Feedback')
usr_fdbk.subject = request['Subject']
usr_fdbk.feedback_type = request["FeedbackType"]
usr_fdbk.user_name = frappe.db.get_value(
"App Users", {"user_id": request["UserID"]}, ["name"])
usr_fdbk.status = "Open"
usr_fdbk.description = request["Description"]
usr_fdbk.date = request["Date"]
usr_fdbk.save()
feedback_name = usr_fdbk.name
folder = request['folder']
files_data = request['Files']
file_response = []
site_name = cstr(frappe.local.site)
for f in files_data:
for x in f:
file_name = x
file_data = f[x]
file_url = "/home/ubuntu/frappe-bench/sites/" + site_name + "/public/files/" + file_name
with open(file_url, "wb") as img:
img.write(base64.b64decode(file_data))
ret = frappe.new_doc("File")
ret.doctype = "File"
ret.attached_to_doctype = request['doctype']
ret.attached_to_name = feedback_name
ret.folder = "Home"
ret.file_name = file_name
ret.file_url = "/files/" + file_name
ret.is_private = 0
ret.insert(ignore_permissions=True)
file_response.append(ret)
api = {"isSuccessful": True, "name": usr_fdbk.name, "files": file_response}
# except Exception as e:
# api = {"status": 0, "error": "Failed to create Feedback"}
try:
request = json.loads(request)
usr_fdbk = frappe.new_doc('User Feedback')
usr_fdbk.subject = request['Subject']
usr_fdbk.feedback_type = request["FeedbackType"]
usr_fdbk.user_name = frappe.db.get_value(
"App Users", {"user_id": request["UserID"]}, ["name"])
usr_fdbk.status = "Open"
usr_fdbk.description = request["Description"]
usr_fdbk.date = request["Date"]
usr_fdbk.save()
feedback_name = usr_fdbk.name
folder = request['folder']
files_data = request['Files']
file_response = []
site_name = cstr(frappe.local.site)
for f in files_data:
for x in f:
file_name = x
file_data = f[x]
file_url = "/home/ubuntu/frappe-bench/sites/" + site_name + "/public/files/" + file_name
with open(file_url, "wb") as img:
img.write(base64.b64decode(file_data))
ret = frappe.new_doc("File")
ret.doctype = "File"
ret.attached_to_doctype = request['doctype']
ret.attached_to_name = feedback_name
ret.folder = "Home"
ret.file_name = file_name
ret.file_url = "/files/" + file_name
ret.is_private = 0
ret.insert(ignore_permissions=True)
file_response.append(ret)
api = {"isSuccessful": True, "name": usr_fdbk.name, "files": file_response}
except Exception as e:
api = {"status": 0, "error": str(frappe.get_traceback())}
else:
api = {"status": 0, "error": "Check argument: args"}
else:

4
smart_service/transactions/doctype/publish/publish.json

@ -299,8 +299,10 @@
"read_only": 1
},
{
"allow_on_submit": 1,
"fieldname": "child_table_updated",
"fieldtype": "Select",
"hidden": 1,
"label": "Child Table Updated",
"options": "0\n1"
}
@ -308,7 +310,7 @@
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2023-05-16 14:02:25.547907",
"modified": "2023-05-16 14:43:27.233080",
"modified_by": "Administrator",
"module": "Transactions",
"name": "Publish",

6
smart_service/transactions/doctype/publish/publish.py

@ -33,8 +33,9 @@ class Publish(Document):
str(km_mapping.name) + '\n'
def onload(self):
if self.child_table_updated == 1:
current_db_name = frappe.conf.get("db_name")
current_db_name = frappe.conf.get("db_name")
if self.child_table_updated == "1":
# To validate updated procedure status
procedure_status = frappe.db.sql("""select p.name,p.update_procedure_status,pro.name,p.variant_mapping,p.system,p.sub_system,p.asset_category,p.item_category,p.variant,p.procedure_link,p.procedure_status,pro.name,pro.workflow_state
from {0}.`tabPublish_Docs` as p,{0}.`tabProcedure` as pro
@ -66,6 +67,7 @@ class Publish(Document):
# Update system and variant mapping ststus
if self.publish_status == "Published" and self.publish_type == "Global":
current_db_name = frappe.conf.get("db_name")
global_publish = frappe.db.sql("""select name from {0}.`tabPublish` where global_publish = '{1}'""".format(
current_db_name, self.name), as_dict=True)
for global_name in global_publish:

Loading…
Cancel
Save