Browse Source

update publish tables if get multiple rows

master
Ubuntu 3 years ago
parent
commit
de3b2cf931
  1. 28
      smart_service/apis/update_validation.py
  2. 8
      smart_service/fixtures/client_script.json
  3. 50
      smart_service/fixtures/notification.json
  4. 23
      smart_service/transactions/doctype/publish/publish.py

28
smart_service/apis/update_validation.py

@ -9,6 +9,19 @@ current_db_name = frappe.conf.get("db_name")
site_name = cstr(frappe.local.site)
base_url = os.path.expanduser("~") + "/frappe-bench/sites/"+site_name+"/public"
def get_parent_map(input_list, parameter):
parentChildMap = {}
for b in input_list:
parentChildMap.setdefault(b[parameter] or None, []).append(b)
list1 = []
for p in parentChildMap:
da = {"procedure_name": p, 'steps': parentChildMap[p]}
list1.append(da)
for i in parentChildMap[p]:
del i['procedure_name']
del i['idx']
return list1
@frappe.whitelist()
def check_all_vehicle_updates(vehicle_list):
@ -25,6 +38,7 @@ def check_all_vehicle_updates(vehicle_list):
if publish_type[0][0] != None:
for v in vehicle_data:
v_id = v['Vehicle']
current_version = float(v['CurrentVersion'])
data1 = frappe.db.sql('''SELECT name,max(version) as version,vehicle_id,language FROM {}.tabPublish where vehicle='{}' and language='{}' and publish_status='Published'
and publish_type='{}' and vehicle_status='Active' order by version ASC;'''.format(current_db_name, v_id,lang, publish_type[0][0]),as_dict=True)
@ -57,20 +71,6 @@ def check_all_vehicle_updates(vehicle_list):
except:
return {"isSuccessful": False}
def get_parent_map(input_list, parameter):
parentChildMap = {}
for b in input_list:
parentChildMap.setdefault(b[parameter] or None, []).append(b)
list1 = []
for p in parentChildMap:
da = {"procedure_name": p, 'steps': parentChildMap[p]}
list1.append(da)
for i in parentChildMap[p]:
del i['procedure_name']
del i['idx']
return list1
@frappe.whitelist()
def check_vehicle_update(vehicle_list):

8
smart_service/fixtures/client_script.json

File diff suppressed because one or more lines are too long

50
smart_service/fixtures/notification.json

@ -56,7 +56,7 @@
"is_standard": 0,
"message": "<p>Hello {{ doc.full_name }},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>\r\n<p>Welcome to Guided Smart Service CMS !!! &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>A new account has been created on {{ doc.creation }}.</p>\r\n<p>Your login id is: {{ doc.username }} </p>\r\n<p>Role: CMS User&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>\r\n<br>Please use Mahindra credentials for accessing your account.</br>\r\n<br>Click on the link below to access the CMS Portal.</br>\r\n<p>http://192.168.1.58:81/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>\r\n<br>Thanks,</br>\r\n<br>Smart Service CMS Admin</br>",
"method": null,
"modified": "2022-03-08 10:58:11.969504",
"modified": "2022-03-21 13:39:02.434667",
"module": null,
"name": "Mahindra User Enabled",
"parent": null,
@ -99,7 +99,7 @@
"is_standard": 0,
"message": "<p>Hello Admin,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>The account with the below details has been successfully enabled. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>\r\n<p>Login ID: {{ doc.username }}</p>\r\n<p>Email ID: {{ doc.name }} </p>\r\n<p>&nbsp;</p>\r\n<p>The user can now access the account.</p>\r\n<p>A welcome mail has been sent to the user as well.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>\r\n<br>Thanks,</br>\r\n<br>Smart Service CMS Admin</br>",
"method": null,
"modified": "2022-03-08 11:08:44.723490",
"modified": "2022-03-21 13:38:54.315513",
"module": null,
"name": "User Enabled",
"parent": null,
@ -115,7 +115,7 @@
"parent": "User Enabled",
"parentfield": "recipients",
"parenttype": "Notification",
"receiver_by_document_field": "email_id,user_emails",
"receiver_by_document_field": "",
"receiver_by_role": "User_Account_Manager"
}
],
@ -142,7 +142,7 @@
"is_standard": 0,
"message": "<p>Hello Smart Service User,</p>\n<br>New <b>{{doc.publish_type}}</b> publish for <b>{{doc.vehicle}}</b> has been published successfully as <b>{{doc.name}}</b>.</br>\n<p> </p>\n<br>Thanks,</br>\n<br>Smart Service CMS Admin</br>",
"method": "smart_service.transactions.doctype.publish.publish.cal_ver",
"modified": "2022-03-17 21:09:52.741600",
"modified": "2022-03-21 13:39:24.317947",
"module": null,
"name": "Published Notification",
"parent": null,
@ -160,10 +160,50 @@
"parenttype": "Notification",
"receiver_by_document_field": "",
"receiver_by_role": "_AppUser"
},
{
"bcc": null,
"cc": null,
"condition": null,
"parent": "Published Notification",
"parentfield": "recipients",
"parenttype": "Notification",
"receiver_by_document_field": null,
"receiver_by_role": "_Approver"
},
{
"bcc": null,
"cc": null,
"condition": null,
"parent": "Published Notification",
"parentfield": "recipients",
"parenttype": "Notification",
"receiver_by_document_field": null,
"receiver_by_role": "_Author"
},
{
"bcc": null,
"cc": null,
"condition": null,
"parent": "Published Notification",
"parentfield": "recipients",
"parenttype": "Notification",
"receiver_by_document_field": null,
"receiver_by_role": "_Reviewer"
},
{
"bcc": null,
"cc": null,
"condition": null,
"parent": "Published Notification",
"parentfield": "recipients",
"parenttype": "Notification",
"receiver_by_document_field": null,
"receiver_by_role": "_Publisher"
}
],
"send_system_notification": 0,
"send_to_all_assignees": 0,
"send_to_all_assignees": 1,
"sender": "GSS-CMS",
"sender_email": "cms@guidedsmartservice.com",
"set_property_after_alert": null,

23
smart_service/transactions/doctype/publish/publish.py

@ -168,3 +168,26 @@ def update_mapping(variant_mapping,doc):
sm_item.procedure_is_published = '1'
frappe.db.sql("""update {0}.`tabSystem Mapping_Sub System` set procedure_is_published = '1' where parent = '{1}' and systems = '{2}' and sub_systems = '{3}'""".format(current_db_name,sm.name,variant.system,variant.sub_system))
frappe.db.commit()
@frappe.whitelist()
def get_vm_asset(doc):
doc = frappe.get_doc("Variant Mapping",doc)
vm_assets = frappe.db.sql("""select category,language,attach_file,active_status from `tabVariant Mapping_Assets` where parent = %s and published = '0'""",doc.name,as_dict=True)
return vm_assets
@frappe.whitelist()
def get_sm_asset(doc):
system_map = frappe.db.sql("""select name from `tabSystem Mapping` where variant_mapping=%s""",doc,as_dict=True)
if system_map:
for s in system_map:
doc = frappe.get_doc("System Mapping",s.name)
system_asset = frappe.db.sql("""select systems,language,active_status,system_asset from `tabSystem Mapping_System Assets` where parent = %s and published = '0'""",s.name,as_dict=True)
return system_asset
@frappe.whitelist()
def get_system(doc):
system_map = frappe.db.sql("""select name from `tabSystem Mapping` where variant_mapping=%s""",doc,as_dict=True)
if system_map:
for s in system_map:
doc = frappe.get_doc("System Mapping",s.name)
system = frappe.db.sql("""select systems,sub_systems,active_status,symptom,component,estimated_time,rts,component,mat,procedure_status,`procedure` from `tabSystem Mapping_Sub System` where parent = %s and procedure_is_published = '0'""",s.name,as_dict=True)
return system

Loading…
Cancel
Save