Browse Source

test doc update

master
venkataakhil 2 years ago
parent
commit
20e5d75ae6
  1. 78
      smart_service/apis/addon_api.py
  2. 4
      smart_service/transactions/doctype/publish/publish.json
  3. 34
      smart_service/transactions/doctype/publish/publish.py

78
smart_service/apis/addon_api.py

@ -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:

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

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

34
smart_service/transactions/doctype/publish/publish.py

@ -64,23 +64,23 @@ class Publish(Document):
y.save() y.save()
frappe.db.commit() frappe.db.commit()
# Update system and variant mapping ststus # Update system and variant mapping ststus
if self.publish_status == "Published" and self.publish_type == "Global": if self.publish_status == "Published" and self.publish_type == "Global":
global_publish = frappe.db.sql("""select name from {0}.`tabPublish` where global_publish = '{1}'""".format( global_publish = frappe.db.sql("""select name from {0}.`tabPublish` where global_publish = '{1}'""".format(
current_db_name, self.name), as_dict=True) current_db_name, self.name), as_dict=True)
for global_name in global_publish: for global_name in global_publish:
update_mapping(self.variant_mapping, global_name.name) update_mapping(self.variant_mapping, global_name.name)
u_id = frappe.get_all( u_id = frappe.get_all(
"User", filters={"name": frappe.session.user}, fields=["username"]) "User", filters={"name": frappe.session.user}, fields=["username"])
if u_id: if u_id:
for i in u_id: for i in u_id:
name = i.username name = i.username
if not self.published_by and self.publish_status == "Published": if not self.published_by and self.publish_status == "Published":
self.published_by = str(name) self.published_by = str(name)
frappe.db.set_value( frappe.db.set_value(
"Publish", self.name, "published_by", str(name)) "Publish", self.name, "published_by", str(name))
frappe.db.commit() frappe.db.commit()
def on_cancel(self): def on_cancel(self):
# Published document should not allow to cancel # Published document should not allow to cancel

Loading…
Cancel
Save