Browse Source

Test feedback

master
venkataakhil 2 years ago
parent
commit
1448931d82
  1. 78
      smart_service/apis/addon_api.py

78
smart_service/apis/addon_api.py

@ -194,45 +194,45 @@ 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": "Failed to create Feedback"}
else:
api = {"status": 0, "error": "Check argument: args"}
else:

Loading…
Cancel
Save