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

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",

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

@ -64,23 +64,23 @@ class Publish(Document):
y.save()
frappe.db.commit()
# Update system and variant mapping ststus
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(
current_db_name, self.name), as_dict=True)
for global_name in global_publish:
update_mapping(self.variant_mapping, global_name.name)
u_id = frappe.get_all(
"User", filters={"name": frappe.session.user}, fields=["username"])
if u_id:
for i in u_id:
name = i.username
if not self.published_by and self.publish_status == "Published":
self.published_by = str(name)
frappe.db.set_value(
"Publish", self.name, "published_by", str(name))
frappe.db.commit()
# Update system and variant mapping ststus
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(
current_db_name, self.name), as_dict=True)
for global_name in global_publish:
update_mapping(self.variant_mapping, global_name.name)
u_id = frappe.get_all(
"User", filters={"name": frappe.session.user}, fields=["username"])
if u_id:
for i in u_id:
name = i.username
if not self.published_by and self.publish_status == "Published":
self.published_by = str(name)
frappe.db.set_value(
"Publish", self.name, "published_by", str(name))
frappe.db.commit()
def on_cancel(self):
# Published document should not allow to cancel

Loading…
Cancel
Save