Browse Source

Publish field fix

master
venkataakhil 1 year ago
parent
commit
067e4f03c4
  1. 3
      .gitignore
  2. BIN
      __pycache__/setup.cpython-38.pyc
  3. BIN
      smart_service/add_ons/__pycache__/__init__.cpython-38.pyc
  4. BIN
      smart_service/add_ons/doctype/__pycache__/__init__.cpython-38.pyc
  5. BIN
      smart_service/add_ons/doctype/app_dealer/__pycache__/__init__.cpython-38.pyc
  6. BIN
      smart_service/add_ons/doctype/app_dealer/__pycache__/app_dealer.cpython-38.pyc
  7. BIN
      smart_service/add_ons/doctype/app_device/__pycache__/__init__.cpython-38.pyc
  8. BIN
      smart_service/add_ons/doctype/app_device/__pycache__/app_device.cpython-38.pyc
  9. BIN
      smart_service/add_ons/doctype/app_log/__pycache__/__init__.cpython-38.pyc
  10. BIN
      smart_service/add_ons/doctype/app_log/__pycache__/app_log.cpython-38.pyc
  11. BIN
      smart_service/add_ons/doctype/app_preference/__pycache__/__init__.cpython-38.pyc
  12. BIN
      smart_service/add_ons/doctype/app_preference/__pycache__/app_preference.cpython-38.pyc
  13. BIN
      smart_service/add_ons/doctype/app_users/__pycache__/__init__.cpython-38.pyc
  14. BIN
      smart_service/add_ons/doctype/app_users/__pycache__/app_users.cpython-38.pyc
  15. BIN
      smart_service/add_ons/doctype/captcha_validation/__pycache__/__init__.cpython-38.pyc
  16. BIN
      smart_service/add_ons/doctype/captcha_validation/__pycache__/captcha_validation.cpython-38.pyc
  17. BIN
      smart_service/add_ons/doctype/user_feedback/__pycache__/__init__.cpython-38.pyc
  18. BIN
      smart_service/add_ons/doctype/user_feedback/__pycache__/user_feedback.cpython-38.pyc
  19. BIN
      smart_service/add_ons/doctype/user_feedback_types/__pycache__/__init__.cpython-38.pyc
  20. BIN
      smart_service/add_ons/doctype/user_feedback_types/__pycache__/user_feedback_types.cpython-38.pyc
  21. BIN
      smart_service/apis/__pycache__/addon_api.cpython-38.pyc
  22. BIN
      smart_service/apis/__pycache__/master_api.cpython-38.pyc
  23. BIN
      smart_service/apis/__pycache__/publish_api.cpython-38.pyc
  24. 111
      smart_service/apis/publish_api.py
  25. 2
      smart_service/hooks.py
  26. BIN
      smart_service/masters/__pycache__/__init__.cpython-38.pyc
  27. BIN
      smart_service/masters/doctype/__pycache__/__init__.cpython-38.pyc
  28. BIN
      smart_service/masters/doctype/variant/__pycache__/__init__.cpython-38.pyc
  29. BIN
      smart_service/masters/doctype/variant/__pycache__/variant.cpython-38.pyc
  30. BIN
      smart_service/masters/doctype/vehicle/__pycache__/__init__.cpython-38.pyc
  31. BIN
      smart_service/masters/doctype/vehicle/__pycache__/vehicle.cpython-38.pyc
  32. 4
      smart_service/public/css/smart_service.css
  33. BIN
      smart_service/public/images/Mahindra Rise2.png
  34. BIN
      smart_service/public/images/Mahindra Rise2_test.png
  35. BIN
      smart_service/reports/__pycache__/__init__.cpython-38.pyc
  36. BIN
      smart_service/transactions/doctype/kilometer_mapping/__pycache__/__init__.cpython-38.pyc
  37. BIN
      smart_service/transactions/doctype/kilometer_mapping/__pycache__/kilometer_mapping.cpython-38.pyc
  38. BIN
      smart_service/transactions/doctype/kilometer_mapping_items/__pycache__/__init__.cpython-38.pyc
  39. BIN
      smart_service/transactions/doctype/kilometer_mapping_items/__pycache__/kilometer_mapping_items.cpython-38.pyc
  40. BIN
      smart_service/transactions/doctype/publish/__pycache__/__init__.cpython-38.pyc
  41. BIN
      smart_service/transactions/doctype/publish/__pycache__/publish.cpython-38.pyc
  42. 111
      smart_service/transactions/doctype/publish/publish.js
  43. 12
      smart_service/transactions/doctype/publish/publish.json
  44. 116
      smart_service/transactions/doctype/publish/publish.py
  45. BIN
      smart_service/transactions/doctype/publish_docs/__pycache__/__init__.cpython-38.pyc
  46. BIN
      smart_service/transactions/doctype/publish_docs/__pycache__/publish_docs.cpython-38.pyc
  47. BIN
      smart_service/transactions/doctype/publish_temp_doc/__pycache__/__init__.cpython-38.pyc
  48. BIN
      smart_service/transactions/doctype/publish_temp_doc/__pycache__/publish_temp_doc.cpython-38.pyc
  49. BIN
      smart_service/transactions/doctype/publish_variant_mapping_assets/__pycache__/__init__.cpython-38.pyc
  50. BIN
      smart_service/transactions/doctype/publish_variant_mapping_assets/__pycache__/publish_variant_mapping_assets.cpython-38.pyc
  51. BIN
      smart_service/transactions/doctype/system_mapping/__pycache__/__init__.cpython-38.pyc
  52. BIN
      smart_service/transactions/doctype/system_mapping/__pycache__/system_mapping.cpython-38.pyc
  53. BIN
      smart_service/transactions/doctype/system_mapping_sub_system/__pycache__/__init__.cpython-38.pyc
  54. BIN
      smart_service/transactions/doctype/system_mapping_sub_system/__pycache__/system_mapping_sub_system.cpython-38.pyc
  55. BIN
      smart_service/transactions/doctype/system_mapping_system_assets/__pycache__/__init__.cpython-38.pyc
  56. BIN
      smart_service/transactions/doctype/system_mapping_system_assets/__pycache__/system_mapping_system_assets.cpython-38.pyc
  57. BIN
      smart_service/transactions/doctype/variant_mapping/__pycache__/__init__.cpython-38.pyc
  58. BIN
      smart_service/transactions/doctype/variant_mapping/__pycache__/variant_mapping.cpython-38.pyc
  59. BIN
      smart_service/transactions/doctype/variant_mapping_assets/__pycache__/__init__.cpython-38.pyc
  60. BIN
      smart_service/transactions/doctype/variant_mapping_assets/__pycache__/variant_mapping_assets.cpython-38.pyc
  61. BIN
      smart_service/transactions/report/__pycache__/__init__.cpython-38.pyc
  62. BIN
      smart_service/transactions/report/kilometer_mapping/__pycache__/__init__.cpython-38.pyc
  63. BIN
      smart_service/transactions/report/kilometer_mapping/__pycache__/kilometer_mapping.cpython-38.pyc
  64. 0
      smart_service/www/__init__.py

3
.gitignore

@ -4,4 +4,5 @@
tags
smart_service/docs/current
*.pyc
__pycache__/
__pycache__/
smart_service/transactions/doctype/publish/publish.py

BIN
__pycache__/setup.cpython-38.pyc

Binary file not shown.

BIN
smart_service/add_ons/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/add_ons/doctype/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/add_ons/doctype/app_dealer/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/add_ons/doctype/app_dealer/__pycache__/app_dealer.cpython-38.pyc

Binary file not shown.

BIN
smart_service/add_ons/doctype/app_device/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/add_ons/doctype/app_device/__pycache__/app_device.cpython-38.pyc

Binary file not shown.

BIN
smart_service/add_ons/doctype/app_log/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/add_ons/doctype/app_log/__pycache__/app_log.cpython-38.pyc

Binary file not shown.

BIN
smart_service/add_ons/doctype/app_preference/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/add_ons/doctype/app_preference/__pycache__/app_preference.cpython-38.pyc

Binary file not shown.

BIN
smart_service/add_ons/doctype/app_users/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/add_ons/doctype/app_users/__pycache__/app_users.cpython-38.pyc

Binary file not shown.

BIN
smart_service/add_ons/doctype/captcha_validation/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/add_ons/doctype/captcha_validation/__pycache__/captcha_validation.cpython-38.pyc

Binary file not shown.

BIN
smart_service/add_ons/doctype/user_feedback/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/add_ons/doctype/user_feedback/__pycache__/user_feedback.cpython-38.pyc

Binary file not shown.

BIN
smart_service/add_ons/doctype/user_feedback_types/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/add_ons/doctype/user_feedback_types/__pycache__/user_feedback_types.cpython-38.pyc

Binary file not shown.

BIN
smart_service/apis/__pycache__/addon_api.cpython-38.pyc

Binary file not shown.

BIN
smart_service/apis/__pycache__/master_api.cpython-38.pyc

Binary file not shown.

BIN
smart_service/apis/__pycache__/publish_api.cpython-38.pyc

Binary file not shown.

111
smart_service/apis/publish_api.py

@ -251,15 +251,15 @@ def print(sts):
@frappe.whitelist(allow_guest=True)
def new_publish(args, publish_type, vehicle, language, version):
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
return rate_res
# rate_res = custom_rate_limit(limit=5, seconds=15)
# if rate_res != 1:
# return rate_res
val = input_validation(args=args, publish_type=publish_type,
vehicle=vehicle, language=language, version=version)
if val != '':
return {'status': 0, 'error': "Parameter missing :"+val}
# Create Directory for internal,global and full_update publish
list1 = []
# list1 = []
try:
try:
if not os.path.exists(internal_path + vehicle + '/'):
@ -274,20 +274,20 @@ def new_publish(args, publish_type, vehicle, language, version):
# JSON generation
json_file = json_grouping(args, language)
file_name = '%s-%s_v%s.json' % (vehicle, language, version)
file_name = ''
base_file_name = '%s-%s_v%s.json' % (vehicle, language, version)
# File name generation
if publish_type.lower() == 'internal':
file_name = internal_path + vehicle + '/' + file_name
file_name = internal_path + vehicle + '/' + base_file_name
elif publish_type.lower() == 'global':
file_name = global_path + vehicle + '/' + file_name
file_name = global_path + vehicle + '/' + base_file_name
else:
return {"status": 0, 'error': 'Publish type not available'}
# Save file (Internal/Global)
with open(file_name, 'w') as outfile:
outfile.write(json.dumps(json_file))
get_step_total_count(file_name)
# get_step_total_count(file_name)
# Remove previous internal publish file
if publish_type.lower() == 'internal':
@ -301,15 +301,14 @@ def new_publish(args, publish_type, vehicle, language, version):
pub_ver = None
prev_update_ver = None
if publish_type.lower() == 'global':
full_update_file_name = full_update_path + vehicle + '/' + \
'%s-%s-full_v%s.json' % (vehicle, language, version)
# Since full update is not available for Global version 1
if version == '1.00':
with open(full_update_file_name, 'w') as outfile:
outfile.write(json.dumps(json_file))
get_step_total_count(full_update_file_name)
# get_step_total_count(full_update_file_name)
else:
pub_ver = frappe.db.sql(''' SELECT vehicle,`language`,version,publish_type FROM tabPublish where vehicle = '{}'
@ -319,16 +318,17 @@ def new_publish(args, publish_type, vehicle, language, version):
prev_full_update_file = full_update_path + vehicle + '/' + \
'%s-%s-full_v%s.json' % (vehicle,
language, prev_update_ver)
list1.append(prev_full_update_file)
list1.append(file_name)
list1.append(full_update_file_name)
final_update_file = merge_json_files(
file_flag, final_update_file = merge_json_files(
prev_full_update_file, file_name, full_update_file_name)
get_step_total_count(final_update_file)
if file_flag:
return True, file_name.split('public')[1]
# get_step_total_count(final_update_file)
return file_name.split('public')[1]
except:
return "Failed to save file"
return True, file_name.split('public')[1]
except Exception as e:
# return "Failed to save file"
return False, str(frappe.get_traceback())
@frappe.whitelist(allow_guest=True)
@ -381,31 +381,29 @@ def new_update(vehicle_list=None):
@frappe.whitelist(allow_guest=True)
def merge_json_files(old_json_path, new_json_path, out_file_path):
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
return rate_res
val = input_validation(old_json_path=old_json_path,
new_json_path=new_json_path, out_file_path=out_file_path)
if val != '':
return {'status': 0, 'error': "Parameter missing :"+val}
# rate_res = custom_rate_limit(limit=5, seconds=15)
# if rate_res != 1:
# return rate_res
# val = input_validation(old_json_path=old_json_path,
# new_json_path=new_json_path, out_file_path=out_file_path)
# if val != '':
# return {'status': 0, 'error': "Parameter missing :" + val}
try:
with open(old_json_path) as json_file:
with open(old_json_path, 'r') as json_file:
data_old = json.load(json_file)
with open(new_json_path) as json_file:
data_new = json.load(json_file)
with open(new_json_path, 'r') as json_file1:
data_new = json.load(json_file1)
data_consolidated = {'JSON': []}
# print('Collecting Variants...')
variant_name = set()
sub_system_name = set()
procedure_name = set()
step_name = set()
variant_added = set()
for variant in data_old['JSON']:
variant_name.add(variant['Variant']['name'])
for variant in data_new['JSON']:
variant_name.add(variant['Variant']['name'])
# print('Comparing Variants...')
for variant_new in data_new['JSON']:
if variant_new['Variant']['name'] in variant_name and variant_new['Variant']['name'] not in variant_added:
@ -415,19 +413,19 @@ def merge_json_files(old_json_path, new_json_path, out_file_path):
variant_asset_name = set()
variant_asset_added = set()
variant_asset_list = []
# print(variant_new['Variant'])
try:
variant_new['Variant']['Assets']
# variant_new['Variant']['Assets']
for variant_asset in variant_new['Variant']['Assets']:
variant_asset_name.add(variant_asset['file'])
if variant_asset['file'] not in variant_asset_added and variant_asset['file'] in variant_asset_name:
if variant_asset['file'] not in variant_asset_added and variant_asset[
'file'] in variant_asset_name:
variant_asset_list.append(variant_asset)
variant_asset_added.add(variant_asset['file'])
except:
pass
# print('Assets not present in '+variant_new['Variant']['name'])
try:
variant_new['Variant']['Systems']
# variant_new['Variant']['Systems']
for system in variant_new['Variant']['Systems']:
system_asset_name = set()
system_asset_added = set()
@ -447,10 +445,10 @@ def merge_json_files(old_json_path, new_json_path, out_file_path):
conf_km_name.add(ck['kilometer_name'])
if ck['kilometer_name'] not in conf_km_added and ck['kilometer_name'] in conf_km_name:
conf_km_list.append({
"kilometer_name": ck['kilometer_name'],
"kilometer_IDX": ck['kilometer_IDX'],
"kilometers_applicable": ck['kilometers_applicable']
})
"kilometer_name": ck['kilometer_name'],
"kilometer_IDX": ck['kilometer_IDX'],
"kilometers_applicable": ck['kilometers_applicable']
})
conf_km_added.add(
ck['kilometer_name'])
for old_variants in data_old['JSON']:
@ -462,7 +460,8 @@ def merge_json_files(old_json_path, new_json_path, out_file_path):
for old_ck in old_sub_system['Config Kilometer']:
conf_km_name.add(
old_ck['kilometer_name'])
if old_ck['kilometer_name'] not in conf_km_added and old_ck['kilometer_name'] in conf_km_name:
if old_ck['kilometer_name'] not in conf_km_added and \
old_ck['kilometer_name'] in conf_km_name:
sub_system_list.append(
old_ck)
conf_km_added.add(
@ -472,7 +471,8 @@ def merge_json_files(old_json_path, new_json_path, out_file_path):
proc_det_list = []
for pd in subsystem['Procedure_details']:
proc_det_name.add(pd['procedure_name'])
if pd['procedure_name'] not in proc_det_added and pd['procedure_name'] in proc_det_name:
if pd['procedure_name'] not in proc_det_added and pd[
'procedure_name'] in proc_det_name:
proc_det_list.append({
"procedure_name": pd['procedure_name'],
"steps": pd['steps'],
@ -488,7 +488,8 @@ def merge_json_files(old_json_path, new_json_path, out_file_path):
for old_pd in old_sub_system['Procedure_details']:
proc_det_name.add(
old_pd['kilometer_name'])
if old_pd['procedure_name'] not in proc_det_added and old_pd['procedure_name'] in proc_det_name:
if old_pd['procedure_name'] not in proc_det_added and \
old_pd['procedure_name'] in proc_det_name:
sub_system_list.append(
old_pd)
proc_det_added.add(
@ -518,14 +519,16 @@ def merge_json_files(old_json_path, new_json_path, out_file_path):
for old_sub_system in old_system['Subsystems']:
sub_system_name.add(
old_sub_system['sub_systems'])
if old_sub_system['sub_systems'] not in sub_system_added and old_sub_system['sub_systems'] in sub_system_name:
if old_sub_system['sub_systems'] not in sub_system_added and \
old_sub_system['sub_systems'] in sub_system_name:
sub_system_list.append(
old_sub_system)
sub_system_added.add(
old_sub_system['sub_systems'])
for asset in system['Assets']:
system_asset_name.add(asset['system_asset'])
if asset['system_asset'] not in system_asset_added and asset['system_asset'] in system_asset_name:
if asset['system_asset'] not in system_asset_added and asset[
'system_asset'] in system_asset_name:
system_asset_list.append({"system_asset": asset['system_asset'],
"systemdisplayorder": asset['systemdisplayorder'],
"active_status": asset['active_status'],
@ -539,7 +542,8 @@ def merge_json_files(old_json_path, new_json_path, out_file_path):
for old_system_asset in old_system['Assets']:
system_asset_name.add(
old_system_asset['system_asset'])
if old_system_asset['system_asset'] not in system_asset_added and old_system_asset['system_asset'] in system_asset_name:
if old_system_asset['system_asset'] not in system_asset_added and \
old_system_asset['system_asset'] in system_asset_name:
system_asset_list.append(
old_system_asset)
system_asset_added.add(
@ -573,12 +577,14 @@ def merge_json_files(old_json_path, new_json_path, out_file_path):
"variant": variant_new['Variant']['variant'],
"vehicle": variant_new['Variant']['vehicle'],
"family_code": variant_new['Variant']['family_code'],
"vehicle_segment": variant_new['Variant']['vehicle_segment'],
"vehicle_segment": variant_new['Variant'][
'vehicle_segment'],
"fuel": variant_new['Variant']['fuel'],
"transmission": variant_new['Variant']['transmission'],
"drive": variant_new['Variant']['drive'],
"active_status": variant_new['Variant']['active_status'],
"kms_mapping_active_status": variant_new['Variant']['kms_mapping_active_status'],
"kms_mapping_active_status": variant_new['Variant'][
'kms_mapping_active_status'],
"Assets": variant_asset_list,
"Systems": system_list
}})
@ -590,9 +596,10 @@ def merge_json_files(old_json_path, new_json_path, out_file_path):
json_object = json.dumps(data_consolidated)
with open(out_file_path, "w") as outfile:
outfile.write(json_object)
return out_file_path
return True, out_file_path
except Exception as e:
return "Exception in publish"
return False, frappe.get_traceback()
# return "Exception in publish"
def get_step_total_count(json_path):

2
smart_service/hooks.py

@ -9,7 +9,7 @@ app_color = "#E31A37"
app_email = "siva@hnsonline.com"
app_license = "MIT"
# app_logo_url = "/assets/smart_service/images/SS Alone.png"
app_logo_url = "/assets/smart_service/images/SsAndMahindra.png"
app_logo_url = "/assets/smart_service/images/Mahindra Rise2.png"
# app_logo_url = "/assets/smart_service/images/ic_app_icon1.png"
# ic_app_icon.png

BIN
smart_service/masters/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/masters/doctype/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/masters/doctype/variant/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/masters/doctype/variant/__pycache__/variant.cpython-38.pyc

Binary file not shown.

BIN
smart_service/masters/doctype/vehicle/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/masters/doctype/vehicle/__pycache__/vehicle.cpython-38.pyc

Binary file not shown.

4
smart_service/public/css/smart_service.css

@ -26,8 +26,8 @@
}
.app-logo {
width: 400px !important;
height: 50px !important;
/* width: 400px !important;
height: 50px !important; */
image-rendering: -webkit-optimize-contrast !important;
filter: none !important;
}

BIN
smart_service/public/images/Mahindra Rise2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
smart_service/public/images/Mahindra Rise2_test.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
smart_service/reports/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/kilometer_mapping/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/kilometer_mapping/__pycache__/kilometer_mapping.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/kilometer_mapping_items/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/kilometer_mapping_items/__pycache__/kilometer_mapping_items.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/publish/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/publish/__pycache__/publish.cpython-38.pyc

Binary file not shown.

111
smart_service/transactions/doctype/publish/publish.js

@ -113,8 +113,8 @@ frappe.ui.form.on('Publish', {
cur_frm.refresh_field('version')
if (frm.doc.docstatus === 1 && frm.doc.publish_status == 'To Publish') {
frappe.call({
// method: "smart_service.apis.publish_api.api_procedure",
method: "smart_service.apis.publish_api.new_publish",
// method: "smart_service.apis.publish_api.api_procedure",
method: "smart_service.apis.publish_api.new_publish",
args: {
"args": frm.doc.name,
"publish_type": frm.doc.publish_type,
@ -123,43 +123,74 @@ frappe.ui.form.on('Publish', {
"version": frm.doc.version
},
callback: function (r) {
frm.set_value('publish_status', 'Published');
frm.set_value('actual_published_date', frappe.datetime.nowdate());
if (r.message != "Failed to save file") {
if (r.message[0]) {
frm.set_value('publish_status', 'Published');
frm.set_value('actual_published_date', frappe.datetime.nowdate());
frappe.call({
method: "smart_service.transactions.doctype.publish.publish.update_procedure_value",
args: {
"name": frm.doc.name,
},
callback: (r) => {
args: {
"name": frm.doc.name,
"file_path": r.message[1],
},
callback: (r) => {
// frm.save('Update');
}
}
})
// frm.set_value('publish_status', 'Published');
// frm.set_value('actual_published_date', frappe.datetime.nowdate());
frappe.msgprint({
title: __('Notification'),
message: __('Successfully Published' + r.message),
message: __('<b>Successfully Published:</b> ' + r.message[1]),
primary_action: {
action(values) {
frm.save('Update');
}
}
});
} else {
frappe.msgprint('Publish Failed')
}
else {
frappe.msgprint({
title: __('Notification'),
message: __('<b>Not Successfully Published:</b> ' + r.message[1]),
// primary_action: {
// action(values) {
// frm.save('Update');
// }
// }
});
}
// if (r.message != "Failed to save file") {
// frm.set_value('publish_status', 'Published');
// frm.set_value('actual_published_date', frappe.datetime.nowdate());
// frappe.call({
// method: "smart_service.transactions.doctype.publish.publish.update_procedure_value",
// args: {
// "name": frm.doc.name,
// "file_path": r.message,
// },
// callback: (r) => {
// // frm.save('Update');
// }
// })
// frappe.msgprint({
// title: __('Notification'),
// message: __('<b>Successfully Published:</b> ' + r.message),
// primary_action: {
// action(values) {
// frm.save('Update');
// }
// }
// });
// } else {
// frappe.msgprint('Publish Failed')
// }
}
});
}
},
})
}
}, () => {
// action to perform if No is selected
});
@ -171,12 +202,12 @@ frappe.ui.form.on('Publish', {
if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish') {
frm.get_field('system_mapping').grid.add_custom_button(__('Add to Publish'), function () {
var added = 0;
var topublish = [];
let added = 0;
let topublish = [];
if (frm.doc.publish_type == 'Global') { topublish = ['Publish Ready']; } else { topublish = ['Review Pending', 'Publish Ready', 'Approval Pending']; }
frm.doc.system_mapping.forEach(row => {
if (topublish.indexOf(row.procedure_status) > -1) {
var dulicate = false;
let dulicate = false;
if (frm.doc.publish_documents) {
frm.doc.publish_documents.forEach(publishrow => {
if (frm.doc.variant_mapping == publishrow.variant_mapping &&
@ -187,7 +218,7 @@ frappe.ui.form.on('Publish', {
});
}
if (dulicate === false) {
var child = cur_frm.add_child("publish_documents");
let child = cur_frm.add_child("publish_documents");
child.variant_mapping = frm.doc.variant_mapping;
child.system = row.systems;
child.sub_system = row.sub_systems;
@ -210,11 +241,10 @@ frappe.ui.form.on('Publish', {
}
if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish') {
frm.get_field('variant_mapping_assets').grid.add_custom_button(__('Add to Publish'), function () {
var added = 0;
var topublish = [];
let added = 0;
frm.doc.variant_mapping_assets.forEach(row => {
if (row.active_status == "Active" || row.active_status == "Inactive") {
var dulicate = false;
let dulicate = false;
if (frm.doc.publish_documents) {
frm.doc.publish_documents.forEach(publishrow => {
if (frm.doc.variant_mapping == publishrow.variant_mapping &&
@ -224,7 +254,7 @@ frappe.ui.form.on('Publish', {
});
}
if (dulicate === false) {
var child = cur_frm.add_child("publish_documents");
let child = cur_frm.add_child("publish_documents");
child.variant_mapping = frm.doc.variant_mapping;
child.asset_category = row.category;
child.item_category = "Variant Mapping Assets";
@ -246,12 +276,12 @@ frappe.ui.form.on('Publish', {
}
},
validate: function (frm) {
var regex = /[!@#$%^*_+\=\[\]{};'`~\\|.<>\?]+/;
if (regex.test(frm.doc.release_description) === true) {
let regex = /[!@#$%^*_+\=\[\]{};'`~\\|.<>\?]+/;
if (regex.test(frm.doc.release_description) === true) {
frm.doc.release_description = '';
frm.refresh_fields();
frappe.msgprint(__("<b>Publish Description:</b> Only letters, numbers and <b> / - () & , ' : </b> are allowed."));
}
frappe.msgprint(__("<b>Publish Description:</b> Only letters, numbers and <b> / - () & , ' : </b> are allowed."));
}
if (frm.doc.vehicle && frm.doc.release_description && frm.fields_dict.publish_documents.grid.grid_rows.length === 0) {
frappe.msgprint(__("No item selected to Publish"));
@ -268,7 +298,7 @@ frappe.ui.form.on('Publish', {
cur_frm.refresh_field('variant');
})
var km_name = frm.doc.variant_mapping + "-" + frm.doc.language + "-KM";
let km_name = frm.doc.variant_mapping + "-" + frm.doc.language + "-KM";
frappe.db.get_value('Kilometer Mapping', { name: km_name }, 'workflow_state', (r) => {
if (r.workflow_state == "Draft") {
frm.doc.kilometer_mapping = '';
@ -307,7 +337,7 @@ frappe.ui.form.on('Publish', {
}, 5);
}
if (frm.doc.km_active_status === "" || frm.doc.km_active_status === null) { return; }
var filter = frm.doc.variant_mapping + "-" + frm.doc.language + "-SM";
let filter = frm.doc.variant_mapping + "-" + frm.doc.language + "-SM";
if (frm.doc.variant_mapping_status == "Active" && frm.doc.km_active_status == "Active") {
frappe.call({
"method": "smart_service.transactions.doctype.publish.publish.get_system",
@ -317,7 +347,7 @@ frappe.ui.form.on('Publish', {
},
callback: function (r) {
$.each(r.message, function (index, row) {
var child;
let child;
child = cur_frm.add_child("system_mapping");
child.systems = row.systems;
child.sub_systems = row.sub_systems;
@ -343,7 +373,7 @@ frappe.ui.form.on('Publish', {
},
callback: function (r) {
$.each(r.message, function (index, row) {
var child;
let child;
child = cur_frm.add_child("variant_mapping_assets");
child.category = row.category;
child.language = row.language;
@ -364,7 +394,7 @@ frappe.ui.form.on('Publish', {
},
callback: function (r) {
$.each(r.message, function (index, row) {
var child_row;
let child_row;
child_row = cur_frm.add_child("variant_mapping_assets");
child_row.category = row.systems;
child_row.language = row.language;
@ -388,7 +418,7 @@ frappe.ui.form.on('Publish', {
}
},
add_variant_mapping_to_publish: function (frm) {
var dulicate = false;
let dulicate = false;
if (frm.doc.publish_documents) {
frm.doc.publish_documents.forEach(publishrow => {
if (frm.doc.variant_mapping == publishrow.variant_mapping && publishrow.systems === undefined && publishrow.sub_systems === undefined && publishrow.procedure === undefined) {
@ -398,7 +428,7 @@ frappe.ui.form.on('Publish', {
frappe.msgprint("Variant Mapping already added");
}
if (dulicate === false) {
var child = cur_frm.add_child("publish_documents");
let child = cur_frm.add_child("publish_documents");
child.variant_mapping = frm.doc.variant_mapping;
child.item_category = "Variant Mapping";
refresh_field("publish_documents");
@ -419,7 +449,7 @@ frappe.ui.form.on('Publish', {
},
callback: function (r) {
if (r.message) {
var vehicle = frm.doc.vehicle;
let vehicle = frm.doc.vehicle;
cur_frm.doc.vehicle = '';
cur_frm.doc.vehicle_status = '';
cur_frm.refresh_field('vehicle');
@ -462,6 +492,7 @@ frappe.ui.form.on('Publish', {
doc: frm.doc.name
},
callback: (r) => {
frm.doc.version = r
cur_frm.refresh_field('version')
},
error: (r) => {

12
smart_service/transactions/doctype/publish/publish.json

@ -11,6 +11,7 @@
"actual_published_date",
"publish_type",
"publish_status",
"file_path",
"column_break_3",
"release_description",
"version",
@ -222,7 +223,7 @@
{
"allow_on_submit": 1,
"fieldname": "version",
"fieldtype": "Data",
"fieldtype": "Float",
"in_standard_filter": 1,
"label": "Version",
"read_only": 1
@ -296,12 +297,19 @@
"fieldtype": "Small Text",
"label": "Kilometer Mapping List",
"read_only": 1
},
{
"allow_on_submit": 1,
"fieldname": "file_path",
"fieldtype": "Data",
"label": "File Path",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2023-05-16 16:59:45.341061",
"modified": "2023-05-20 12:35:06.604859",
"modified_by": "Administrator",
"module": "Transactions",
"name": "Publish",

116
smart_service/transactions/doctype/publish/publish.py

@ -16,9 +16,11 @@ class Publish(Document):
# Selected variant and kilometer mapping details list
variant = []
for vm in self.get('publish_documents'):
if vm.variant_mapping in variant:
pass
else:
# if vm.variant_mapping in variant:
# pass
# else:
# variant.append(vm.variant_mapping)
if vm.variant_mapping not in variant:
variant.append(vm.variant_mapping)
self.variant_mapping_details = ''
@ -33,13 +35,13 @@ class Publish(Document):
str(km_mapping.name) + '\n'
def onload1(self):
current_db_name = frappe.conf.get("db_name")
current_db_name = frappe.conf.get("db_name")
# To validate updated procedure status
procedure_status = frappe.db.sql("""select p.name,p.update_procedure_status,pro.name,p.variant_mapping,p.system,p.sub_system,p.asset_category,p.item_category,p.variant,p.procedure_link,p.procedure_status,pro.name,pro.workflow_state
from {0}.`tabPublish_Docs` as p,{0}.`tabProcedure` as pro
where p.parent = '{1}' and p.procedure_link = pro.name and p.procedure_link is not null""".format(current_db_name, self.name), as_dict=True)
l = len(procedure_status)
if procedure_status and self.publish_status == "Published":
for x in procedure_status:
for y in self.get("publish_documents"):
@ -141,8 +143,8 @@ def cal_ver(vehicle, lang, publish_type, doc):
update_procedure(vehicle, lang, publish_type, doc)
current_db_name = frappe.conf.get("db_name")
doc = frappe.get_doc("Publish", doc)
ver = frappe.db.sql("""select max(version),publish_type from {current_db_name}.tabPublish where vehicle = '{vehi}' and language = '{lang}';"""
.format(current_db_name=current_db_name, vehi=vehicle, lang=lang))
ver = frappe.db.sql("""select max(version) from `tabPublish` where vehicle = '{vehi}' and language = '{lang}';"""
.format(vehi=vehicle, lang=lang))
v = 0.0
if publish_type == 'Global':
if ver[0][0] == None:
@ -176,7 +178,6 @@ def global_publish(doc):
if not procedure and not asset:
frappe.throw("There is no item for global publish")
publish_type = "Global"
publish_record = frappe.new_doc("Publish")
publish_record.language = doc.language
publish_record.publish_type = "Global"
@ -316,52 +317,57 @@ def variant(doctype, txt, searchfield, start, page_len, filters):
@frappe.whitelist()
def update_procedure_value(name):
self = frappe.get_doc("Publish",name)
current_db_name = frappe.conf.get("db_name")
# To validate updated procedure status
procedure_status = frappe.db.sql("""select p.name,p.update_procedure_status,pro.name,p.variant_mapping,p.system,p.sub_system,p.asset_category,p.item_category,p.variant,p.procedure_link,p.procedure_status,pro.name,pro.workflow_state
from {0}.`tabPublish_Docs` as p,{0}.`tabProcedure` as pro
where p.parent = '{1}' and p.procedure_link = pro.name and p.procedure_link is not null""".format(current_db_name, self.name), as_dict=True)
l = len(procedure_status)
if procedure_status:
for x in procedure_status:
for y in self.get("publish_documents"):
if y.procedure_link:
if x.procedure_link == y.procedure_link and y.update_procedure_status != y.procedure_status:
y.update_procedure_status = x.workflow_state
frappe.db.sql("""update `tabPublish_Docs` set update_procedure_status = %s where parent = %s and procedure_link = %s ; """, (
x.workflow_state, self.name, x.procedure_link))
frappe.db.commit()
if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status:
y.update_procedure_status = x.workflow_state
frappe.db.sql("""update `tabPublish_Docs` set update_procedure_status = %s where parent = %s and procedure_link = %s""", (
x.workflow_state, self.name, x.procedure_link))
frappe.db.commit()
if y.procedure_status == "Publish Ready":
if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status and not y.excluded_global:
y.excluded_global = "1"
if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status and x.workflow_state == "Draft" and y.procedure_status != "Publish Ready":
y.excluded_internal = "1"
y.save()
frappe.db.commit()
def update_procedure_value(name, file_path):
self = frappe.get_doc("Publish", name)
# Update system and variant mapping ststus
if self.publish_type == "Global":
current_db_name = frappe.conf.get("db_name")
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)
frappe.db.sql(
f'''update `tabPublish` set file_path = '{file_path}' where name = '{name}';''')
frappe.db.commit()
current_db_name = frappe.conf.get("db_name")
# To validate updated procedure status
procedure_status = frappe.db.sql("""select p.name,p.update_procedure_status,pro.name,p.variant_mapping,p.system,p.sub_system,
p.asset_category,p.item_category,p.variant,p.procedure_link,p.procedure_status,pro.name,pro.workflow_state
from {0}.`tabPublish_Docs` as p,{0}.`tabProcedure` as pro where p.parent = '{1}' and
p.procedure_link = pro.name and p.procedure_link is not null""".format(current_db_name, self.name), as_dict=True)
# l = len(procedure_status)
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:
self.published_by = str(name)
frappe.db.set_value(
"Publish", self.name, "published_by", str(name))
frappe.db.commit()
if procedure_status:
for x in procedure_status:
for y in self.get("publish_documents"):
if y.procedure_link:
if x.procedure_link == y.procedure_link and y.update_procedure_status != y.procedure_status:
y.update_procedure_status = x.workflow_state
frappe.db.sql("""update `tabPublish_Docs` set update_procedure_status = %s where parent = %s and procedure_link = %s ; """, (
x.workflow_state, self.name, x.procedure_link))
frappe.db.commit()
if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status:
y.update_procedure_status = x.workflow_state
frappe.db.sql("""update `tabPublish_Docs` set update_procedure_status = %s where parent = %s and procedure_link = %s""", (
x.workflow_state, self.name, x.procedure_link))
frappe.db.commit()
if y.procedure_status == "Publish Ready":
if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status and not y.excluded_global:
y.excluded_global = "1"
if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status and x.workflow_state == "Draft" and y.procedure_status != "Publish Ready":
y.excluded_internal = "1"
y.save()
frappe.db.commit()
# Update system and variant mapping ststus
if self.publish_type == "Global":
current_db_name = frappe.conf.get("db_name")
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:
self.published_by = str(name)
frappe.db.set_value(
"Publish", self.name, "published_by", str(name))
frappe.db.commit()

BIN
smart_service/transactions/doctype/publish_docs/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/publish_docs/__pycache__/publish_docs.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/publish_temp_doc/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/publish_temp_doc/__pycache__/publish_temp_doc.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/publish_variant_mapping_assets/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/publish_variant_mapping_assets/__pycache__/publish_variant_mapping_assets.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/system_mapping/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/system_mapping/__pycache__/system_mapping.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/system_mapping_sub_system/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/system_mapping_sub_system/__pycache__/system_mapping_sub_system.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/system_mapping_system_assets/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/system_mapping_system_assets/__pycache__/system_mapping_system_assets.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/variant_mapping/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/variant_mapping/__pycache__/variant_mapping.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/variant_mapping_assets/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/doctype/variant_mapping_assets/__pycache__/variant_mapping_assets.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/report/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/report/kilometer_mapping/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
smart_service/transactions/report/kilometer_mapping/__pycache__/kilometer_mapping.cpython-38.pyc

Binary file not shown.

0
smart_service/www/__init__.py

Loading…
Cancel
Save