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