Compare commits

...

129 Commits

Author SHA1 Message Date
venkata akhil 6138c77805 hide unused field myid 8 months ago
venkata akhil a751202101 role master,publish hide update button 8 months ago
venkata akhil 7511792331 Training Information Publish Changes 9 months ago
venkata akhil 7ec7d3df88 torque.training info,publish changes 9 months ago
venkata akhil 2b5ee828d4 Display select model in Model Hit and model download 9 months ago
venkata akhil 0efdd804c8 Torque mapping column table bootstrap 9 months ago
venkata akhil 68aab0d9a7 Torque mapping colum HTML update 9 months ago
venkata akhil 999c13552b Format master.py 9 months ago
venkata akhil 7da8abfae9 Publish update 9 months ago
venkata akhil 0052df518a Hide check fields - Module publish, qwik and training information 9 months ago
venkata akhil fc3a0b75f9 Torque table column doctype delete 9 months ago
venkata akhil 484a989f1b Translation reports code formatting 9 months ago
venkata akhil c62edba301 App user login api file update for fixing installed/reinstalled and mahindra login api https fix 9 months ago
venkata akhil c078b03f03 Feebback report, installation, login, model download and model hit from master branch 9 months ago
venkata akhil c0f7b47e16 Torque Manual and Training information 10 months ago
venkata akhil d34585b286 Torque and training information 10 months ago
venkata akhil b205a9b8ba Torque manual publish 10 months ago
venkata akhil ab5c03a6fa torque manual doctype 10 months ago
administrator a846a0395d Merge 3.6 10 months ago
administrator 8b8133f4ad Doc view changes for module publish mapping, publish 10 months ago
venkataakhil 39ea33ca60 changes in variant mapping 10 months ago
venkataakhil 1b884ab2f7 KM Mapping merge fix 10 months ago
venkata akhil 7b9097967f Merge branch 'version2' of http://65.1.227.215:3000/Administrator/smart_service into version2 10 months ago
venkata akhil 8273fdc95a Feature finder child table data to small text field 10 months ago
venkataakhil bb51b2c7db kilometer mapping changes 10 months ago
venkataakhil ab2fb4aa3e publish changes 10 months ago
venkataakhil b64c2b1dd3 publish changes 10 months ago
venkata akhil 0d3053914a kilometer mapping changes 10 months ago
venkata akhil 3d55c6285e Publish Changes 10 months ago
venkataakhil bb4600bece kilometer mapping reload fix 10 months ago
venkataakhil e8dc8467a4 Add saved notification on update of kilometer mapping 11 months ago
venkataakhil 94492e5a46 Hide filters in Kilometer and system mapping 11 months ago
venkataakhil 71c16cbf71 Remove Filters in System mapping and kilometer mapping 11 months ago
venkataakhil 74fe371415 FIlters working 11 months ago
venkataakhil e6e10c5c0a Filter for System Mapping n kilometer mapping 11 months ago
venkataakhil db4f959cb7 Kilometer duplicate fetcg from feature 11 months ago
venkataakhil f39f9526da Publish py update custom language internal/global flag 11 months ago
venkataakhil b8ffb2bf0a Publish API data append based on publish module 11 months ago
venkataakhil a6f833dbe6 Audit report null values fix 11 months ago
venkataakhil e1a51a17dc Remove rename in App Dealer, App Device, App Preference, Custom Languages, Drive, Fuel, Procedure Name, Procedure Step Name, Sub System, System, Transmission, Variant 11 months ago
venkata akhil 5e3d038de4 Table name fix 11 months ago
venkata akhil 7a40e243fa Vehicle master- Publish type validation 11 months ago
venkataakhil caca62111f Check vehicle and all vehicle update fixes 11 months ago
venkataakhil 56c3743d30 Check vehicle update global vehicle check fix 11 months ago
venkataakhil a5a238952c Update validation fixes for all vehicle update 11 months ago
venkata akhil 219064b82d check_all_update release desc 11 months ago
venkataakhil e34a2612fd Check all vehcile update api fix- remove log error 11 months ago
venkataakhil 9fbf7c0792 Check all vehcile update api fix 11 months ago
venkataakhil 201ff26855 Check all vehicle update fix 11 months ago
venkataakhil 260b1ab2c9 check_vehicle_update api update 11 months ago
venkataakhil cf38659136 publish client changes 11 months ago
venkata akhil f4f8b6057c mst html changes 11 months ago
venkata akhil 5aafe41452 step wise bulletpoints-mst 11 months ago
venkata akhil adb7bb7eae mst prework hmtl content 11 months ago
venkata akhil e25cfac609 mst category master 11 months ago
venkata akhil f228502abb validation fixes in mst,qwik service and publish 11 months ago
venkata akhil a2a61f7966 Role mapping fixes 11 months ago
venkata akhil 7123cc49db Publish fix, mst field validation 11 months ago
venkata akhil 95bf6d9a58 MST release 12 months ago
venkata akhil 18db2c99b1 MST file Validation 12 months ago
venkata akhil 952297af9a Fixture export 12 months ago
venkata akhil 10c436323a MST and publish mapping 12 months ago
venkata akhil a956342305 MST n instruictions 12 months ago
venkataakhil b0d435934c MST update 12 months ago
venkata akhil d43123cc87 Field validation in MSTI 12 months ago
venkataakhil 33b925e8f3 File validation for MST 12 months ago
venkataakhil ffa5051eca MST File validation 12 months ago
venkata akhil 4902ccbde2 MST doctype udpates 12 months ago
venkata akhil f5856f9f42 Merge branch 'version2' of http://65.1.227.215:3000/Administrator/smart_service into version2 12 months ago
venkata akhil e226ed4d42 MST Image review and field changes 12 months ago
venkataakhil 5a00f33028 MST tool name update 12 months ago
venkata akhil 0d3602acf0 MST doctype view update n remove field in master v2 api 12 months ago
venkata akhil 93c9bae261 Merge branch 'version2' of http://65.1.227.215:3000/Administrator/smart_service into version2 12 months ago
venkata akhil 509cfa4659 Feature finder fields update 12 months ago
venkataakhil 3ce4842d31 MST key update 12 months ago
venkata akhil 1f0f0ea40f Changes to doctype views 12 months ago
venkata akhil f4d3f4ff60 QWIK changes 1 year ago
venkata akhil 0f4f076d14 MST TEB field depends on condition 1 year ago
venkata akhil f38c446e91 QWIK field udpate 1 year ago
venkataakhil e396a556e3 MST field update 1 year ago
venkata akhil 5038b7fcdd Doc level UI Changes in QWIK and MST 1 year ago
venkataakhil a996a67d4a MSt fixes 1 year ago
venkataakhil 446a0c45a1 publsih remove log errros 1 year ago
venkataakhil db6a174c46 Workspace add qwik and mst 1 year ago
venkataakhil 07d419239b QWIk, MST with publish modules 1 year ago
venkataakhil d2ca624140 Qwik fixes 1 year ago
venkataakhil 08440f378c QWIK and MST tools 1 year ago
venkata akhil b489b10f96 Merge fix 1 year ago
venkata akhil 12614de7b4 QWIK 1 year ago
venkataakhil 22069d2824 modules fix 1 year ago
venkataakhil 4815459bb9 Merge branch 'version2' of http://65.1.227.215:3000/Administrator/smart_service into version2 1 year ago
venkataakhil 9ad2de1fd4 active status filter in search 1 year ago
venkata akhil aaf43feca5 ui fixes 1 year ago
venkataakhil c714cdc369 workspace changes 1 year ago
venkata akhil e23d141c43 UI fixes 1 year ago
venkataakhil d5849db677 UI level fixes, remove active status, SOP name change field 1 year ago
venkataakhil 58ff0d7610 Remove data invalidation 1 year ago
venkataakhil 68c956c001 Hide reference fields 1 year ago
venkataakhil baeede25f3 Publish update and release 1 fix 1 year ago
venkataakhil 360439782e App Labels: empty parent label for is group fie;d 1 year ago
venkataakhil 6317902e9b Variant api add iid in request 1 year ago
venkataakhil 047e35d22e Publish doc child table add 1 year ago
venkataakhil 4ca858d373 Publish route 1 year ago
administrator 2eeaeb82c6 Merge branch 'version2' of http://65.1.227.215:3000/Administrator/smart_service into version2 1 year ago
venkataakhil 023dbedd19 Publish v2 verion and global custom button fix 1 year ago
venkataakhil fbd0c484ca Publish pHase 2 api integration 1 year ago
administrator e0ff72c68d Feature finder content field update to small text 1 year ago
venkataakhil dec5ae4127 Publish version update 1 year ago
venkataakhil 38e81834bd Publish version update 1 year ago
venkata akhil 3d8a2cd351 Fixtures export 1 year ago
venkataakhil 306646aeb5 hooks py export all settings 1 year ago
venkataakhil a5f6b8ae59 Publish modules fields update in modules, new publish integration to old publish 1 year ago
venkataakhil 46df11dec0 Merge conflict 1 year ago
venkataakhil b02fb26d4f Publish 1 year ago
venkataakhil ef64008c0b Role master doc fields update 1 year ago
venkataakhil a1f6cef7c2 Pubish test 1 year ago
venkataakhil 0bacab0173 Publish feature update 1 year ago
venkataakhil 7ebe7d5749 Feature fiinder 1 year ago
venkata akhil 785136553f List view changes 1 year ago
venkata akhil e4d104142f Merge branch 'version2' of http://65.1.227.215:3000/Administrator/smart_service into version2 1 year ago
venkata akhil 1f6c0a4b1e Logo height to 32 px 1 year ago
venkataakhil 8d3acdbfeb Publish new modules data changes 1 year ago
venkataakhil 5b3e58044f remove master api test functions 1 year ago
venkataakhil 3d9acc82fc remove logs and console 1 year ago
venkataakhil 95192293d8 Feature finder, publish update 1 year ago
venkataakhil 35c8357070 feature finder fix 1 year ago
venkataakhil 500a4c4cfb Publish phase2 1 year ago
venkataakhil 014f15ea39 Feature finder custom tab and MST 1 year ago
venkataakhil 357c900d64 Phase Release1 1 year ago
  1. 15
      smart_service/add_ons/doctype/app_dealer/app_dealer.json
  2. 21
      smart_service/add_ons/doctype/app_device/app_device.json
  3. 6
      smart_service/add_ons/doctype/app_preference/app_preference.json
  4. 0
      smart_service/add_ons/doctype/torque_table_column/__init__.py
  5. 8
      smart_service/add_ons/doctype/torque_table_column/test_torque_table_column.py
  6. 8
      smart_service/add_ons/doctype/torque_table_column/torque_table_column.js
  7. 65
      smart_service/add_ons/doctype/torque_table_column/torque_table_column.json
  8. 8
      smart_service/add_ons/doctype/torque_table_column/torque_table_column.py
  9. 0
      smart_service/add_ons/doctype/torque_table_column_child_table/__init__.py
  10. 8
      smart_service/add_ons/doctype/torque_table_column_child_table/test_torque_table_column_child_table.py
  11. 8
      smart_service/add_ons/doctype/torque_table_column_child_table/torque_table_column_child_table.js
  12. 36
      smart_service/add_ons/doctype/torque_table_column_child_table/torque_table_column_child_table.json
  13. 8
      smart_service/add_ons/doctype/torque_table_column_child_table/torque_table_column_child_table.py
  14. 80
      smart_service/add_ons/report/feedback_report/feedback_report.py
  15. 69
      smart_service/add_ons/report/installation_report/installation_report.py
  16. 84
      smart_service/add_ons/report/login_report/login_report.py
  17. 23
      smart_service/add_ons/report/model_download_report/model_download_report.js
  18. 108
      smart_service/add_ons/report/model_download_report/model_download_report.py
  19. 21
      smart_service/add_ons/report/model_hit_report/model_hit_report.js
  20. 243
      smart_service/add_ons/report/model_hit_report/model_hit_report.py
  21. 658246
      smart_service/apis/THAR-en-full_v12.00.json
  22. 3
      smart_service/apis/addon_api.py
  23. 187
      smart_service/apis/app_user_login.py
  24. 439
      smart_service/apis/check_update.py
  25. 176
      smart_service/apis/master_api.py
  26. 152
      smart_service/apis/publish_api.py
  27. 941
      smart_service/apis/update_validation.py
  28. 177
      smart_service/apis/utils.py
  29. 751
      smart_service/apis/v2/master.py
  30. 137
      smart_service/apis/v2/phase2_test_publish.py
  31. 3289
      smart_service/fixtures/custom_docperm.json
  32. 93
      smart_service/fixtures/dashboard_chart.json
  33. 618
      smart_service/fixtures/property_setter.json
  34. 449
      smart_service/fixtures/report.json
  35. 542
      smart_service/fixtures/role.json
  36. 11
      smart_service/fixtures/role_profile.json
  37. 6
      smart_service/fixtures/workflow_action_master.json
  38. 30
      smart_service/fixtures/workflow_state.json
  39. 1847
      smart_service/fixtures/workspace.json
  40. 22
      smart_service/hooks.py
  41. 33
      smart_service/masters/doctype/app_labels/app_labels.js
  42. 7
      smart_service/masters/doctype/app_labels/app_labels.json
  43. 5
      smart_service/masters/doctype/custom_languages/custom_languages.json
  44. 3
      smart_service/masters/doctype/drive/drive.json
  45. 3
      smart_service/masters/doctype/fuel/fuel.json
  46. 0
      smart_service/masters/doctype/module_master/__init__.py
  47. 55
      smart_service/masters/doctype/module_master/module_master.js
  48. 73
      smart_service/masters/doctype/module_master/module_master.json
  49. 21
      smart_service/masters/doctype/module_master/module_master.py
  50. 8
      smart_service/masters/doctype/module_master/test_module_master.py
  51. 4
      smart_service/masters/doctype/procedure_name/procedure_name.json
  52. 4
      smart_service/masters/doctype/procedure_step_name/procedure_step_name.json
  53. 0
      smart_service/masters/doctype/role_master/__init__.py
  54. 122
      smart_service/masters/doctype/role_master/role_master.js
  55. 93
      smart_service/masters/doctype/role_master/role_master.json
  56. 25
      smart_service/masters/doctype/role_master/role_master.py
  57. 8
      smart_service/masters/doctype/role_master/test_role_master.py
  58. 3
      smart_service/masters/doctype/sub_systems/sub_systems.json
  59. 3
      smart_service/masters/doctype/systems/systems.json
  60. 3
      smart_service/masters/doctype/transmission/transmission.json
  61. 6
      smart_service/masters/doctype/variant/variant.json
  62. 82
      smart_service/masters/report/drive_translation/drive_translation.py
  63. 66
      smart_service/masters/report/fuel_translation/fuel_translation.py
  64. 98
      smart_service/masters/report/sub_systems_translation/sub_systems_translation.py
  65. 83
      smart_service/masters/report/systems_translation/systems_translation.py
  66. 82
      smart_service/masters/report/transmission_translation/transmission_translation.py
  67. 66
      smart_service/masters/report/variant_translation/variant_translation.py
  68. 114
      smart_service/masters/report/vehicle_segment_translation/vehicle_segment_translation.py
  69. 82
      smart_service/masters/report/vehicle_translation/vehicle_translation.py
  70. 1
      smart_service/modules.txt
  71. 2
      smart_service/overrides/overrides/override_file.py
  72. 0
      smart_service/phase_2/__init__.py
  73. 0
      smart_service/phase_2/doctype/__init__.py
  74. 0
      smart_service/phase_2/doctype/feature_finder/__init__.py
  75. 1254
      smart_service/phase_2/doctype/feature_finder/feature_finder.js
  76. 233
      smart_service/phase_2/doctype/feature_finder/feature_finder.json
  77. 334
      smart_service/phase_2/doctype/feature_finder/feature_finder.py
  78. 8
      smart_service/phase_2/doctype/feature_finder/test_feature_finder.py
  79. 0
      smart_service/phase_2/doctype/feature_finder_category_master/__init__.py
  80. 29
      smart_service/phase_2/doctype/feature_finder_category_master/feature_finder_category_master.js
  81. 75
      smart_service/phase_2/doctype/feature_finder_category_master/feature_finder_category_master.json
  82. 8
      smart_service/phase_2/doctype/feature_finder_category_master/feature_finder_category_master.py
  83. 8
      smart_service/phase_2/doctype/feature_finder_category_master/test_feature_finder_category_master.py
  84. 0
      smart_service/phase_2/doctype/feature_finder_content/__init__.py
  85. 50
      smart_service/phase_2/doctype/feature_finder_content/feature_finder_content.json
  86. 8
      smart_service/phase_2/doctype/feature_finder_content/feature_finder_content.py
  87. 0
      smart_service/phase_2/doctype/feature_finder_disclaimer/__init__.py
  88. 30
      smart_service/phase_2/doctype/feature_finder_disclaimer/feature_finder_disclaimer.json
  89. 8
      smart_service/phase_2/doctype/feature_finder_disclaimer/feature_finder_disclaimer.py
  90. 0
      smart_service/phase_2/doctype/feature_finder_images/__init__.py
  91. 51
      smart_service/phase_2/doctype/feature_finder_images/feature_finder_images.json
  92. 8
      smart_service/phase_2/doctype/feature_finder_images/feature_finder_images.py
  93. 0
      smart_service/phase_2/doctype/feature_finder_master/__init__.py
  94. 35
      smart_service/phase_2/doctype/feature_finder_master/feature_finder_master.js
  95. 103
      smart_service/phase_2/doctype/feature_finder_master/feature_finder_master.json
  96. 42
      smart_service/phase_2/doctype/feature_finder_master/feature_finder_master.py
  97. 8
      smart_service/phase_2/doctype/feature_finder_master/test_feature_finder_master.py
  98. 0
      smart_service/phase_2/doctype/feature_finder_publish_data/__init__.py
  99. 137
      smart_service/phase_2/doctype/feature_finder_publish_data/feature_finder_publish_data.json
  100. 8
      smart_service/phase_2/doctype/feature_finder_publish_data/feature_finder_publish_data.py

15
smart_service/add_ons/doctype/app_dealer/app_dealer.json

@ -1,6 +1,5 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "D-#####",
"creation": "2021-12-30 09:58:43.222658",
"doctype": "DocType",
@ -17,22 +16,26 @@
{
"fieldname": "dealer_name",
"fieldtype": "Data",
"label": "Dealer Name"
"label": "Dealer Name",
"read_only": 1
},
{
"fieldname": "dealer_code",
"fieldtype": "Data",
"label": "Dealer Code"
"label": "Dealer Code",
"read_only": 1
},
{
"fieldname": "zone",
"fieldtype": "Data",
"label": "Zone"
"label": "Zone",
"read_only": 1
},
{
"fieldname": "area",
"fieldtype": "Data",
"label": "Area"
"label": "Area",
"read_only": 1
},
{
"fieldname": "active_status",
@ -42,7 +45,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-01-28 12:57:33.359666",
"modified": "2023-11-08 14:04:25.384029",
"modified_by": "Administrator",
"module": "Add Ons",
"name": "App Dealer",

21
smart_service/add_ons/doctype/app_device/app_device.json

@ -23,33 +23,39 @@
"fieldtype": "Data",
"in_list_view": 1,
"label": "Device ID",
"read_only": 1,
"reqd": 1
},
{
"fieldname": "last_login",
"fieldtype": "Datetime",
"in_list_view": 1,
"label": "Last Login"
"label": "Last Login",
"read_only": 1
},
{
"fieldname": "last_sync",
"fieldtype": "Datetime",
"label": "Last Sync"
"label": "Last Sync",
"read_only": 1
},
{
"fieldname": "device_type",
"fieldtype": "Data",
"label": "Device Type"
"label": "Device Type",
"read_only": 1
},
{
"fieldname": "os",
"fieldtype": "Data",
"label": "OS"
"label": "OS",
"read_only": 1
},
{
"fieldname": "os_version",
"fieldtype": "Data",
"label": "OS Version"
"label": "OS Version",
"read_only": 1
},
{
"fieldname": "column_break_5",
@ -58,7 +64,8 @@
{
"fieldname": "app_current_version",
"fieldtype": "Data",
"label": "App Current Version"
"label": "App Current Version",
"read_only": 1
},
{
"fieldname": "publish_type",
@ -77,7 +84,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-03-01 12:51:54.027555",
"modified": "2023-11-08 14:05:39.200220",
"modified_by": "Administrator",
"module": "Add Ons",
"name": "App Device",

6
smart_service/add_ons/doctype/app_preference/app_preference.json

@ -25,7 +25,9 @@
{
"fieldname": "application_server_url",
"fieldtype": "Data",
"label": "Application Server URL"
"in_list_view": 1,
"label": "Application Server URL",
"reqd": 1
},
{
"fieldname": "update_server_url",
@ -98,7 +100,7 @@
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2022-07-06 13:59:24.139229",
"modified": "2023-11-08 14:03:45.442889",
"modified_by": "Administrator",
"module": "Add Ons",
"name": "App Preference",

0
smart_service/add_ons/doctype/torque_table_column/__init__.py

8
smart_service/add_ons/doctype/torque_table_column/test_torque_table_column.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and Contributors
# See license.txt
# import frappe
import unittest
class TestTorqueTableColumn(unittest.TestCase):
pass

8
smart_service/add_ons/doctype/torque_table_column/torque_table_column.js

@ -0,0 +1,8 @@
// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
// For license information, please see license.txt
frappe.ui.form.on('Torque Table Column', {
// refresh: function(frm) {
// }
});

65
smart_service/add_ons/doctype/torque_table_column/torque_table_column.json

@ -0,0 +1,65 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-12-08 14:40:14.464142",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"variant",
"vehicle",
"section_break_bytf4",
"torque_table_columns"
],
"fields": [
{
"fieldname": "torque_table_columns",
"fieldtype": "Table",
"label": "Torque Table Columns",
"options": "Torque Table Column Child Table"
},
{
"fieldname": "variant",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Variant",
"options": "Variant Mapping",
"reqd": 1
},
{
"fetch_from": "variant.vehicle",
"fieldname": "vehicle",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Vehicle",
"reqd": 1
},
{
"fieldname": "section_break_bytf4",
"fieldtype": "Section Break"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-08 14:53:30.505533",
"modified_by": "Administrator",
"module": "Add Ons",
"name": "Torque Table Column",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC"
}

8
smart_service/add_ons/doctype/torque_table_column/torque_table_column.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
# import frappe
from frappe.model.document import Document
class TorqueTableColumn(Document):
pass

0
smart_service/add_ons/doctype/torque_table_column_child_table/__init__.py

8
smart_service/add_ons/doctype/torque_table_column_child_table/test_torque_table_column_child_table.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and Contributors
# See license.txt
# import frappe
import unittest
class TestTorqueTableColumnChildTable(unittest.TestCase):
pass

8
smart_service/add_ons/doctype/torque_table_column_child_table/torque_table_column_child_table.js

@ -0,0 +1,8 @@
// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
// For license information, please see license.txt
frappe.ui.form.on('Torque Table Column Child Table', {
// refresh: function(frm) {
// }
});

36
smart_service/add_ons/doctype/torque_table_column_child_table/torque_table_column_child_table.json

@ -0,0 +1,36 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-12-08 14:39:31.936009",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"column_number",
"column_name"
],
"fields": [
{
"fieldname": "column_number",
"fieldtype": "Data",
"label": "Column Number"
},
{
"fieldname": "column_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Column Name"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-12-08 14:48:55.346403",
"modified_by": "Administrator",
"module": "Add Ons",
"name": "Torque Table Column Child Table",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}

8
smart_service/add_ons/doctype/torque_table_column_child_table/torque_table_column_child_table.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
# import frappe
from frappe.model.document import Document
class TorqueTableColumnChildTable(Document):
pass

80
smart_service/add_ons/report/feedback_report/feedback_report.py

@ -3,47 +3,61 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe import msgprint, _
import sys
sys.tracebacklimit=0
sys.tracebacklimit = 0
def execute(filters=None):
columns, data = [], []
columns = get_columns()
data = get_data(filters)
return columns, data
columns, data = [], []
columns = get_columns()
data = get_data(filters)
return columns, data
def get_data(filters):
current_db_name = frappe.conf.get("db_name")
data = frappe.db.sql("""select uf.name,uf.date,uf.subject,uf.user_name,uf.status,uf.attachments,uf.closure_date,uf.closed_by,
current_db_name = frappe.conf.get("db_name")
data = frappe.db.sql("""select uf.name,uf.date,uf.subject,uf.user_name,uf.status,uf.attachments,uf.closure_date,uf.closed_by,
uf.description,uf.feedback_type,dealer.dealer_code,dealer.zone,dealer.dealer_name,uf.closure_date,uf.closed_by,
dealer.area,au.user_id,concat_ws(' ',au.first_name,au.last_name) as user_name from {0}.`tabUser Feedback` uf,{0}.`tabApp Dealer` dealer,{0}.`tabApp Users` au
where uf.user_name = au.name and
(date(uf.modified) between '{1}' and '{2}') group by uf.name""".format(current_db_name,filters.get('from_date'), filters.get('to_date')), as_dict=1)
if data:
return data
else:
frappe.msgprint('No Data for Selected Filters.')
def get_columns():
columns = [
{"label": _("<b>Date</b>"), "fieldname": "date", "fieldtype": "Date", "width": 100},
{"label": _("<b>Feedback ID</b>"), "fieldname": "name", "fieldtype": "Link", "options":"User Feedback","width": 120},
{"label": _("<b>Feedback Type</b>"), "fieldname": "feedback_type", "fieldtype": "Data", "width": 120},
{"label": _("<b>Feedback Title</b>"), "fieldname": "subject", "fieldtype": "Data", "width": 120},
{"label": _("<b>Feedback Description</b>"), "fieldname": "description", "fieldtype": "Text Editor", "width": 250},
{"label": _("<b>Attachments</b>"), "fieldname": "attachments", "fieldtype": "Data", "width": 100},
{"label": _("<b>Feedback Status</b>"), "fieldname": "status", "fieldtype": "Data", "width": 100},
{"label": _("<b>User ID</b>"), "fieldname": "user_id", "fieldtype":"Data","width": 100},
{"label": _("<b>User Name</b>"), "fieldname": "user_name", "fieldtype": "Data", "width": 150},
{"label": _("<b>Zone</b>"), "fieldname": "zone", "fieldtype": "Data", "width": 100},
{"label": _("<b>Area Office</b>"), "fieldname": "area", "fieldtype": "Data", "width": 140},
{"label": _("<b>Dealer Code</b>"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 120},
{"label": _("<b>Dealer Name</b>"), "fieldname": "dealer_name", "fieldtype": "Data", "width": 150},
{"label": _("<b>Closure Date</b>"), "fieldname": "closure_date", "fieldtype": "Data", "width": 150},
{"label": _("<b>Closed By</b>"), "fieldname": "closed_by", "fieldtype": "Data", "width": 120}
(date(uf.modified) between '{1}' and '{2}') group by uf.name ORDER BY uf.date DESC""".format(current_db_name, filters.get('from_date'), filters.get('to_date')), as_dict=1)
if data:
return data
else:
frappe.msgprint('No Data for Selected Filters.')
]
return columns
def get_columns():
columns = [
{"label": _("<b>User ID</b>"), "fieldname": "user_id",
"fieldtype": "Data", "width": 100},
{"label": _("<b>User Name</b>"), "fieldname": "user_name",
"fieldtype": "Data", "width": 150},
{"label": _("<b>Date</b>"), "fieldname": "date",
"fieldtype": "Date", "width": 100},
{"label": _("<b>Feedback ID</b>"), "fieldname": "name",
"fieldtype": "Link", "options": "User Feedback", "width": 120},
{"label": _("<b>Feedback Type</b>"), "fieldname": "feedback_type",
"fieldtype": "Data", "width": 120},
{"label": _("<b>Feedback Title</b>"), "fieldname": "subject",
"fieldtype": "Data", "width": 120},
{"label": _("<b>Feedback Description</b>"), "fieldname": "description",
"fieldtype": "Text Editor", "width": 250},
{"label": _("<b>Attachments</b>"), "fieldname": "attachments",
"fieldtype": "Data", "width": 100},
{"label": _("<b>Feedback Status</b>"), "fieldname": "status",
"fieldtype": "Data", "width": 100},
{"label": _("<b>Zone</b>"), "fieldname": "zone",
"fieldtype": "Data", "width": 100},
{"label": _("<b>Area Office</b>"), "fieldname": "area",
"fieldtype": "Data", "width": 140},
{"label": _("<b>Dealer Code</b>"), "fieldname": "dealer_code",
"fieldtype": "Data", "width": 120},
{"label": _("<b>Dealer Name</b>"), "fieldname": "dealer_name",
"fieldtype": "Data", "width": 150},
{"label": _("<b>Closure Date</b>"), "fieldname": "closure_date",
"fieldtype": "Data", "width": 150},
{"label": _("<b>Closed By</b>"), "fieldname": "closed_by",
"fieldtype": "Data", "width": 120}
]
return columns

69
smart_service/add_ons/report/installation_report/installation_report.py

@ -5,47 +5,54 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe import msgprint, _
def execute(filters=None):
columns, data = [], []
columns = get_columns()
data = get_data(filters)
return columns, data
columns, data = [], []
columns = get_columns()
data = get_data(filters)
return columns, data
def get_data(filters):
current_db_name = frappe.conf.get("db_name")
data = frappe.db.sql("""select dealer.zone,au.user_id,concat_ws(' ',au.first_name,au.last_name) as user_name,dealer.dealer_code,dealer.dealer_name,dealer.area,ad.os,ad.os_version,
current_db_name = frappe.conf.get("db_name")
data = frappe.db.sql("""select dealer.zone,au.user_id,concat_ws(' ',au.first_name,au.last_name) as user_name,dealer.dealer_code,dealer.dealer_name,dealer.area,ad.os,ad.os_version,
al.device,ad.device_id,ad.app_current_version,al.type as type,ad.device_type,al.date_time_stamp,al.creation,ad.last_login as date,al.date_time_stamp as time,time(al.date_time_stamp) as last_time
from {0}.`tabApp Log` al, {0}.`tabApp Device` ad, {0}.`tabApp Users` au, {0}.`tabApp Dealer` dealer
where
al.device = ad.name and al.user = au.name and au.dealer = dealer.name and (al.type = 'Installed' or al.type = 'Reinstalled') and
(date(al.modified) between '{1}' and '{2}')""".format(current_db_name,filters.get('from_date'), filters.get('to_date')), as_dict=1)
(date(al.modified) between '{1}' and '{2}') ORDER BY ad.last_login DESC""".format(current_db_name, filters.get('from_date'), filters.get('to_date')), as_dict=1)
if data:
return data
else:
frappe.msgprint('No Data for Selected Filters.')
if data:
return data
else:
frappe.msgprint('No Data for Selected Filters.')
def get_columns():
columns = [
{"label": _("<b>Zone</b>"), "fieldname": "zone", "fieldtype": "Data", "width": 100},
{"label": _("<b>Area Office</b>"), "fieldname": "area", "fieldtype":"Data","width": 150},
{"label": _("<b>Dealer Code</b>"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 100},
{"label": _("<b>Dealer Name</b>"), "fieldname": "dealer_name", "fieldtype":"Data","width": 150},
{"label": _("<b>Installation</b>"), "fieldname": "device", "fieldtype": "Data","width": 100},
{"label": _("<b>Device</b>"), "fieldname": "device_type", "fieldtype": "Data","width": 100},
{"label": _("<b>Device ID</b>"), "fieldname": "device_id", "fieldtype": "Data", "width": 100},
{"label": _("<b>Device OS</b>"), "fieldname": "os", "fieldtype": "Data", "width": 100},
{"label": _("<b>OS Version</b>"), "fieldname": "os_version", "fieldtype": "Data", "width": 100},
{"label": _("<b>User ID</b>"), "fieldname": "user_id", "fieldtype": "Data", "width": 100},
{"label": _("<b>User Name</b>"), "fieldname": "user_name", "fieldtype": "Data", "width": 100},
{"label": _("<b>Activity Type</b>"), "fieldname": "type", "fieldtype": "Data","width": 100},
{"label": _("<b>App Installation Date</b>"), "fieldname": "date_time_stamp", "fieldtype": "DateTime","width": 200},
{"label": _("<b>App Last Accessed Date</b>"), "fieldname": "date", "fieldtype": "DateTime","width": 200},
{"label": _("<b>App Version No</b>"), "fieldname": "app_current_version", "fieldtype": "Data", "width": 150},
]
return columns
columns = [
{"label": _("<b>User ID</b>"), "fieldname": "user_id",
"fieldtype": "Data", "width": 100},
{"label": _("<b>User Name</b>"), "fieldname": "user_name",
"fieldtype": "Data", "width": 150},
{"label": _("<b>Installation</b>"), "fieldname": "device",
"fieldtype": "Data", "width": 100},
{"label": _("<b>App Version No</b>"), "fieldname": "app_current_version",
"fieldtype": "Data", "width": 150},
{"label": _("<b>Activity Type</b>"), "fieldname": "type",
"fieldtype": "Data", "width": 150},
{"label": _("<b>Device</b>"), "fieldname": "device_type",
"fieldtype": "Data", "width": 100},
{"label": _("<b>Device ID</b>"), "fieldname": "device_id",
"fieldtype": "Data", "width": 150},
{"label": _("<b>Device OS</b>"), "fieldname": "os",
"fieldtype": "Data", "width": 100},
{"label": _("<b>OS Version</b>"), "fieldname": "os_version",
"fieldtype": "Data", "width": 100},
{"label": _("<b>App Installation Date</b>"),
"fieldname": "date_time_stamp", "fieldtype": "DateTime", "width": 200},
{"label": _("<b>App Last Accessed Date</b>"),
"fieldname": "date", "fieldtype": "DateTime", "width": 200}
]
return columns

84
smart_service/add_ons/report/login_report/login_report.py

@ -3,64 +3,58 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe import msgprint, _
from frappe.utils import cstr, flt, cint,TIME_FORMAT,DATE_FORMAT,DATETIME_FORMAT, now_datetime
from datetime import date, time, datetime, timedelta
from frappe.utils import now
import datetime
def execute(filters=None):
columns, data = [], []
columns = get_columns()
data = get_data(filters)
return columns, data
columns, data = [], []
columns = get_columns()
data = get_data(filters)
return columns, data
def get_data(filters):
current_db_name = frappe.conf.get("db_name")
from_date = filters.get('from_date')
to_date = filters.get('to_date')
data_test = frappe.db.sql("""select count(al.name) as count,dealer.zone,au.user_id,concat_ws(' ',au.first_name,au.last_name) as user_name,
dealer.dealer_code,dealer.dealer_name,dealer.area,ad.os,ad.os_version,
ad.device_type,ad.device_id,ad.app_current_version,al.type,al.latitude,al.longitude,al.date_time_stamp,al.creation,
date(al.date_time_stamp) as date,time(ad.last_login) as time
from {0}.`tabApp Log` al,{0}.`tabApp Device` ad,{0}.`tabApp Users` au,{0}.`tabApp Dealer` dealer
where
al.device = ad.name and al.user = au.name and au.dealer = dealer.name and al.type = 'Logged in' and
(date(al.modified) between '{1}' and '{2}') group by al.user,ad.device_id,date(al.date_time_stamp)""".format(current_db_name,from_date,to_date), as_dict=1)
def get_data(filters):
current_db_name = frappe.conf.get("db_name")
from_date = filters.get('from_date')
to_date = filters.get('to_date')
data = frappe.db.sql("""select dealer.zone,au.user_id,concat_ws(' ',au.first_name,au.last_name) as user_name,
data = frappe.db.sql("""select dealer.zone,au.user_id,concat_ws(' ',au.first_name,au.last_name) as user_name,
dealer.dealer_code,dealer.dealer_name,dealer.area,ad.os,ad.os_version,
ad.device_type,ad.device_id,ad.app_current_version,al.type,date(al.date_time_stamp) as date,
al.latitude, al.longitude, au.name, al.device, time(al.date_time_stamp) as last_login_time, mal.count from {current_db_name}.`tabApp Log` al,{current_db_name}.`tabApp Device` ad, {current_db_name}.`tabApp Users` au,{current_db_name}.`tabApp Dealer` dealer,
al.latitude, al.longitude, au.name, al.device, time(al.date_time_stamp) as last_login_time, mal.count from {current_db_name}.`tabApp Log` al,
{current_db_name}.`tabApp Device` ad, {current_db_name}.`tabApp Users` au,{current_db_name}.`tabApp Dealer` dealer,
(select user,Max(date_time_stamp) as date_time_stam, count(date(date_time_stamp)) as count from {current_db_name}.`tabApp Log`
where date(date_time_stamp) between '{from_date}' and '{to_date}' group by user,date(date_time_stamp)) mal
where mal.user=al.user
and mal.user=au.name
and au.dealer = dealer.name
and al.device = ad.name
and mal.date_time_stam=al.date_time_stamp; """.format(current_db_name = current_db_name,from_date= from_date,to_date=to_date), as_dict=1)
if data:
return data
else:
frappe.msgprint('No Data for Selected Filters.')
and mal.date_time_stam=al.date_time_stamp ORDER BY date DESC; """.format(current_db_name=current_db_name, from_date=from_date, to_date=to_date), as_dict=1)
if data:
return data
else:
frappe.msgprint('No Data for Selected Filters.')
def get_columns():
columns = [
{"label": _("<b>Date</b>"), "fieldname": "date", "fieldtype": "Date", "width": 100},
{"label": _("<b>Time</b>"), "fieldname": "last_login_time", "fieldtype": "DateTime", "width": 130},
{"label": _("<b>Zone</b>"), "fieldname": "zone", "fieldtype": "Data", "width": 100},
{"label": _("<b>Area Office</b>"), "fieldname": "area", "fieldtype": "Data", "width": 100},
{"label": _("<b>Dealer Code</b>"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 150},
{"label": _("<b>Dealer Name</b>"), "fieldname": "dealer_name", "fieldtype":"Data","width": 150},
{"label": _("<b>Device</b>"), "fieldname": "device_type", "fieldtype": "Data", "width": 100},
{"label": _("<b>Device ID</b>"), "fieldname": "device_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>User ID</b>"), "fieldname": "user_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>User Name</b>"), "fieldname": "user_name", "fieldtype": "Data", "width": 100},
{"label": _("<b>Latitude</b>"), "fieldname": "latitude", "fieldtype": "Data", "width": 100},
{"label": _("<b>Longitude</b>"), "fieldname": "longitude", "fieldtype": "Data", "width": 100},
{"label": _("<b>Count</b>"), "fieldname": "count", "fieldtype": "Data", "width": 100},
]
return columns
def get_columns():
columns = [
{"label": _("<b>User ID</b>"), "fieldname": "user_id",
"fieldtype": "Data", "width": 150},
{"label": _("<b>User Name</b>"), "fieldname": "user_name",
"fieldtype": "Data", "width": 150},
{"label": _("<b>Date</b>"), "fieldname": "date",
"fieldtype": "Date", "width": 100},
{"label": _("<b>Time</b>"), "fieldname": "last_login_time",
"fieldtype": "DateTime", "width": 130},
{"label": _("<b>Count</b>"), "fieldname": "count",
"fieldtype": "Data", "width": 100},
{"label": _("<b>Device ID</b>"), "fieldname": "device_id",
"fieldtype": "Data", "width": 100},
{"label": _("<b>Device</b>"), "fieldname": "device_type",
"fieldtype": "Data", "width": 130},
{"label": _("<b>Latitude</b>"), "fieldname": "latitude",
"fieldtype": "Data", "width": 100},
{"label": _("<b>Longitude</b>"), "fieldname": "longitude",
"fieldtype": "Data", "width": 100}
]
return columns

23
smart_service/add_ons/report/model_download_report/model_download_report.js

@ -24,8 +24,27 @@ frappe.query_reports["Model Download Report"] = {
"label": __("Model"),
"fieldtype": "Link",
"options" : "Vehicle",
"reqd": 0
"reqd": 0,
"on_change":function() {
model = frappe.query_report.get_filter_value('model');
if (!model) {
setTimeout(function mysam(){
$('.msg-box').empty()
$('.msg-box').append('<div><img src="/assets/frappe/images/ui-states/list-empty-state.svg" alt="Generic Empty State" class="null-state"></div><p>Please Enter the Model</p>')
},200)
}
frappe.query_report.refresh();
}
}
]
],
"onload":function(){
setTimeout(function mysam(){
$('.msg-box').empty()
$('.msg-box').append('<div><img src="/assets/frappe/images/ui-states/list-empty-state.svg" alt="Generic Empty State" class="null-state"></div><p>Please Enter the Model</p>')
},400)
}
};

108
smart_service/add_ons/report/model_download_report/model_download_report.py

@ -3,65 +3,79 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe import msgprint, _
import datetime
current_db_name = frappe.conf.get("db_name")
def execute(filters=None):
columns, data = [], []
columns = get_columns()
data = get_data(filters)
return columns, data
columns, data = [], []
columns = get_columns()
data = get_data(filters)
return columns, data
def get_data(filters):
if filters.get('model'):
from_date=filters['from_date']
to_date=filters['to_date']
modelfilter=filters['model']
if filters.get('model'):
from_date = filters['from_date']
to_date = filters['to_date']
modelfilter = filters['model']
data = frappe.db.sql("""SELECT date(date) as date, device_id, device_type, app_version, download_vehicle_id, download_vehicle_version,
download_vehicle_date, download_vehicle_language_id, download_vehicle_current_version, user_id
FROM {0}.`tabModel Hit` WHERE download_vehicle_id='{1}' and (date(date) between '{2}' and '{3}') order by download_vehicle_id;""".format(current_db_name,
modelfilter, from_date, to_date), as_dict=1)
data = frappe.db.sql("""SELECT date(date) as date, device_id, device_type, app_version, download_vehicle_id, download_vehicle_version,
download_vehicle_date, download_vehicle_language_id, download_vehicle_current_version, mh.user_id,
login_name,concat(first_name,' ',last_name) as user_name
FROM `tabModel Hit` mh
left join `tabApp Users` au on mh.user_id = au.user_id
WHERE download_vehicle_id='{1}' and (date(date) between '{2}' and '{3}') ORDER BY download_vehicle_id,date DESC;""".format(current_db_name,
modelfilter, from_date, to_date), as_dict=1)
for d in data:
d['download_vehicle_id']=modelfilter
if d['user_id']:
try:
dealer_info=frappe.db.sql("""SELECT dealer FROM {0}.`tabApp Users` where user_id='{1}';""".format(current_db_name, d['user_id']), as_dict=1)
dealer_info=dealer_info[-1]['dealer']
dealer_details=frappe.db.sql("""SELECT dealer_name,dealer_code,area as location,zone FROM {0}.`tabApp Dealer`
for d in data:
d['download_vehicle_id'] = modelfilter
if d['user_id']:
try:
dealer_info = frappe.db.sql("""SELECT dealer FROM {0}.`tabApp Users` where user_id='{1}';""".format(
current_db_name, d['user_id']), as_dict=1)
dealer_info = dealer_info[-1]['dealer']
dealer_details = frappe.db.sql("""SELECT dealer_name,dealer_code,area as location,zone FROM {0}.`tabApp Dealer`
where name='{1}';""".format(current_db_name, dealer_info), as_dict=1)
dealer_details=dealer_details[-1]
d['dealer_code']=dealer_details['dealer_code']
d['dealer_name']=dealer_details['dealer_name']
d['area']=dealer_details['location']
d['zone']=dealer_details['zone']
except:
pass
if data:
return data
else:
frappe.msgprint('No Data for Selected Filters.')
dealer_details = dealer_details[-1]
d['dealer_code'] = dealer_details['dealer_code']
d['dealer_name'] = dealer_details['dealer_name']
d['area'] = dealer_details['location']
d['zone'] = dealer_details['zone']
except:
pass
if data:
return data
else:
frappe.msgprint('No Data for Selected Filters.')
def get_columns():
columns = [
{"label": _("<b>Date</b>"), "fieldname": "date", "fieldtype": "Date", "width": 100},
{"label": _("<b>Downloaded Vehicle</b>"), "fieldname": "download_vehicle_id", "fieldtype": "Data", "width": 170},
{"label": _("<b>Downloaded Version</b>"), "fieldname": "download_vehicle_current_version", "fieldtype": "Data", "width": 150},
{"label": _("<b>Downloaded Language</b>"), "fieldname": "download_vehicle_language_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>App Version</b>"), "fieldname": "app_version", "fieldtype": "Data", "width": 150},
{"label": _("<b>Zone</b>"), "fieldname": "zone", "fieldtype": "Data", "width": 100},
{"label": _("<b>Area Office</b>"), "fieldname": "area", "fieldtype": "Data", "width": 150},
{"label": _("<b>Dealer Code</b>"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 150},
{"label": _("<b>Dealer Name</b>"), "fieldname": "dealer_name", "fieldtype": "Data", "width": 150},
{"label": _("<b>Device</b>"), "fieldname": "device_id", "fieldtype": "Data", "width": 100},
{"label": _("<b>Device Type</b>"), "fieldname": "device_type", "fieldtype": "Data", "width": 130}
columns = [
{"label": _("<b>Date</b>"), "fieldname": "date",
"fieldtype": "Date", "width": 150},
{"label": _("<b>User ID</b>"), "fieldname": "login_name",
"fieldtype": "Data", "width": 125},
{"label": _("<b>User Name</b>"), "fieldname": "user_name",
"fieldtype": "Data", "width": 125},
{"label": _("<b>Downloaded Vehicle</b>"),
"fieldname": "download_vehicle_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Downloaded Language</b>"),
"fieldname": "download_vehicle_language_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Downloaded Version</b>"),
"fieldname": "download_vehicle_current_version", "fieldtype": "Data", "width": 150},
{"label": _("<b>App Version</b>"), "fieldname": "app_version",
"fieldtype": "Data", "width": 150},
# {"label": _("<b>Zone</b>"), "fieldname": "zone", "fieldtype": "Data", "width": 100},
# {"label": _("<b>Area Office</b>"), "fieldname": "area", "fieldtype": "Data", "width": 150},
# {"label": _("<b>Dealer Code</b>"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 150},
# {"label": _("<b>Dealer Name</b>"), "fieldname": "dealer_name", "fieldtype": "Data", "width": 150},
{"label": _("<b>Device</b>"), "fieldname": "device_id",
"fieldtype": "Data", "width": 150},
{"label": _("<b>Device Type</b>"), "fieldname": "device_type",
"fieldtype": "Data", "width": 150}
]
return columns
]
return columns

21
smart_service/add_ons/report/model_hit_report/model_hit_report.js

@ -24,7 +24,18 @@ frappe.query_reports["Model Hit Report"] = {
"label": __("Model"),
"fieldtype": "Link",
"options" : "Vehicle",
"reqd": 0
"reqd": 0,
"on_change":function() {
model = frappe.query_report.get_filter_value('model');
if (!model) {
setTimeout(function mysam(){
$('.msg-box').empty()
$('.msg-box').append('<div><img src="/assets/frappe/images/ui-states/list-empty-state.svg" alt="Generic Empty State" class="null-state"></div><p>Please Enter the Model</p>')
},200)
}
frappe.query_report.refresh();
}
},
{
"fieldname":"variant",
@ -44,6 +55,14 @@ frappe.query_reports["Model Hit Report"] = {
}
],
"onload":function(){
setTimeout(function mysam(){
$('.msg-box').empty()
$('.msg-box').append('<div><img src="/assets/frappe/images/ui-states/list-empty-state.svg" alt="Generic Empty State" class="null-state"></div><p>Please Enter the Model</p>')
},400)
},
"formatter": function (value, row, column, data, default_formatter) {

243
smart_service/add_ons/report/model_hit_report/model_hit_report.py

@ -4,142 +4,167 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe import msgprint, _
import datetime
current_db_name = frappe.conf.get("db_name")
def execute(filters=None):
columns, data = [], []
columns = get_columns()
data = get_data(filters)
return columns, data
columns, data = [], []
columns = get_columns()
data = get_data(filters)
return columns, data
def get_data(filters):
if filters.get('variant') and filters.get('model'):
from_date=filters['from_date']
to_date=filters['to_date']
modelfilter=filters['model']
variantfilter=filters['variant']
variantfilter=variantfilter.split(".")
data = frappe.db.sql("""SELECT date as date, device_id, device_type, module_id, vehicle_id, variant_id,variant_mapping_id, system_id, sub_system_id, procedure_id, steps_id,
if filters.get('variant') and filters.get('model'):
from_date = filters['from_date']
to_date = filters['to_date']
modelfilter = filters['model']
variantfilter = filters['variant']
variantfilter = variantfilter.split(".")
data = frappe.db.sql("""SELECT date as date, device_id, device_type, module_id, vehicle_id, variant_id,variant_mapping_id, system_id, sub_system_id, procedure_id, steps_id,
count(*) as count, user_id, language FROM {0}.`tabModel Usage` WHERE vehicle_id='{1}' and variant_id='{2}' and (date(date) between '{3}' and '{4}')
GROUP BY date(date), user_id, module_id, device_id, vehicle_id, variant_id, variant_mapping_id, system_id, sub_system_id, procedure_id, steps_id,
language
order by module_id,vehicle_id, variant_id, variant_mapping_id, system_id, sub_system_id, procedure_id, steps_id,language;
order by module_id,vehicle_id, variant_id, variant_mapping_id, system_id, sub_system_id, procedure_id, steps_id,language,date DESC;
""".format(current_db_name, modelfilter, variantfilter[1], from_date, to_date), as_dict=1)
for d in data:
if d['user_id']:
try:
dealer_info=frappe.db.sql("""SELECT dealer FROM {0}.`tabApp Users` where user_id='{1}';""".format(current_db_name, d['user_id']), as_dict=1)
dealer_info=dealer_info[-1]['dealer']
dealer_details=frappe.db.sql("""SELECT dealer_name,dealer_code,area as location,zone FROM {0}.`tabApp Dealer` where name='{1}';""".format(current_db_name, dealer_info), as_dict=1)
dealer_details=dealer_details[-1]
d['dealer_code']=dealer_details['dealer_code']
d['dealer_name']=dealer_details['dealer_name']
d['area']=dealer_details['location']
d['zone']=dealer_details['zone']
except:
pass
if data:
return data
else:
frappe.msgprint('No Data for Selected Filters.')
elif filters.get('model'):
from_date=filters['from_date']
to_date=filters['to_date']
modelfilter=filters['model']
data = frappe.db.sql("""SELECT date(date) as date, device_id, device_type, module_id, vehicle_id, variant_id,variant_mapping_id, system_id, sub_system_id, procedure_id,
for d in data:
if d['user_id']:
try:
dealer_info = frappe.db.sql("""SELECT dealer FROM {0}.`tabApp Users` where user_id='{1}';""".format(
current_db_name, d['user_id']), as_dict=1)
dealer_info = dealer_info[-1]['dealer']
dealer_details = frappe.db.sql("""SELECT dealer_name,dealer_code,area as location,zone FROM {0}.`tabApp Dealer` where name='{1}';""".format(
current_db_name, dealer_info), as_dict=1)
dealer_details = dealer_details[-1]
d['dealer_code'] = dealer_details['dealer_code']
d['dealer_name'] = dealer_details['dealer_name']
d['area'] = dealer_details['location']
d['zone'] = dealer_details['zone']
except:
pass
if data:
return data
else:
frappe.msgprint('No Data for Selected Filters.')
elif filters.get('model'):
from_date = filters['from_date']
to_date = filters['to_date']
modelfilter = filters['model']
data = frappe.db.sql("""SELECT date(date) as date, device_id, device_type, module_id, vehicle_id, variant_id,variant_mapping_id, system_id, sub_system_id, procedure_id,
steps_id, count(*) as count, user_id, language FROM {0}.`tabModel Usage` WHERE vehicle_id='{1}' and (date(date) between '{2}' and '{3}')
GROUP BY date(date), user_id, module_id, device_id, vehicle_id, variant_id, variant_mapping_id, system_id, sub_system_id, procedure_id, steps_id,language
order by module_id,vehicle_id, variant_id, variant_mapping_id, system_id, sub_system_id, procedure_id, steps_id,language;
;""".format(current_db_name, modelfilter, from_date, to_date), as_dict=1)
for d in data:
if d['user_id']:
try:
dealer_info=frappe.db.sql("""SELECT dealer FROM {0}.`tabApp Users` where user_id='{1}';""".format(current_db_name, d['user_id']), as_dict=1)
dealer_info=dealer_info[-1]['dealer']
dealer_details=frappe.db.sql("""SELECT dealer_name,dealer_code,area as location,zone FROM {0}.`tabApp Dealer` where name='{1}';""".format(current_db_name, dealer_info), as_dict=1)
dealer_details=dealer_details[-1]
d['dealer_code']=dealer_details['dealer_code']
d['dealer_name']=dealer_details['dealer_name']
d['area']=dealer_details['location']
d['zone']=dealer_details['zone']
except:
pass
if data:
return data
else:
frappe.msgprint('No Data for Selected Filters.')
elif filters.get('variant'):
from_date=filters['from_date']
to_date=filters['to_date']
variantfilter=filters['variant']
variantfilter=variantfilter.split(".")
data = frappe.db.sql("""SELECT date as date, device_id, device_type, module_id, vehicle_id, variant_id,variant_mapping_id, system_id, sub_system_id,
procedure_id, steps_id, count(*) as count, user_id, language FROM {0}.`tabModel Usage` WHERE vehicle_id='{1}' and variant_id='{2}'
for d in data:
if d['user_id']:
try:
dealer_info = frappe.db.sql("""SELECT dealer FROM {0}.`tabApp Users` where user_id='{1}';""".format(
current_db_name, d['user_id']), as_dict=1)
dealer_info = dealer_info[-1]['dealer']
dealer_details = frappe.db.sql("""SELECT dealer_name,dealer_code,area as location,zone FROM {0}.`tabApp Dealer` where name='{1}';""".format(
current_db_name, dealer_info), as_dict=1)
dealer_details = dealer_details[-1]
d['dealer_code'] = dealer_details['dealer_code']
d['dealer_name'] = dealer_details['dealer_name']
d['area'] = dealer_details['location']
d['zone'] = dealer_details['zone']
except:
pass
if data:
return data
else:
frappe.msgprint('No Data for Selected Filters.')
elif filters.get('variant'):
from_date = filters['from_date']
to_date = filters['to_date']
variantfilter = filters['variant']
variantfilter = variantfilter.split(".")
data = frappe.db.sql("""SELECT date as date, device_id, device_type, module_id, vehicle_id, variant_id,variant_mapping_id, system_id, sub_system_id,
procedure_id, steps_id, count(*) as count, user_id, language,
login_name,concat(first_name,' ',last_name) as user_name
FROM `tabModel Usage` mu left join `tabApp Users` au on mu.user_id = au.user_id
WHERE vehicle_id='{1}' and variant_id='{2}'
and (date(date) between '{3}' and '{4}') GROUP BY date(date), user_id, module_id, device_id, vehicle_id, variant_id, variant_mapping_id,
system_id, sub_system_id, procedure_id, steps_id, language
order by module_id,vehicle_id, variant_id, variant_mapping_id, system_id, sub_system_id, procedure_id, steps_id,language;
;""".format(current_db_name, variantfilter[0], variantfilter[1], from_date, to_date), as_dict=1)
for d in data:
if d['user_id']:
try:
dealer_info=frappe.db.sql("""SELECT dealer FROM {0}.`tabApp Users` where user_id='{1}';""".format(current_db_name, d['user_id']), as_dict=1)
dealer_info=dealer_info[-1]['dealer']
dealer_details=frappe.db.sql("""SELECT dealer_name,dealer_code,area as location,zone FROM {0}.`tabApp Dealer` where name='{1}';""".format(current_db_name, dealer_info), as_dict=1)
dealer_details=dealer_details[-1]
d['dealer_code']=dealer_details['dealer_code']
d['dealer_name']=dealer_details['dealer_name']
d['area']=dealer_details['location']
d['zone']=dealer_details['zone']
except:
pass
if data:
return data
else:
frappe.msgprint('No Data for Selected Filters.')
for d in data:
if d['user_id']:
try:
dealer_info = frappe.db.sql("""SELECT dealer FROM {0}.`tabApp Users` where user_id='{1}';""".format(
current_db_name, d['user_id']), as_dict=1)
dealer_info = dealer_info[-1]['dealer']
dealer_details = frappe.db.sql("""SELECT dealer_name,dealer_code,area as location,zone FROM {0}.`tabApp Dealer`
where name='{1}';""".format(current_db_name, dealer_info), as_dict=1)
dealer_details = dealer_details[-1]
d['dealer_code'] = dealer_details['dealer_code']
d['dealer_name'] = dealer_details['dealer_name']
d['area'] = dealer_details['location']
d['zone'] = dealer_details['zone']
except:
pass
if data:
return data
else:
frappe.msgprint('No Data for Selected Filters.')
def get_columns():
columns = [
{"label": _("<b>Date</b>"), "fieldname": "date", "fieldtype": "Date", "width": 150},
{"label": _("<b>Module</b>"), "fieldname": "module_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Model</b>"), "fieldname": "vehicle_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Variant Mapping</b>"), "fieldname": "variant_mapping_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Variant</b>"), "fieldname": "variant_id", "fieldtype": "Data", "width": 80},
{"label": _("<b>System</b>"), "fieldname": "system_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Sub System</b>"), "fieldname": "sub_system_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Procedure</b>"), "fieldname": "procedure_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Steps</b>"), "fieldname": "steps_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Language</b>"), "fieldname": "language", "fieldtype": "Data", "width": 80},
{"label": _("<b>Count</b>"), "fieldname": "count", "fieldtype": "Data", "width": 80},
{"label": _("<b>Zone</b>"), "fieldname": "zone", "fieldtype": "Data", "width": 150},
{"label": _("<b>Area Office</b>"), "fieldname": "area", "fieldtype": "Data", "width": 150},
{"label": _("<b>Dealer Code</b>"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 150},
{"label": _("<b>Dealer Name</b>"), "fieldname": "dealer_name", "fieldtype": "Data", "width": 150},
{"label": _("<b>Device</b>"), "fieldname": "device_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Device Type</b>"), "fieldname": "device_type", "fieldtype": "Data", "width": 150}
]
return columns
columns = [
{"label": _("<b>Date</b>"), "fieldname": "date",
"fieldtype": "Date", "width": 150},
# {"label": _("<b>User ID</b>"), "fieldname": "login_name", "fieldtype": "Data", "width": 125},
# {"label": _("<b>User Name</b>"), "fieldname": "user_name", "fieldtype": "Data", "width": 125},
{"label": _("<b>Model</b>"), "fieldname": "vehicle_id",
"fieldtype": "Data", "width": 150},
{"label": _("<b>Variant Mapping</b>"), "fieldname": "variant_mapping_id",
"fieldtype": "Data", "width": 150},
{"label": _("<b>Variant</b>"), "fieldname": "variant_id",
"fieldtype": "Data", "width": 80},
{"label": _("<b>Module</b>"), "fieldname": "module_id",
"fieldtype": "Data", "width": 150},
{"label": _("<b>System</b>"), "fieldname": "system_id",
"fieldtype": "Data", "width": 150},
{"label": _("<b>Sub System</b>"), "fieldname": "sub_system_id",
"fieldtype": "Data", "width": 150},
{"label": _("<b>Procedure</b>"), "fieldname": "procedure_id",
"fieldtype": "Data", "width": 150},
{"label": _("<b>Steps</b>"), "fieldname": "steps_id",
"fieldtype": "Data", "width": 150},
{"label": _("<b>Language</b>"), "fieldname": "language",
"fieldtype": "Data", "width": 80},
{"label": _("<b>Count</b>"), "fieldname": "count",
"fieldtype": "Data", "width": 80},
# {"label": _("<b>Zone</b>"), "fieldname": "zone", "fieldtype": "Data", "width": 150},
# {"label": _("<b>Area Office</b>"), "fieldname": "area", "fieldtype": "Data", "width": 150},
# {"label": _("<b>Dealer Code</b>"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 150},
# {"label": _("<b>Dealer Name</b>"), "fieldname": "dealer_name", "fieldtype": "Data", "width": 150},
{"label": _("<b>Device</b>"), "fieldname": "device_id",
"fieldtype": "Data", "width": 150},
{"label": _("<b>Device Type</b>"), "fieldname": "device_type",
"fieldtype": "Data", "width": 150}
]
return columns
@frappe.whitelist()
def variant(doctype,txt,searchfield,start,page_len,filters):
model = filters.get('name')
variant = frappe.db.sql("""select name from `tabVariant` where name like %s""",model+'%',as_list=True)
return variant
def variant(doctype, txt, searchfield, start, page_len, filters):
model = filters.get('name')
variant = frappe.db.sql(
"""select name from `tabVariant` where name like %s""", model+'%', as_list=True)
return variant

658246
smart_service/apis/THAR-en-full_v12.00.json

File diff suppressed because it is too large

3
smart_service/apis/addon_api.py

@ -99,8 +99,9 @@ def addon(args=None):
return api
@frappe.whitelist()
@frappe.whitelist(allow_guest=1)
def bookmark(args=None, request=None):
frappe.set_user('Administrator')
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
return rate_res

187
smart_service/apis/app_user_login.py

@ -32,18 +32,16 @@ def custom_rate_limit(limit, seconds):
return 1
# Temporary Login
@frappe.whitelist(allow_guest=True)
def app_user_validation_test():
dicData = {}
try:
doc = frappe.get_doc("Fish", None)
dicData['token'] = doc.apple
dicData['status'] = 1
except:
return {'status': 0, 'error': 'Site Error'}
return dicData
# @frappe.whitelist(allow_guest=True)
# def app_user_validation_test():
# dicData = {}
# try:
# doc = frappe.get_doc("Fish", None)
# dicData['token'] = doc.apple
# dicData['status'] = 1
# except:
# return {'status': 0, 'error': 'Site Error'}
# return dicData
@frappe.whitelist(allow_guest=True)
@ -60,13 +58,12 @@ def app_user_validation(usr=None, pwd=None):
technician_login = preference.technician_login_api
# ISmartAuth API - Email available
try:
data = {'LoginID': usr, 'Password': pwd}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
if technician_login == 1 and mahindra_login == 0:
response = requests.post(
"http://www.mahindramile.com/ISmartAuth/Service.asmx/ValidateCredential", data=data, headers=headers)
"https://www.mahindramile.com/ISmartAuth/Service.asmx/ValidateCredential", data=data, headers=headers)
decoded = response.content.decode('utf-8')
if len(decoded) > 165:
@ -85,7 +82,7 @@ def app_user_validation(usr=None, pwd=None):
return {'status': 0, 'error': 'Invalid Credentials'}
elif technician_login == 0 and mahindra_login == 1:
response1 = requests.post("http://www.mahindramile.com/WindowAuth/Service.asmx/ValidateCredential",
response1 = requests.post("https://www.mahindramile.com/WindowAuth/Service.asmx/ValidateCredential",
data=data, headers=headers)
decoded1 = response1.content.decode('utf-8')
node = ET.fromstring(decoded1)
@ -131,10 +128,10 @@ def app_user_validation(usr=None, pwd=None):
elif technician_login == 1 and mahindra_login == 1:
response = requests.post(
"http://www.mahindramile.com/ISmartAuth/Service.asmx/ValidateCredential", data=data, headers=headers)
"https://www.mahindramile.com/ISmartAuth/Service.asmx/ValidateCredential", data=data, headers=headers)
decoded = response.content.decode('utf-8')
response1 = requests.post("http://www.mahindramile.com/WindowAuth/Service.asmx/ValidateCredential",
response1 = requests.post("https://www.mahindramile.com/WindowAuth/Service.asmx/ValidateCredential",
data=data, headers=headers)
decoded1 = response1.content.decode('utf-8')
node = ET.fromstring(decoded1)
@ -218,7 +215,6 @@ def grant_user_access(userdata=None, iid=None):
area_name = userdata['AreaName']
zone = userdata['Zone']
dealer_code = userdata['Code']
dealer_name = userdata['DealerName']
app_current_version = userdata['AppCurrentVersion']
@ -234,9 +230,7 @@ def grant_user_access(userdata=None, iid=None):
frappe.set_user("Administrator")
user_name = frappe.db.sql('''SELECT name FROM {0}.tabUser where email='{1}';'''.format(
current_db_name, email), as_dict=1)
# return user_name
if user_name:
# token = generate_keys(user_name[0]['name'])
try:
""" New Refresh token update """
access_token = generate_access_token(user_name[0]['name'])
@ -259,7 +253,6 @@ def grant_user_access(userdata=None, iid=None):
user_name = frappe.db.sql('''SELECT name FROM {0}.tabUser where email='{1}';'''.format(
current_db_name, email), as_dict=1)
if user_name:
# token = generate_keys(user_name[0]['name'])
try:
""" New Refresh token update """
access_token = generate_access_token(user_name[0]['name'])
@ -306,16 +299,6 @@ def grant_user_access(userdata=None, iid=None):
'''Inserting Device data'''
if iid == 'None' or iid == 'null':
app_device = frappe.new_doc('App Device')
app_device.device_id = device_id
app_device.publish_type = "Global"
app_device.device_type = device_type
app_device.os = os
app_device.os_version = os_version
app_device.app_current_version = app_current_version
app_device.last_login = now()
app_device.insert()
if frappe.db.exists({'doctype': 'App Device', 'device_id': device_id}):
frappe.db.sql(
'''UPDATE {2}.`tabApp Device` SET active_status= "{1}" where device_id = "{0}";'''.format(device_id,
@ -328,21 +311,27 @@ def grant_user_access(userdata=None, iid=None):
app_device1 = frappe.get_last_doc(
'App Device', filters={"device_id": device_id})
app_device = frappe.new_doc('App Device')
app_device.device_id = device_id
app_device.publish_type = "Global"
app_device.device_type = device_type
app_device.os = os
app_device.os_version = os_version
app_device.app_current_version = app_current_version
app_device.last_login = now()
app_device.insert()
app_logs = frappe.new_doc('App Log')
app_logs.user = app_user1.name
app_logs.device = app_device.name
app_logs.type = 'Reinstalled'
app_logs.latitude = latitude
app_logs.longitude = longitude
# app_logs.active_status = 'Active'
app_logs.date_time_stamp = now()
app_logs.insert()
app_device_tmp = frappe.get_last_doc(
'App Device', filters={"device_id": device_id})
frappe.db.sql('''UPDATE {2}.`tabApp Device` SET active_status= "{1}" where name = "{0}";'''.format(
app_device_tmp.name, "Active", current_db_name))
frappe.db.commit()
app_logs3 = frappe.new_doc('App Log')
app_logs3.user = app_user1.name
@ -354,6 +343,16 @@ def grant_user_access(userdata=None, iid=None):
app_logs3.insert()
else:
app_device = frappe.new_doc('App Device')
app_device.device_id = device_id
app_device.publish_type = "Global"
app_device.device_type = device_type
app_device.os = os
app_device.os_version = os_version
app_device.app_current_version = app_current_version
app_device.last_login = now()
app_device.insert()
app_user1 = frappe.get_last_doc(
'App Users', filters={"email_id": email})
app_device1 = frappe.get_last_doc(
@ -362,7 +361,6 @@ def grant_user_access(userdata=None, iid=None):
app_logs.user = app_user1.name
app_logs.device = app_device.name
app_logs.type = 'Installed'
# app_logs.active_status = 'Active'
app_logs.latitude = latitude
app_logs.longitude = longitude
app_logs.date_time_stamp = now()
@ -378,9 +376,6 @@ def grant_user_access(userdata=None, iid=None):
app_logs4.save()
else:
# frappe.db.sql(
# '''UPDATE {4}.`tabApp Device` set last_login= '{0}', user_name = '{2}', device_type = '{3}' where name = "{1}";'''.format(
# now(), iid, email, user_type_desc, current_db_name))
frappe.db.sql(
'''UPDATE {3}.`tabApp Device` set last_login= '{0}', device_type = '{2}' where name = "{1}";'''.format(
now(), iid, device_type, current_db_name))
@ -406,7 +401,6 @@ def grant_user_access(userdata=None, iid=None):
user_details = {}
user_details['Installation ID'] = lst[0][0]
user_details['User ID'] = lst1[0][0]
# user_details['token'] = token
user_details['status'] = 1
user_details['token_details'] = token_details
return user_details
@ -415,6 +409,32 @@ def grant_user_access(userdata=None, iid=None):
return {'status': 0, 'error': "Invalid Inputs"}
@frappe.whitelist(allow_guest=True)
def data_invalidation(email, device_id, iid=None):
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
return rate_res
try:
# User validation
frappe.set_user("Administrator")
user_name = frappe.db.sql('''SELECT name FROM {0}.tabUser where email='{1}';'''.format(
current_db_name, email), as_dict=1)
token_details = []
if user_name:
""" New Refresh token update """
access_token = generate_access_token(user_name[0]['name'])
refresh_token = generate_refresh_token()
token_details = update_tokens_in_doc(
user_name[0]['name'], access_token, refresh_token)
return {'status': 1, 'data': token_details, 'error': None}
except Exception as e1:
return {'status': 0, 'data': [], 'error': 'Failed to verify user'}
@frappe.whitelist(allow_guest=True)
def new_app_user_validation(usr=None, pwd=None, iid=None, device_data=None):
rate_res = custom_rate_limit(limit=5, seconds=15)
@ -435,7 +455,7 @@ def new_app_user_validation(usr=None, pwd=None, iid=None, device_data=None):
headers = {"Content-Type": "application/x-www-form-urlencoded"}
if technician_login == 1 and mahindra_login == 0:
response = requests.post(
"http://www.mahindramile.com/ISmartAuth/Service.asmx/ValidateCredential", data=data, headers=headers)
"https://www.mahindramile.com/ISmartAuth/Service.asmx/ValidateCredential", data=data, headers=headers)
decoded = response.content.decode('utf-8')
if len(decoded) > 165:
@ -454,7 +474,7 @@ def new_app_user_validation(usr=None, pwd=None, iid=None, device_data=None):
return {'status': 0, 'error': 'Invalid Credentials'}
elif technician_login == 0 and mahindra_login == 1:
response1 = requests.post("http://www.mahindramile.com/WindowAuth/Service.asmx/ValidateCredential",
response1 = requests.post("https://www.mahindramile.com/WindowAuth/Service.asmx/ValidateCredential",
data=data, headers=headers)
decoded1 = response1.content.decode('utf-8')
node = ET.fromstring(decoded1)
@ -497,10 +517,10 @@ def new_app_user_validation(usr=None, pwd=None, iid=None, device_data=None):
elif technician_login == 1 and mahindra_login == 1:
response = requests.post(
"http://www.mahindramile.com/ISmartAuth/Service.asmx/ValidateCredential", data=data, headers=headers)
"https://www.mahindramile.com/ISmartAuth/Service.asmx/ValidateCredential", data=data, headers=headers)
decoded = response.content.decode('utf-8')
response1 = requests.post("http://www.mahindramile.com/WindowAuth/Service.asmx/ValidateCredential",
response1 = requests.post("https://www.mahindramile.com/WindowAuth/Service.asmx/ValidateCredential",
data=data, headers=headers)
decoded1 = response1.content.decode('utf-8')
node = ET.fromstring(decoded1)
@ -660,16 +680,6 @@ def new_grant_user_access(userdata=None, iid=None):
'''Inserting Device data'''
if iid == 'None' or iid == 'null':
app_device = frappe.new_doc('App Device')
app_device.device_id = device_id
app_device.publish_type = "Global"
app_device.device_type = device_type
app_device.os = os
app_device.os_version = os_version
app_device.app_current_version = app_current_version
app_device.last_login = now()
app_device.insert()
if frappe.db.exists({'doctype': 'App Device', 'device_id': device_id}):
frappe.db.sql(
'''UPDATE {2}.`tabApp Device` SET active_status= "{1}" where device_id = "{0}";'''.format(device_id,
@ -681,6 +691,15 @@ def new_grant_user_access(userdata=None, iid=None):
'App Users', filters={"email_id": email})
app_device1 = frappe.get_last_doc(
'App Device', filters={"device_id": device_id})
app_device = frappe.new_doc('App Device')
app_device.device_id = device_id
app_device.publish_type = "Global"
app_device.device_type = device_type
app_device.os = os
app_device.os_version = os_version
app_device.app_current_version = app_current_version
app_device.last_login = now()
app_device.insert()
app_logs = frappe.new_doc('App Log')
app_logs.user = app_user1.name
@ -688,16 +707,9 @@ def new_grant_user_access(userdata=None, iid=None):
app_logs.type = 'Reinstalled'
app_logs.latitude = latitude
app_logs.longitude = longitude
# app_logs.active_status = 'Active'
app_logs.date_time_stamp = now()
app_logs.insert()
app_device_tmp = frappe.get_last_doc(
'App Device', filters={"device_id": device_id})
frappe.db.sql('''UPDATE {2}.`tabApp Device` SET active_status= "{1}" where name = "{0}";'''.format(
app_device_tmp.name, "Active", current_db_name))
frappe.db.commit()
app_logs3 = frappe.new_doc('App Log')
app_logs3.user = app_user1.name
app_logs3.device = app_device.name
@ -708,6 +720,16 @@ def new_grant_user_access(userdata=None, iid=None):
app_logs3.insert()
else:
app_device = frappe.new_doc('App Device')
app_device.device_id = device_id
app_device.publish_type = "Global"
app_device.device_type = device_type
app_device.os = os
app_device.os_version = os_version
app_device.app_current_version = app_current_version
app_device.last_login = now()
app_device.insert()
app_user1 = frappe.get_last_doc(
'App Users', filters={"email_id": email})
app_device1 = frappe.get_last_doc(
@ -716,7 +738,6 @@ def new_grant_user_access(userdata=None, iid=None):
app_logs.user = app_user1.name
app_logs.device = app_device.name
app_logs.type = 'Installed'
# app_logs.active_status = 'Active'
app_logs.latitude = latitude
app_logs.longitude = longitude
app_logs.date_time_stamp = now()
@ -732,9 +753,6 @@ def new_grant_user_access(userdata=None, iid=None):
app_logs4.save()
else:
# frappe.db.sql(
# '''UPDATE {4}.`tabApp Device` set last_login= '{0}', user_name = '{2}', device_type = '{3}' where name = "{1}";'''.format(
# now(), iid, email, user_type_desc, current_db_name))
frappe.db.sql(
'''UPDATE {3}.`tabApp Device` set last_login= '{0}', device_type = '{2}' where name = "{1}";'''.format(
now(), iid, device_type, current_db_name))
@ -785,16 +803,16 @@ def generate_keys(user_name):
return token
@frappe.whitelist()
def login_generate_token(doc=None, method=None):
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
return rate_res
new_tok = generate_keys('cms@guidedsmartservice.com')
water = frappe.get_doc("Fish", None)
water.apple = new_tok
water.save()
return water.apple
# @frappe.whitelist()
# def login_generate_token(doc=None, method=None):
# rate_res = custom_rate_limit(limit=5, seconds=15)
# if rate_res != 1:
# return rate_res
# new_tok = generate_keys('cms@guidedsmartservice.com')
# water = frappe.get_doc("Fish", None)
# water.apple = new_tok
# water.save()
# return water.apple
def input_validation(**kwargs):
@ -857,7 +875,6 @@ def generate_refresh_token():
@frappe.whitelist(allow_guest=1, methods=['POST'])
def refresh_token():
""" For Refresh API """
# rate_res = custom_rate_limit(limit=5, seconds=15)
# if rate_res != 1:
@ -867,9 +884,9 @@ def refresh_token():
req = frappe.request.data
req = json.loads(req)
refresh_token= req['refresh_token']
refresh_token = req['refresh_token']
if refresh_token:
device_id= req['DeviceID']
device_id = req['DeviceID']
ref_token = refresh_token
doc_details = frappe.db.sql('''
SELECT * FROM `tabRefresh Token`;''', as_dict=1)
@ -880,9 +897,7 @@ def refresh_token():
refresh_token = generate_refresh_token()
token_details = update_tokens_in_doc(
d['user'], access_token, refresh_token)
# token_details['status'] = 1
return {'status': 1, 'token_details': token_details}
# return token_details
return {'status': 0, "error": 'Invalid token'}
@ -918,7 +933,7 @@ def invalidate_token(refresh_token):
return {'status': 0, "error": 'Failed'}
@frappe.whitelist(allow_guest=1,methods=['POST'])
@frappe.whitelist(allow_guest=1, methods=['POST'])
def deactivate_account(refresh_token):
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
@ -944,10 +959,7 @@ def deactivate_account(refresh_token):
return {'status': 0, "error": 'Failed'}
def update_tokens_in_doc(user_email, access, refresh):
# access_exp_hours = 15 * 60
# refresh_exp_hrs = 60 * 60 * 24
token_settings = frappe.get_doc('Token Settings')
access_exp_hours = token_settings.access_expiry_time
@ -970,9 +982,6 @@ def update_tokens_in_doc(user_email, access, refresh):
refresh_doc.access_token = encrypt(access)
refresh_doc.refresh_token = encrypt(refresh)
# access_exp_time = datetime.now() + timedelta(seconds=access_exp_hours)
# refresh_exp_time = datetime.now() + timedelta(seconds=refresh_exp_hrs)
access_exp_time = datetime.now() + timedelta(minutes=access_exp_hours)
refresh_exp_time = datetime.now() + timedelta(hours=refresh_exp_hrs)
@ -982,9 +991,9 @@ def update_tokens_in_doc(user_email, access, refresh):
frappe.db.commit()
user_token_details['access_token'] = access
user_token_details['access_expiry_time'] = access_exp_hours* 60
user_token_details['access_expiry_time'] = access_exp_hours * 60
user_token_details['refresh_token'] = refresh
user_token_details['refresh_expiry_time'] = refresh_exp_hrs* 60 * 60
user_token_details['refresh_expiry_time'] = refresh_exp_hrs * 60 * 60
return user_token_details

439
smart_service/apis/check_update.py

@ -0,0 +1,439 @@
import frappe
from frappe.model.document import Document
import json
import os
from frappe.utils import cstr
from smart_service.apis.app_user_login import input_validation
""" Constants """
JSON_EXT = ".json"
JSON_INT_PATH = "/files/json_files/internal/"
JSON_FULL_INT_PATH = "/files/json_files/full_update/internal/"
JSON_GLOABL_PATH = "/files/json_files/global/"
JSON_FULL_GLOBAL_PATH = "/files/json_files/full_update/"
STATUS = "status"
ERROR = "error"
UPDATE_AVAILABLE = 'IsUpdateAvailable'
UPDATE_FAILED = "Update checking Failed"
PARAM_MISSING = "Parameter missing :"
VERSION = 'Version'
CUR_VERSION = 'CurrentVersion'
DIS = 'Discription'
FILE_ERROR = 'File failed to load'
LANGUAGE = 'Language'
FILE_SIZE = 'FileSize'
JSON_URL = 'JsonURL'
site_name = cstr(frappe.local.site)
base_url = os.path.expanduser(
"~") + "/frappe-bench/sites/" + site_name + "/public"
@frappe.whitelist(allow_guest=1)
def check_vehicle_update(vehicle_list=None):
""" Rate Limiting """
# rate_res = custom_rate_limit(limit=5, seconds=15)
# if rate_res != 1:
# return rate_res
""" Validate Inputs """
val = input_validation(vehicle_list=vehicle_list)
""" Validate Input response """
if val != '':
return {"Vehicle": None,
"VehicleReqList": [],
STATUS: 0, ERROR: PARAM_MISSING+val}
response = {}
""" Iterate Vehicle List """
if vehicle_list:
try:
""" Read Request Body """
req_list = json.loads(vehicle_list)
response['Vehicle'] = req_list['Vehicle']
vehicle = req_list['Vehicle']
iid = req_list['InstallationId']
vehicle_data = req_list['VehicleReqList']
""" Get Publish Type based on IID """
publish_type = frappe.db.get_list(
'App Device', filters={'name': iid}, fields='publish_type')
if publish_type:
publish_type = publish_type[0]['publish_type']
VehicleReqList = []
for v in vehicle_data:
l_id = v['LanguageID']
current_version = float(v[CUR_VERSION])
""" New function to validate publish version and get file path """
pulish_response = get_vehicle_publish_data(vehicle=vehicle,
l_id=l_id, current_version=current_version, publish_type=publish_type)
""" Append to Main Vehicle Request Response List """
VehicleReqList.append(pulish_response)
return {
"Vehicle": vehicle, "VehicleReqList": VehicleReqList, STATUS: 1, ERROR: "No error"}
except Exception as e:
return {"Vehicle": None, "VehicleReqList": [], STATUS: 0, ERROR: str(e)}
else:
return {"Vehicle": None, "VehicleReqList": [], STATUS: 0, ERROR: "Check Parameter: vehicle list"}
def get_file_size(file_name):
return os.path.getsize(base_url + file_name)
def get_vehicle_publish_data(vehicle, l_id, current_version, publish_type):
""" Response Structure """
vehicle_response_data = {
"Name": None,
"Version": 0,
"Vehicle": None,
"Language": l_id,
"Description": None,
"JsonURL": None,
"FileSize": None,
"Error": None,
"IsUpdateAvailable": False,
"CurrentVersion": current_version
}
latest_global_version = frappe.db.sql('''SELECT name as Name,format(version,2) as version,vehicle_id,language,release_description as Description
FROM `tabPublish` where vehicle='{0}' and language='{1}' and publish_status='Published' and vehicle_status='Active'
and publish_module='Automotive System' and version = (select max(version) as version from `tabPublish`
where publish_module='Automotive System' and vehicle='{0}' and publish_type='Global' and language='{1}');
'''.format(vehicle, l_id), as_dict=1)
latest_publish_version = frappe.db.sql('''SELECT name as Name,format(version,2) as version,vehicle_id,language,release_description as Description
FROM `tabPublish` where vehicle='{0}' and language='{1}' and publish_status='Published' and vehicle_status='Active'
and publish_module='Automotive System' and version = (select max(version) as version from `tabPublish`
where publish_module='Automotive System' and vehicle='{0}' and language='{1}' and version >= {2});
'''.format(vehicle, l_id, current_version), as_dict=1)
if not latest_publish_version:
""" Latest File already downloaded Global/Internal """
vehicle_response_data['IsUpdateAvailable'] = False
vehicle_response_data['Remarks'] = "Latest Version"
else:
if not latest_global_version or (current_version >= float(latest_global_version[0]['version'])):
""" Only First Internal available """
if publish_type == 'Internal':
value = round(
float(latest_publish_version[0]['version']) - current_version, 2)
if value == 0.01:
# frappe.log_error('Inside 1 Internal')
""" 1 Internal File """
data = frappe.db.sql('''SELECT name as Name,format(version,2) as Version,vehicle_id as Vehicle,language as Language,
release_description as Description FROM `tabPublish` where vehicle='{0}' and language='{1}' and
publish_status='Published' and vehicle_status='Active' and publish_module='Automotive System'
and version = (select max(version) as version from `tabPublish`
where publish_module='Automotive System' and publish_type='Internal'
and vehicle='{0}' and language='{1}');
'''.format(vehicle, l_id), as_dict=1)
# frappe.log_error('data', str(data))
# data = latest_publish_version
# frappe.log_error("data",str(data))
if data:
file_name = JSON_INT_PATH+vehicle+"/"+vehicle + \
"-" + l_id + "_v" + \
str(data[0][VERSION]) + JSON_EXT
if os.path.exists(base_url + file_name):
vehicle_response_data['Name'] = data[0]['Name']
vehicle_response_data['Vehicle'] = data[0]['Vehicle']
vehicle_response_data['Version'] = data[0]['Version']
vehicle_response_data['Language'] = data[0]['Language']
vehicle_response_data['Description'] = data[0]['Description']
vehicle_response_data['FileSize'] = get_file_size(
file_name)
vehicle_response_data['JsonURL'] = file_name
vehicle_response_data['IsUpdateAvailable'] = True
vehicle_response_data['Remarks'] = "Internal available"
else:
vehicle_response_data['IsUpdateAvailable'] = False
vehicle_response_data['Remarks'] = "Internal available"
vehicle_response_data['Error'] = "Failed to read file"
else:
vehicle_response_data['IsUpdateAvailable'] = False
vehicle_response_data['Remarks'] = "Internal available"
vehicle_response_data['Error'] = "Failed to get Publish version"
else:
""" Full Internal File """
# same as latest_publish_version
data = frappe.db.sql('''SELECT name as Name,format(version,2) as Version,vehicle_id as Vehicle,language as Language,
release_description as Description FROM `tabPublish` where vehicle='{0}' and language='{1}' and
publish_status='Published' and vehicle_status='Active' and publish_module='Automotive System'
and version = (select max(version) as version from `tabPublish`
where publish_module='Automotive System' and publish_type='Internal'
and vehicle='{0}' and language='{1}' );
'''.format(vehicle, l_id), as_dict=1)
# data = latest_publish_version
if data:
file_name = JSON_FULL_INT_PATH+vehicle+"/"+vehicle + \
"-" + l_id + "-"+"full_v" + \
str(data[0][VERSION]
) + JSON_EXT
if os.path.exists(base_url + file_name):
vehicle_response_data['Name'] = data[0]['Name']
vehicle_response_data['Vehicle'] = data[0]['Vehicle']
vehicle_response_data['Version'] = data[0]['Version']
vehicle_response_data['Language'] = data[0]['Language']
vehicle_response_data['Description'] = data[0]['Description']
vehicle_response_data['FileSize'] = get_file_size(
file_name)
vehicle_response_data['JsonURL'] = file_name
vehicle_response_data['IsUpdateAvailable'] = True
vehicle_response_data['Remarks'] = "Internal Full Update available"
else:
vehicle_response_data['IsUpdateAvailable'] = False
vehicle_response_data['Remarks'] = "Internal Full Update available"
vehicle_response_data['Error'] = "Failed to read file"
else:
vehicle_response_data['IsUpdateAvailable'] = False
vehicle_response_data['Remarks'] = "Internal Full Update available"
vehicle_response_data['Error'] = "Failed to get Publish version"
else:
vehicle_response_data['IsUpdateAvailable'] = False
vehicle_response_data['Remarks'] = "No Update available"
elif current_version < float(latest_global_version[0]['version']):
""" Only Global available """
if (float(latest_global_version[0]['version']) - int(current_version)) > 1:
""" Full Global File """
data = frappe.db.sql('''SELECT name as Name,format(version,2) as Version,vehicle_id as Vehicle,language as Language,
release_description as Description FROM `tabPublish` where vehicle='{0}' and language='{1}' and
publish_status='Published' and vehicle_status='Active' and publish_module='Automotive System'
and version = (select max(version) as version from `tabPublish`
where publish_module='Automotive System'
and vehicle='{0}' and language='{1}' and publish_type ='Global');
'''.format(vehicle, l_id), as_dict=1)
if data:
file_name = JSON_FULL_GLOBAL_PATH + vehicle + "/" + vehicle + \
"-" + l_id + "-"+"full_v" + \
str(data[0][VERSION]
) + JSON_EXT
if os.path.exists(base_url + file_name):
vehicle_response_data['Name'] = data[0]['Name']
vehicle_response_data['Vehicle'] = data[0]['Vehicle']
vehicle_response_data['Version'] = data[0]['Version']
vehicle_response_data['Language'] = data[0]['Language']
vehicle_response_data['Description'] = data[0]['Description']
vehicle_response_data['FileSize'] = get_file_size(
file_name)
vehicle_response_data['JsonURL'] = file_name
vehicle_response_data['IsUpdateAvailable'] = True
vehicle_response_data['Remarks'] = "Global Full Update available"
else:
vehicle_response_data['IsUpdateAvailable'] = False
vehicle_response_data['Remarks'] = "Global Full Update available"
vehicle_response_data['Error'] = "Failed to read file"
else:
vehicle_response_data['IsUpdateAvailable'] = False
vehicle_response_data['Remarks'] = "Global Full Update available"
vehicle_response_data['Error'] = "Failed to get Publish version"
# vehicle_response_data['IsUpdateAvailable'] = True
# vehicle_response_data['Remarks'] = "Full Update Global available"
else:
""" Single Global File """
# vehicle_response_data['IsUpdateAvailable'] = True
# vehicle_response_data['Remarks'] = "Global available"
data = frappe.db.sql('''SELECT name as Name,format(version,2) as Version,vehicle_id as Vehicle,language as Language,
release_description as Description FROM `tabPublish` where vehicle='{0}' and language='{1}' and
publish_status='Published' and vehicle_status='Active' and publish_module='Automotive System'
and version = (select max(version) as version from `tabPublish`
where publish_module='Automotive System'
and vehicle='{0}' and language='{1}' and publish_type ='Global');
'''.format(vehicle, l_id), as_dict=1)
if data:
file_name = JSON_GLOABL_PATH+vehicle+"/"+vehicle + \
"-" + l_id + "_v" + \
str(data[0][VERSION]) + JSON_EXT
if os.path.exists(base_url + file_name):
vehicle_response_data['Name'] = data[0]['Name']
vehicle_response_data['Vehicle'] = data[0]['Vehicle']
vehicle_response_data['Version'] = data[0]['Version']
vehicle_response_data['Language'] = data[0]['Language']
vehicle_response_data['Description'] = data[0]['Description']
vehicle_response_data['FileSize'] = get_file_size(
file_name)
vehicle_response_data['JsonURL'] = file_name
vehicle_response_data['IsUpdateAvailable'] = True
vehicle_response_data['Remarks'] = "Global available"
else:
vehicle_response_data['IsUpdateAvailable'] = False
vehicle_response_data['Remarks'] = "Global available"
vehicle_response_data['Error'] = "Failed to read file"
else:
vehicle_response_data['IsUpdateAvailable'] = False
vehicle_response_data['Remarks'] = "Global available"
vehicle_response_data['Error'] = "Failed to get Publish version"
else:
""" Unknow condition Dont Know Yet """
value = {'latest_publish_version': latest_publish_version[0]['version'],
" latest_global_version": latest_global_version[0]['version']}
frappe.log_error('New check Update', str(
f'Unknow Condition{value}'))
vehicle_response_data['IsUpdateAvailable'] = True
vehicle_response_data['Remarks'] = "New Condition"
return vehicle_response_data
@frappe.whitelist(allow_guest=1)
def check_all_vehicle_updates(vehicle_list=None):
val = input_validation(vehicle_list=vehicle_list)
if val != '':
return {STATUS: 0, ERROR: PARAM_MISSING+val}
if vehicle_list:
try:
vehicle_req_list = []
response = {}
v_list = json.loads(vehicle_list)
lang = v_list['LanguageID']
iid = v_list['InstallationId']
vehicle_data = v_list['VehicleReqList']
publish_type = frappe.db.sql(
'''SELECT publish_type FROM `tabApp Device` where name='{}';'''.format(iid), as_list=1)
if publish_type[0][0] is not None:
if vehicle_data:
for v in vehicle_data:
v_id = v['Vehicle']
current_version = float(v[CUR_VERSION])
data1_global = frappe.db.sql('''SELECT name,format(version,2) as version,vehicle_id,language,release_description as description
FROM `tabPublish` where vehicle='{}' and language='{}' and publish_status='Published'
and publish_type='Global'
and vehicle_status='Active' and publish_module='Automotive System' and version = (select max(version) as version
from `tabPublish` where publish_module='Automotive System'
and vehicle='{}' and publish_type='Global' and language='{}');'''.format(v_id, lang, v_id, lang), as_dict=1)
data1 = frappe.db.sql('''SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description
FROM `tabPublish` where vehicle='{}' and language='{}'
and publish_status='Published' and vehicle_status='Active' and publish_module='Automotive System'
and vehicle='{}' and language='{}'
;'''.format(v_id, lang, v_id, lang), as_dict=1)
if data1[0]['version'] is not None:
if current_version == float(data1[0]['version']):
data1[0][CUR_VERSION] = current_version
data1[0][UPDATE_AVAILABLE] = "false"
vehicle_req_list.append(data1)
elif len(data1_global) == 0:
if current_version < float(data1[0]['version']):
data = frappe.db.sql('''SELECT name,format(version,2) as version,vehicle_id,language,release_description as description
FROM `tabPublish` where vehicle='{}' and language='{}' and publish_status='Published' and
publish_type='{}' and vehicle_status='Active' and publish_module='Automotive System' and
version = (select max(version) as version from `tabPublish` where publish_module='Automotive System'
and vehicle='{}' and language='{}')'''.format(v_id, lang, publish_type[0][0], v_id, lang), as_dict=1)
data_append = []
rd = []
try:
for d in data:
d[UPDATE_AVAILABLE] = 'true'
d[CUR_VERSION] = current_version
data_append.append(d)
vehicle_req_list.append(data_append)
except:
pass
else:
if current_version < float(data1_global[0]['version']):
data = frappe.db.sql('''SELECT name,format(version,2) as version,vehicle_id,language,release_description as description
FROM `tabPublish` where vehicle='{}' and language='{}'
and publish_status='Published' and publish_type='Global' and vehicle_status='Active'
and publish_module='Automotive System'
and version = (select max(version) as version from `tabPublish`
where publish_module='Automotive System'
and vehicle='{}' and language='{}')'''.format(v_id, lang, v_id, lang), as_dict=1)
elif current_version == float(data1_global[0]['version']):
if current_version < float(data1[0]['version']):
data = frappe.db.sql('''SELECT name,format(version,2) as version,vehicle_id,language,release_description as description
FROM `tabPublish` where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='{}'
and vehicle_status='Active' and publish_module='Automotive System'
and version = (select max(version) as version from `tabPublish` where publish_module='Automotive System'
and vehicle='{}' and language='{}')'''.format(v_id, lang, publish_type[0][0], v_id, lang), as_dict=1)
elif current_version > float(data1_global[0]['version']):
if current_version < float(data1[0]['version']):
data = frappe.db.sql('''SELECT name,format(version,2) as version,vehicle_id,language,release_description as description
FROM `tabPublish` where vehicle='{}' and language='{}' and publish_status='Published' and
publish_type='{}' and vehicle_status='Active' and publish_module='Automotive System' and
version = (select max(version) as version from `tabPublish` where publish_module='Automotive System'
and vehicle='{}' and language='{}')'''.format(v_id, lang, publish_type[0][0], v_id, lang), as_dict=1)
# return data
data_append = []
rd = []
try:
for d in data:
d[UPDATE_AVAILABLE] = 'true'
d[CUR_VERSION] = current_version
data_append.append(d)
vehicle_req_list.append(data_append)
# for note in publish_dec:
# rd.append(note)
# vehicle_req_list.append(rd)
# for n in publish_dec:
# rd.append(n['release_description'])
# vehicle_req_list.append(rd)
except:
pass
response['LanguageID'] = lang
if len(vehicle_req_list) != 0:
data = [vu[0] for vu in vehicle_req_list]
# publish_dec_txt = [pd[0] for pd in publish_dec]
response['VehicleReqList'] = data
# response['release_description'] = publish_dec_txt['release_description']
return response
else:
return {STATUS: 0, ERROR: "No Vehicles in criteria"}
else:
return {STATUS: 0, ERROR: "Invalid Publish Details"}
else:
return {STATUS: 0, ERROR: "Invalid Publish Details"}
except Exception as e:
return {STATUS: 0, ERROR: str(e)}
else:
return {STATUS: 0, ERROR: "Check argument: vehicle list"}

176
smart_service/apis/master_api.py

@ -7,6 +7,13 @@ from frappe.utils import cstr
import datetime
from smart_service.apis.app_user_login import input_validation
import os
import json
from frappe import utils
from frappe.utils import logger
import copy
frappe.utils.logger.set_log_level("DEBUG")
date_format = "%Y-%m-%d %H:%M:%S.%f"
current_db_name = frappe.conf.get("db_name")
site_name = cstr(frappe.local.site)
@ -37,17 +44,19 @@ def custom_rate_limit(limit, seconds):
@frappe.whitelist()
def masters(args=None, LSD=None,iid=None):
def masters(args=None, LSD=None, iid=None):
# Rate limit - Step 1
rate = custom_rate_limit(limit=20, seconds=5)
if rate != 1:
return rate
# Input Validation
val = input_validation(args=args)
if val != '':
return {"status": 0, "error": "Parameter's missing:"+val}
# Time validation
date_format = "%Y-%m-%d %H:%M:%S.%f"
if LSD != "":
try:
datetime.datetime.strptime(LSD, date_format)
@ -64,15 +73,18 @@ def masters(args=None, LSD=None,iid=None):
if publish_type == 'Global':
api = frappe.db.sql(f'''
select name as vehicle,vehicle_segment,vehicle_segment_id,image,active_status,display_order,
myid as vechile_id,display_order,modified from tabVehicle
where modified > '{LSD}' and global_publish = 1;
''',as_dict=1)
else:
myid as vechile_id,display_order,modified from `tabVehicle`
where modified > '{LSD}' and global_publish = 1;
''', as_dict=1)
elif publish_type == 'Internal':
api = frappe.db.sql(f'''
select name as vehicle,vehicle_segment,vehicle_segment_id,image,active_status,display_order,
myid as vechile_id,display_order,modified from tabVehicle
where modified > '{LSD}' and internal_publish = 1;
''',as_dict=1)
myid as vechile_id,display_order,modified from `tabVehicle`
where modified > '{LSD}' and internal_publish = 1;
''', as_dict=1)
else:
api = []
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
@ -80,6 +92,10 @@ def masters(args=None, LSD=None,iid=None):
i["active_status"] = False
elif args == "variant":
api = frappe.db.sql('''
select v.myid as variant_id,vm.name,vm.vehicle,vm.variant,vm.fuel,vm.transmission,vm.drive,vm.active_status
FROM `tabVariant Mapping` vm left join tabVariant v on v.name = vm.variant where vm.modified >='';''', as_dict=1)
api = frappe.db.get_list(
"Variant",
fields=[
@ -223,13 +239,13 @@ def masters(args=None, LSD=None,iid=None):
api = frappe.db.sql('''
SELECT lang_name,lang_code,active_status,display_order,myid as lang_id,modified FROM `tabCustom Languages`
where modified> 'LSD' and global_publish = 1;
''',as_dict=1)
''', as_dict=1)
else:
api = frappe.db.sql('''
SELECT lang_name,lang_code,active_status,display_order,myid as lang_id,modified FROM `tabCustom Languages`
where modified> 'LSD' and internal_publish = 1;
''',as_dict=1)
''', as_dict=1)
for i in api:
if i["active_status"] == "Active":
@ -267,6 +283,8 @@ def masters(args=None, LSD=None,iid=None):
temp_api = frappe.get_doc(
"App Preference",
)
time_val = datetime.datetime.strptime(
temp_api.auto_logout_time, '%H:%M:%S')
api = {
"application_server_url": temp_api.application_server_url,
"update_server_url": temp_api.update_server_url,
@ -275,7 +293,7 @@ def masters(args=None, LSD=None,iid=None):
"masters_base_url": temp_api.masters_base_url,
"transactions_base_url": temp_api.transactions_base_url,
"addons_base_url": temp_api.addons_base_url,
"auto_logout_time": temp_api.auto_logout_time
"auto_logout_time": time_val.strftime('%H:%M:%S.%f')
}
else:
@ -296,3 +314,137 @@ def check_pub_type(iid):
if not device_pub_type:
return False
return device_pub_type[0][0]
@frappe.whitelist(methods=['POST'])
def old_variant(LSD, language):
date_format = "%Y-%m-%d %H:%M:%S.%f"
if LSD != "":
try:
datetime.datetime.strptime(LSD, date_format)
except:
return {"status": 0, "error": " 'LSD' format error"}
try:
data = frappe.db.sql('''
select name,vehicle,vehicle_id,variant_name,variant,variant_id,fuel,fuel_id,transmission,transmission_id,drive,drive_id,family_code,
case when active_status= 'Active' Then true else false end as active_status
FROM `tabVariant Mapping` where modified >='';''', as_dict=1)
for d in data:
d['modules'] = {
"Automotive System": 1,
"TSB": 1,
"FSA": 1,
"TEKalert": 1,
"Feature Finder": 1,
"Repair/Service Check Sheet": 1,
"Mahindra Special Tool Information": 0,
"Training Information": 0,
"QWIK Service": 0,
"PDI Inspection": 0,
"Torque Information NM": 0
}
return {"status": 1, "error": None, 'data': data}
except Exception as e:
frappe.local.response['http_status_code'] = 400
return {"status": 0, "error": e, 'data': None}
@frappe.whitelist(methods=['POST'],allow_guest = 1)
def variant(LSD, language, iid=None):
date_format = "%Y-%m-%d %H:%M:%S.%f"
# if LSD != "null":
# try:
# datetime.datetime.strptime(LSD, date_format)
# except:
# return {"status": 0, "error": " 'LSD' format error"}
publish_type = check_pub_type(iid)
try:
data = frappe.db.sql(f'''
select name,vehicle,vehicle_id,name as variant_name,variant,variant_id,fuel,fuel_id,transmission,transmission_id,
drive,drive_id,family_code,
case when active_status= 'Active' Then true else false end as active_status
FROM `tabVariant Mapping` where modified >='{LSD}';''', as_dict=1)
for d in data:
modules = frappe.db.sql(f'''select automotive_system as 'Automotive System',tsb as 'TSB',fsa as 'FSA',tekalert as 'TEKalert',
feature_finder as 'Feature Finder',repairservice_check_sheet as 'Repair/Service Check Sheet',
mahindra_special_tool_information as 'Mahindra Special Tool Information',training_information as 'Training Information',
qwik_service as 'QWIK Service',pdi_inspection as 'PDI Inspection',torque_information_nm as 'Torque Information'
FROM `tabModule Publish Mapping` where vehicle= '{d['vehicle']}' and variant='{d['variant_name']}'
and language = "{language}" and publish_type = '{publish_type}';''', as_dict=1)
if modules:
d['modules'] = [{'title': k, 'active_status': v, 'app_menu_id':
frappe.db.sql(f'''select app_menu_id from `tabModule Master` where module_name = '{k}' ;''', as_dict=1)[0]['app_menu_id']}
for k, v in modules[0].items()]
else:
d['modules'] = []
return {"status": 1, "error": None, 'data': data}
except Exception as e:
frappe.local.response['http_status_code'] = 400
return {"status": 0, "error": e, 'data': None}
@frappe.whitelist(methods=['POST'],allow_guest =1)
def app_modules(LSD):
date_format = "%Y-%m-%d %H:%M:%S.%f"
if LSD != "":
try:
datetime.datetime.strptime(LSD, date_format)
except:
return {"status": 0, "error": " 'LSD' format error"}
try:
data = frappe.db.sql('''
select module_name as title, app_menu_id,display_order,
case when active_status = 'Active' Then true else false end as active_status
FROM `tabModule Master` where modified >='';''', as_dict=1)
return {"status": 1, "error": None, 'data': data}
except Exception as e:
frappe.local.response['http_status_code'] = 400
return {"status": 0, "error": e, 'data': None}
@frappe.whitelist(methods=["POST"], allow_guest=1)
def role_mapping():
req = json.loads(frappe.request.data)
try:
lsdt = req['LSD']
if lsdt != '':
try:
datetime.datetime.strptime(lsdt, date_format)
except:
frappe.local.response['http_status_code'] = 400
return {"status": 0, "error": "Invalid date format", 'data': None}
except Exception as e:
frappe.local.response['http_status_code'] = 403
return {"status": 0, "error": e}
data = {}
try:
module_details = frappe.db.sql(f"""select module_name,case when active_status= 'Active' Then true else false end as active_status,
app_menu_id from `tabModule Master`
where modified >= '{lsdt}' order by display_order;""", as_dict=1)
module_details1 = frappe.db.sql(f"""select module_name,0 as active_status,app_menu_id from `tabModule Master`
where modified >= '{lsdt}' order by display_order;""", as_dict=1)
data['module'] = module_details
role_maping_details = frappe.db.sql(f"""SELECT role,skill_id,modules from `tabRole Master`
where modified>='{lsdt}' order by display_order;""", as_dict=1)
for r in role_maping_details:
role_list = r['modules'].split(",")
modules = copy.deepcopy(module_details1)
for m in modules:
if m['module_name'] in role_list:
m['active_status'] = 1
r['modules'] = modules
data['role_mapping'] = role_maping_details
return {"status": 1, "error": None, 'lsdt': utils.now(), "data": data}
except Exception as e:
return {"status": 0, "error": e, 'lsdt': utils.now(), "data": None}

152
smart_service/apis/publish_api.py

@ -20,6 +20,7 @@ base_url = os.path.expanduser(
internal_path = base_url + "/files/json_files/internal/"
global_path = base_url + "/files/json_files/global/"
full_update_path = base_url + "/files/json_files/full_update/"
full_update_path_internal = base_url + "/files/json_files/full_update/internal/"
STATUS = "status"
ERROR = "error"
PARAM_MISSING = "Parameter missing :"
@ -245,8 +246,8 @@ def old_json_grouping(args, language):
final.append(variant_out)
dicfinal = {"JSON": final}
frappe.db.sql(""" UPDATE %s.tabPublish SET publish_status = "%s" where name = "%s" """ % (
current_db_name, "Published", args))
frappe.db.sql(""" UPDATE `tabPublish` SET publish_status = "%s" where name = "%s" """ % (
"Published", args))
frappe.db.commit()
return dicfinal
@ -254,6 +255,7 @@ def old_json_grouping(args, language):
def json_grouping(args, language):
try:
dicfinal = []
frappe.log_error('args' + str(args))
docs_child = frappe.db.get_list("Publish_Docs", filters={"parent": args},
fields=["variant_mapping", "system", "sub_system", "procedure_status",
"procedure_link"])
@ -292,7 +294,7 @@ def json_grouping(args, language):
variant_out = {}
vari = frappe.db.sql("""SELECT name,variant, vehicle,family_code,vehicle_segment,fuel,transmission,drive, active_status
FROM %s.`tabVariant Mapping` WHERE name ="%s" ; """ % (current_db_name, d),
as_dict=True)
as_dict=True)
var_asset = frappe.db.sql(
"""SELECT name,category, attach_file as file, %s FROM %s.`tabVariant Mapping_Assets` where category<>"Technical Manual"
@ -315,8 +317,8 @@ def json_grouping(args, language):
kms_active_status = True
else:
kms_active_status = False
vari.update({"kms_mapping_active_status": kms_active_status})
if kms_mapping_status:
vari.update({"kms_mapping_active_status": kms_active_status})
vari["Assets"] = var_asset
variant_out["Variant"] = vari
@ -404,12 +406,14 @@ def json_grouping(args, language):
final.append(variant_out)
dicfinal = {"JSON": final}
frappe.db.sql(""" UPDATE %s.tabPublish SET publish_status = "%s" where name = "%s" """ % (
current_db_name, "Published", args))
frappe.log_error('dicfinal' + str(dicfinal))
frappe.db.sql(""" UPDATE `tabPublish` SET publish_status = "%s" where name = "%s" """ % (
"Published", args))
frappe.db.commit()
return dicfinal
except Exception as e:
frappe.log_error('JSON Grouping',str(e))
frappe.log_error('JSON Grouping', str(e))
""" New Publish """
@ -431,12 +435,15 @@ def new_publish(args, publish_type, vehicle, language, version):
os.makedirs(global_path + vehicle + "/")
if not os.path.exists(full_update_path + vehicle + "/"):
os.makedirs(full_update_path + vehicle + "/")
if not os.path.exists(full_update_path_internal + vehicle + "/"):
os.makedirs(full_update_path_internal + vehicle + "/")
except Exception as e:
return False, "Failed to create Folders"
""" JSON generation """
json_file = json_grouping(args, language)
frappe.log_error('json grouping' + str(json_file))
file_name = ""
base_file_name = "%s-%s_v%s.json" % (vehicle, language, version)
@ -447,24 +454,29 @@ def new_publish(args, publish_type, vehicle, language, version):
file_name = global_path + vehicle + "/" + base_file_name
else:
return {STATUS: 0, ERROR: "Publish type not available"}
frappe.log_error('created file name' + str(file_name))
""" Save file (Internal/Global) """
with open(file_name, "w") as outfile:
outfile.write(json.dumps(json_file))
get_step_total_count(file_name)
""" Remove previous internal publish file """
if publish_type.lower() == "internal":
for fil in os.listdir(internal_path + vehicle):
file_val = internal_path + vehicle + "/" + fil
if file_val != file_name:
if (fil.split("-")[1]).split("_")[0] == language:
os.remove(file_val)
# """ Remove previous internal publish file """
# if publish_type.lower() == "internal":
# for fil in os.listdir(internal_path + vehicle):
# file_val = internal_path + vehicle + "/" + fil
# if file_val != file_name:
# if (fil.split("-")[1]).split("_")[0] == language:
# os.remove(file_val)
""" Generate full update file """
pub_ver = None
prev_update_ver = None
check_if_global_exist = frappe.db.sql("""SELECT vehicle,language,format(version,2) as version,modified,publish_type FROM tabPublish where vehicle = "{}"
and publish_type = "Global" AND `language` = "{}" and publish_module="Automotive System" order by modified desc limit 1 ;""".format(vehicle, language), as_dict=1)
if publish_type.lower() == "global":
frappe.log_error(str("global"))
full_update_file_name = full_update_path + vehicle + "/" + \
"%s-%s-full_v%s.json" % (vehicle, language, version)
@ -472,37 +484,113 @@ def new_publish(args, publish_type, vehicle, language, version):
with open(full_update_file_name, "w") as outfile:
outfile.write(json.dumps(json_file))
get_step_total_count(full_update_file_name)
file_name1 = file_name
return True, file_name1.split("public")[1]
else:
pub_ver = frappe.db.sql(""" SELECT vehicle,`language`,format(version,2) as version,modified,publish_type FROM tabPublish where vehicle = "{}"
and publish_type = "Global" AND `language` = "{}" order by modified desc limit 2 ;""".format(vehicle, language), as_dict=1)
pub_ver = frappe.db.sql(""" SELECT vehicle,language,format(version,2) as version,modified,publish_type FROM `tabPublish` where vehicle = "{}"
and publish_type = "Global" AND `language` = "{}" and publish_module="Automotive System" order by modified desc;""".format(vehicle, language), as_dict=1)
if pub_ver:
prev_update_ver = pub_ver[1]["version"]
prev_full_update_file = full_update_path + vehicle + "/" + \
"%s-%s-full_v%s.json" % (vehicle,
language, prev_update_ver)
language, prev_update_ver)
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)
set_publish_flag(publish_type, vehicle, language)
if file_flag:
return True, file_name.split("public")[1]
# return True, file_name
else:
return False, "File save issue"
if publish_type.lower() == "internal" and len(check_if_global_exist) > 0:
# frappe.log_error(str('already global published'))
full_update_file_name = full_update_path_internal + vehicle + "/" + \
"%s-%s-full_v%s.json" % (vehicle, language, version)
# frappe.log_error('update file' + str(full_update_file_name))
pub_ver = frappe.db.sql(""" SELECT vehicle,language,format(version,2) as version,modified,publish_type FROM tabPublish where vehicle = "{}"
and `language` = "{}" and publish_module="Automotive System" order by modified desc limit 2 ;""".format(vehicle, language), as_dict=1)
if pub_ver:
# frappe.log_error('inside')
if pub_ver[1]['publish_type'] == 'Internal':
prev_update_ver_internal = float(pub_ver[1]["version"])
# frappe.log_error('version_internal' +
# str(prev_update_ver_internal))
prev_full_internal_update_file = full_update_path_internal + vehicle + "/" + \
"%s-%s-full_v%s.json" % (vehicle,
language, prev_update_ver_internal)
file_flag, final_update_file = merge_json_files(
prev_full_internal_update_file, file_name, full_update_file_name)
get_step_total_count(final_update_file)
set_publish_flag(publish_type, vehicle, language)
if file_flag:
return True, file_name.split("public")[1]
# return True, file_name
else:
return False, "File save issue"
elif pub_ver[1]['publish_type'] == 'Global':
try:
with open(full_update_file_name, "w") as outfile:
outfile.write(json.dumps(json_file))
get_step_total_count(full_update_file_name)
file_name1 = file_name
set_publish_flag(publish_type, vehicle, language)
file_flag = True
except Exception as e:
file_flag = True
if file_flag:
return True, file_name.split("public")[1]
# return True, file_name
else:
return False, "File save issue"
else:
frappe.log_error(str('first time ionternal'))
full_update_file_name = full_update_path_internal + vehicle + "/" + \
"%s-%s-full_v%s.json" % (vehicle, language, version)
if str(version) == "0.01":
frappe.log_error(str('first time ionternal file creation'))
with open(full_update_file_name, "w") as outfile:
outfile.write(json.dumps(json_file))
get_step_total_count(full_update_file_name)
else:
pub_ver = frappe.db.sql(""" SELECT vehicle,language,format(version,2) as version,modified,publish_type FROM tabPublish where vehicle = "{}"
and publish_type = "Internal" AND `language` = "{}" and publish_module="Automotive System" order by modified desc limit 2 ;""".format(vehicle, language), as_dict=1)
if pub_ver:
prev_update_ver = pub_ver[1]["version"]
prev_full_update_file = full_update_path_internal + vehicle + "/" + \
"%s-%s-full_v%s.json" % (vehicle,
language, prev_update_ver)
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)
set_publish_flag(publish_type,vehicle,language)
set_publish_flag(publish_type, vehicle, language)
if file_flag:
return True, file_name.split("public")[1]
# return True, file_name
else:
return False, "File save issue"
set_publish_flag(publish_type,vehicle,language)
set_publish_flag(publish_type, vehicle, language)
frappe.log_error('file_name' + str(file_name))
return True, file_name.split("public")[1]
# return True, file_name
except Exception as e:
# return "Failed to save file"
frappe.log_error("Publish",frappe.get_traceback())
frappe.log_error("Publish", frappe.get_traceback())
return False, str(frappe.get_traceback())
def set_publish_flag(publish_type,vehicle,language):
def set_publish_flag(publish_type, vehicle, language):
try:
if publish_type == 'Internal':
# Update vehicle master field
@ -550,7 +638,7 @@ def set_publish_flag(publish_type,vehicle,language):
frappe.db.commit()
except Exception as e:
frappe.log_error(str(e))
frappe.log_error('set_publish_flag' + str(e))
def merge_json_files(old_json_path, new_json_path, out_file_path):
@ -563,7 +651,8 @@ def merge_json_files(old_json_path, new_json_path, out_file_path):
data_new = json.load(json_file1)
for k in data_new["JSON"]:
old_var_key = check_key(k["Variant"]["name"], data_old["JSON"], "Variant")
old_var_key = check_key(
k["Variant"]["name"], data_old["JSON"], "Variant")
if old_var_key is not None and old_var_key >= 0:
var_dict = {}
var_dict["Variant"] = k["Variant"]
@ -574,7 +663,8 @@ def merge_json_files(old_json_path, new_json_path, out_file_path):
var_dict["Variant"]["Assets"] = data_old["JSON"][old_var_key]["Variant"]["Assets"]
for i in variant_systems:
old_sys_key = check_key(i["sys_id"], var_dict["Variant"]["Systems"], "System")
old_sys_key = check_key(
i["sys_id"], var_dict["Variant"]["Systems"], "System")
if old_sys_key is not None and old_sys_key >= 0:
var_dict["Variant"]["Systems"][old_sys_key]["systemdisplayorder"] = i["systemdisplayorder"]
@ -592,7 +682,8 @@ def merge_json_files(old_json_path, new_json_path, out_file_path):
if old_sub_key is not None and old_sub_key >= 0:
var_dict["Variant"]["Systems"][old_sys_key]["Subsystems"][old_sub_key] = s
else:
var_dict["Variant"]["Systems"][old_sys_key]["Subsystems"].append(s)
var_dict["Variant"]["Systems"][old_sys_key]["Subsystems"].append(
s)
else:
var_dict["Variant"]["Systems"].append(i)
@ -614,7 +705,7 @@ def merge_json_files(old_json_path, new_json_path, out_file_path):
return True, out_file_path
except:
return False, frappe.log_error("Merge JSON:",frappe.get_traceback())
return False, frappe.log_error("Merge JSON:", frappe.get_traceback())
def check_key(key_name, old_data, type=None):
@ -626,21 +717,22 @@ def check_key(key_name, old_data, type=None):
if old_data[d]["Variant"]["name"] == key_name:
return d
except:
frappe.log_error("Check key System:",frappe.get_traceback())
frappe.log_error("Check key System:", frappe.get_traceback())
if type == "System":
try:
if old_data[d]["sys_id"] == key_name:
return d
except:
frappe.log_error("Check key System:",frappe.get_traceback())
frappe.log_error("Check key System:", frappe.get_traceback())
if type == "Sub System":
try:
if old_data[d]["sub_systems"] == key_name:
return d
except:
frappe.log_error("Check key subsystem:",frappe.get_traceback())
frappe.log_error("Check key subsystem:",
frappe.get_traceback())
@frappe.whitelist(allow_guest=True)

941
smart_service/apis/update_validation.py

File diff suppressed because it is too large

177
smart_service/apis/utils.py

@ -0,0 +1,177 @@
import frappe
import os
@frappe.whitelist()
def check_img_ext(path):
if path:
ext = path.split()[-1]
if ext.lower().endswith('.jpg') or ext.lower().endswith('.jpeg'):
return True
else:
return False
else:
return False
@frappe.whitelist()
def check_png_ext(path):
if path:
ext = path.split()[-1]
if ext.lower().endswith('.png'):
return True
else:
return False
else:
return False
@frappe.whitelist()
def check_zip_ext(path):
if path:
ext = path.split()[-1]
if ext.lower().endswith('.zip'):
return True
else:
return False
else:
return False
@frappe.whitelist()
def check_pdf_ext(path):
if path:
ext = path.split()[-1]
if ext.lower().endswith('.pdf'):
return True
else:
return False
else:
return False
@frappe.whitelist()
def check_mp4_ext(path):
if path:
ext = path.split()[-1]
if ext.lower().endswith('.mp4'):
return True
else:
return False
@frappe.whitelist()
def check_html_ext(path):
if path:
ext = path.split()[-1]
if ext.lower().endswith('.html'):
return True
else:
return False
@frappe.whitelist()
def check_ppt_ext(path):
if path:
ext = path.split()[-1]
if ext.lower().endswith('.pptx'):
return True
elif ext.lower().endswith('.pptm'):
return True
elif ext.lower().endswith('.ppt'):
return True
else:
return False
@frappe.whitelist()
def check_web_link(path):
if path.lower().startswith("http:") or path.lower().startswith("https:"):
return True
else:
return False
def details_of_image(image_file):
try:
# Image dimension validation
import os
from PIL import Image
if image_file.startswith('/private/'):
filepath = get_absolute_path(image_file, True)
else:
filepath = get_absolute_path(image_file)
img = Image.open(filepath)
width = img.width
height = img.height
size = os.stat(filepath)
size=size[6]/1024
return width, height,size
except Exception as e:
raise e
def get_file_size(filepath):
if filepath.startswith('/private/'):
file_dir = get_absolute_path(filepath, True)
else:
file_dir = get_absolute_path(filepath)
size_in_bytes = os.path.getsize(file_dir)
size_in_megabytes = size_in_bytes / (1024 * 1024)
return size_in_megabytes
def get_image_size(filepath):
if filepath.startswith('/private/'):
file_dir = get_absolute_path(filepath, True)
else:
file_dir = get_absolute_path(filepath)
size_in_bytes = os.path.getsize(file_dir)
size_in_kilobytes = size_in_bytes / 1024
return size_in_kilobytes
def get_absolute_path(file_name, is_private=False):
try:
if file_name.startswith('/files/'):
file_name = file_name[7:]
else:
file_name = file_name[15:]
return frappe.utils.get_bench_path() + "/sites/" + frappe.utils.get_path('private' if is_private else 'public',
'files', file_name)[2:]
except Exception as e:
frappe.log_error("get_absolute_path", frappe.get_traceback())
def checking_image(file_url, attached_to_doctype, attached_to_field, docname, is_child=None):
try:
import time
time.sleep(1)
if docname.startswith('new'):
image_name = frappe.db.get_list("File", fields={"name"}, filters={"file_url": file_url,
"attached_to_doctype": attached_to_doctype,
"attached_to_field": attached_to_field,
"attached_to_name": docname})
else:
image_name = frappe.db.get_list("File", fields={"name"}, filters={"file_url": file_url,
"attached_to_doctype": attached_to_doctype,
"attached_to_field": attached_to_field})
image_name = frappe.db.sql(f"""select name from `tabFile` where file_url='{file_url}' and attached_to_doctype='{attached_to_doctype}' and
attached_to_field='{attached_to_field}'""",as_dict=1)
# frappe.msgprint("data-"+str(file_url)+"-"+str(attached_to_doctype)+"-"+str(attached_to_field)+"-"+str(docname))
if not attached_to_doctype == "Symbol Scanner" and is_child != 1:
frappe.db.sql(
'''UPDATE `tab{0}` SET {2} = '' where name = "{1}"'''.format(attached_to_doctype, docname,
attached_to_field))
frappe.db.commit()
if attached_to_doctype == "Symbol Scanner":
frappe.db.set_value(
"Symbol Scanner", "Symbol Scanner", attached_to_field, "")
if len(image_name) > 0:
frappe.delete_doc('File', image_name[0]['name'])
return True
except Exception as e:
frappe.log_error("Checking images", frappe.get_traceback())

751
smart_service/apis/v2/master.py

@ -0,0 +1,751 @@
from frappe.utils import cstr
import frappe
import re
from urllib import request
import datetime
from frappe import utils
import json
import html
import os
import shutil
import zipfile
success_reponse = {"status": 1, "data": "", "message": ""}
site_name = cstr(frappe.local.site)
BASE_URL = os.path.expanduser(
"~") + "/frappe-bench/sites/" + site_name + "/public"
# base = os.path.expanduser(
# "~") + "/frappe-bench/sites/" + site_name
date_format = "%Y-%m-%d %H:%M:%S.%f"
current_db_name = frappe.conf.get("db_name")
# style="""<style>
# ul {
# margin: 0.75em 0;
# padding: 0 1em;
# list-style: none;
# }
# li:before {
# content: "";
# border-color: transparent #FF0000;
# border-style: solid;
# border-width: 0.35em 0 0.35em 0.45em;
# display: block;
# height: 0;
# width: 0;
# left: -1em;
# top: 0.9em;
# position: relative;
# }
# </style>"""
@frappe.whitelist(methods=["POST"], allow_guest=1)
def get_role_mapping():
req = json.loads(frappe.request.data)
try:
lsdt = req['lsdt']
if lsdt != '':
try:
datetime.datetime.strptime(lsdt, date_format)
except:
frappe.local.response['http_status_code'] = 400
return {"status": 0, "error": "Invalid date format", 'data': None}
except Exception as e:
frappe.local.response['http_status_code'] = 403
return {"status": 0, "error": e}
data = {}
try:
module_details = frappe.db.sql(f"""select module_name,active_status,my_id,display_order,modified from `tabModule Master`
where modified >= '{lsdt}' order by display_order;""", as_dict=1)
data['module'] = module_details
if lsdt:
role_maping_details = frappe.db.sql(f"""SELECT role,my_id,display_order,modules,active_status,modified from `tabRole Master`
where active_status = 'Active' and modified>='{lsdt}' order by display_order;""", as_dict=1)
else:
role_maping_details = frappe.db.sql(f"""SELECT role,my_id,display_order,modules,active_status,modified from `tabRole Master`
where active_status = 'Active' order by display_order;""", as_dict=1)
data['role_mapping'] = role_maping_details
return {"status": 1, "error": None, 'lsdt': utils.now(), "data": data}
except Exception as e:
return {"status": 0, "error": e, 'lsdt': utils.now(), "data": None}
@frappe.whitelist(methods=["POST"], allow_guest=1)
def get_repair_service_mapping(vehicle, language):
try:
repair_service_details = []
if language == 'en':
repair_service_details = frappe.db.sql(f""" select vehicle,vehicle_id,name,language,check_list_name,active_status,display_order,my_id,keywords from
`tabRepair Service Mapping` where vehicle = '{vehicle}' and language = '{language}'; """, as_dict=1)
else:
repair_service_details = frappe.db.sql(f""" select vehicle,vehicle_id,name,language,translated_check_list_name as check_list_name,active_status,keywords,
display_order,my_id from `tabRepair Service Mapping` where vehicle = '{vehicle}' and
language = '{language}'; """, as_dict=1)
for d in repair_service_details:
d['complaint'] = frappe.db.sql(f""" select complaint,remedial_action_ok,remedial_action_not_ok,idx as display_order from
`tabRepair Service Child` where parent = '{d['name']}' order by display_order ;""", as_dict=1)
return True, repair_service_details
except Exception as e:
return False, e
@frappe.whitelist(methods=["POST"], allow_guest=1)
def get_feature_finder(vehicle, variant, language):
try:
feature_finder_details = []
if language == 'en':
feature_finder_details = frappe.db.sql(f"""select ff.name,ff.vehicle,ff.vehicle_id,ff.variant,ff.variant_id,ff.language,
ff.keywords,ff.sop_name,
ff.features_names as feature_name,ff.feature_category,ff.display_order,ff.active_status,
ffm.feature_pdf as pdf from `tabFeature Finder` ff left join `tabFeature Finder Master` ffm on
ff.features_names = ffm.feature_name
where ff.vehicle = "{vehicle}" and ffm.vehicle = "{vehicle}" and ff.variant = "{variant}"
and ff.language = "{language}" and ffm.language = "{language}";
""", as_dict=1)
else:
feature_finder_details = frappe.db.sql(f"""select ff.name,ff.vehicle,ff.vehicle_id,ff.variant,ff.variant_id,ff.language,
ff.keywords,ff.sop_name,
ff.translated_feature_name as feature_name,ff.feature_category,
ff.display_order,ff.active_status,ffm.feature_pdf as pdf from `tabFeature Finder` ff
left join `tabFeature Finder Master` ffm on ff.features_names = ffm.feature_name
where ff.vehicle = "{vehicle}" and ffm.vehicle = "{vehicle}" and ff.variant = "{variant}"
and ff.language = "{language}"; """, as_dict=1)
for f in feature_finder_details:
f['disclaimer'] = frappe.db.sql(f'''
SELECT name,content,idx as display_order FROM `tabFeature Finder Disclaimer`
where parent = '{str(f['vehicle'])+ str('-')+ str(f['feature_name']) +str('-')+str(f['language'])}'
order by display_order;
''', as_dict=1)
sop_images = frappe.db.sql(f""" select image,idx as display_order from `tabFeature Finder Images` where
parent = '{f['name']}' and feature_type ='SOP' order by display_order;""", as_dict=1)
sop_content = frappe.db.sql(f"""select content,idx as display_order from `tabFeature Finder Content`
where parent = '{f['name']}' and feature_type ='SOP' order by display_order;""", as_dict=1)
sop_specification = frappe.db.sql(f"""select specification,value,idx as display_order from `tabFeature Finder Specification`
where parent = '{f['name']}' and feature_type ='SOP' order by display_order;""", as_dict=1)
f['sop'] = {'content': sop_content, 'images': sop_images,
'specificaton': sop_specification, 'sop_name': f['sop_name']}
post_vin_data = frappe.db.sql(f'''select name,idx as display_order,post_vin_cutoff_name,post_vin_cutoff_id
from `tabPost Vin Cutoff ID` where parent = '{f['name']}' order by display_order;''', as_dict=1)
for p in post_vin_data:
vin_content = frappe.db.sql(f"""select content,idx as display_order from `tabFeature Finder Content`
where parent = '{f['name']}'
and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}'
order by display_order;""", as_dict=1)
vin_images = frappe.db.sql(f""" select image,idx as display_order from `tabFeature Finder Images` where
parent = '{f['name']}' and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}'
order by display_order;""", as_dict=1)
vin_specification = frappe.db.sql(f"""select specification,value,idx as display_order from `tabFeature Finder Specification`
where parent = '{f['name']}' and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}'
order by display_order;""", as_dict=1)
p['content'] = vin_content
p['images'] = vin_images
p['specificaton'] = vin_specification
f['post_vin'] = post_vin_data
return True, feature_finder_details
except Exception as e:
return False, e
@frappe.whitelist(methods=["POST"], allow_guest=1)
def get_training_information(vehicle, language):
try:
training_information = frappe.db.sql(f"""select name,vehicle,category,topic,language,active_status,keywords from`tabTraining Information`
where vehicle = "{vehicle}" and language = "{language}"; """, as_dict=1)
for t in training_information:
t['content'] = frappe.db.sql(f''' select content_type,content,image_video,idx as display_order,active_status from
`tabTraining Information Content Reference` where parent = '{t['name']}';''', as_dict=1)
return True, training_information
except Exception as e:
return False, e
@frappe.whitelist(methods=['POST'], allow_guest=1)
def new_publish_old():
req = json.loads(frappe.request.data)
try:
module = req['module']
iid = req['iid']
vehicle = req['vehicle']
variant = req['variant']
language = req['language']
data = []
if module == 'Feature Finder':
flag, data = get_feature_finder(vehicle, variant, language)
elif module == 'Repair/Service Check Sheet':
flag, data = get_repair_service_mapping(vehicle, language)
elif module == 'QWIK Service':
flag, data = get_qwik_service(variant, language)
CLEANR = re.compile('<.*?>')
CLEANR_back_slash = re.compile("\"")
ul_html = '<ul style="list-style-type: none; padding-left: 0px;"><span style="width: 0;height: 0;border-top: 6px solid transparent;border-left: 8px solid red;border-bottom: 6px solid transparent;position: absolute;margin-top: 3px;"></span>'
li_html = '<li style="margin-left: 15px;padding: 0px 1px 5px 0px;"data-list=\"bullet\">'
cling_li = '</li><span style="width: 0;height: 0;border-top: 6px solid transparent;border-left: 8px solid red;border-bottom: 6px solid transparent;position: absolute;margin-top: 3px;"></span>'
cling_last = '</ul>'
find_last_ul = '<span style="width: 0;height: 0;border-top: 6px solid transparent;border-left: 8px solid red;border-bottom: 6px solid transparent;position: absolute;margin-top: 3px;"></span></ul>'
for dt in data:
if len(dt['consumables']) > 0:
for con in dt['consumables']:
if con['content']:
con['content'] = re.sub(CLEANR, '', con['content'])
# if len(dt['pre_work'])>0:
for pw in dt['pre_work']:
reg_str = "<p>"
reg_str1 = "<div>"
if pw['content']:
res = str(pw['content']).find('<div>')
res1 = str(pw['content']).find('<p>')
if res == 1:
pw['content'] = re.sub(
'<div>', '', pw['content'])
pw['content'] = re.sub(
'</div>', '', pw['content'])
pw['content'] = re.sub(
'<p>', '<div style="color: #fff;margin:0px !important;">', pw['content'])
pw['content'] = re.sub(
'</p>', '</div>', pw['content'])
cnverted_data = re.sub(
CLEANR_back_slash, "'", pw['content'])
pw['content'] = cnverted_data
else:
pw['content'] = '<div style="color: #fff;margin:0px !important;">' + \
pw['content']+'</div>'
cnverted_data = re.sub(
CLEANR_back_slash, "'", pw['content'])
pw['content'] = cnverted_data
if res1 == 1:
pw['content'] = re.sub(
'<div>', '', pw['content'])
pw['content'] = re.sub(
'</div>', '', pw['content'])
pw['content'] = re.sub(
'<p>', '<div style="color: #fff;margin:0px !important;">', pw['content'])
pw['content'] = re.sub(
'</p>', '</div>', pw['content'])
cnverted_data = re.sub(
CLEANR_back_slash, "'", pw['content'])
pw['content'] = cnverted_data
else:
pw['content'] = '<div style="color: #fff;margin:0px !important;">' + \
pw['content']+'</div>'
cnverted_data = re.sub(
CLEANR_back_slash, "'", pw['content'])
pw['content'] = cnverted_data
if dt['qwik_procedure']:
for qp in dt['qwik_procedure']['LHS']:
if qp['content']:
qp['content'] = re.sub(
'<ul>', ul_html, qp['content'])
qp['content'] = re.sub(
'<li data-list="bullet">', li_html, qp['content'])
clsing_li_tag = re.sub(
'</li>', cling_li, qp['content'])
qp['content'] = clsing_li_tag
res = re.sub(
find_last_ul, cling_last, qp['content'])
qp['content'] = res
cnverted_data = re.sub(
CLEANR_back_slash, "'", qp['content'])
qp['content'] = cnverted_data
for qp_rhs in dt['qwik_procedure']['RHS']:
if qp_rhs:
qp_rhs['content'] = re.sub(
'<ul>', ul_html, qp_rhs['content'])
qp_rhs['content'] = re.sub(
'<li data-list="bullet">', li_html, qp_rhs['content'])
qp_rhs['content'] = re.sub(
'</li>', cling_li, qp_rhs['content'])
qp_rhs['content'] = re.sub(
find_last_ul, cling_last, qp_rhs['content'])
cnverted_data = re.sub(
CLEANR_back_slash, "'", qp_rhs['content'])
qp_rhs['content'] = cnverted_data
elif module == 'Training Information':
base_path = BASE_URL + "/" + "training" + "/" + vehicle
scrom_path = base_path + "/" + "scrom"
# html_path = base_path +"/"+ "/html"
flag, data = get_training_information(vehicle, language)
# for d in data:
# if d['content']:
# for ch in d['content']:
# if ch['topic'] == 'SCROM' and ch['content']!=None:
# scrom_folder_path = base_path +"/"+ "scrom" + "/" + ch['content'].split("/")[2].split(".")[0]
# if not os.path.exists(scrom_folder_path):
# os.makedirs(scrom_folder_path)
# if ch['content']:
# frappe.log_error(str(ch['content']))
# with zipfile.ZipFile(BASE_URL+ch['content'], 'r') as zip_ref:
# zip_ref.extractall(path=scrom_folder_path)
# ch['content'] = scrom_folder_path + ch['content'].split("/")[2].split(".")[0]
# cont=frappe.db.sql('''select content from `tabTraining Information Content Reference` where parent = %s and topic = 'SCROM' '''%(d['name']),as_dict=1)
elif module == 'Mahindra Special Tool Information':
CLEANR_back_slash = re.compile("\"")
html_code_ul = '<ul style="list-style-type: none; padding-left: 0px;"><span style="width: 0;height: 0;border-top: 6px solid transparent;border-left: 8px solid red;border-bottom: 6px solid transparent;position: absolute;margin-top: 3px;"></span>'
html_code_li = '<li style="margin-left: 15px;padding: 0px 1px 5px 0px;"data-list="bullet">'
flag, data = get_special_tool_information(vehicle)
for dt in data:
if len(dt['instructions']) > 0:
for c_t in dt['instructions']:
if c_t['content_type'] == 'Description':
if c_t['content']:
c_t['content'] = html_code_ul + \
html_code_li+c_t['content']+'</li>'+'</ul>'
cnverted_data = re.sub(
CLEANR_back_slash, "'", c_t['content'])
c_t['content'] = cnverted_data
elif module == 'PDI Inspection':
pass
elif module == 'Torque Information':
flag, data = get_torque_information(variant, language)
else:
flag = False
data = 'No Module found'
if flag:
return {'status': 1, 'error': None, 'data': data}
else:
return {'status': 0, 'error': data, 'data': None}
except Exception as e:
frappe.local.response['http_status_code'] = 400
return {'status': 0, 'error': "Parameter's missing: " + str(e), 'data': None}
@frappe.whitelist(methods=['POST'], allow_guest=1)
def new_publish():
req = json.loads(frappe.request.data)
try:
module = req['module']
iid = req['iid']
vehicle_name = req['vehicle']
vehicle = req['vehicle'].replace(' ','-')
variant = req['variant']
language = req['language']
val = input_validation(req)
# if val != '' or val != "":
# return {"status": 0, "error": "Input parameter Missing: " + val}
data = []
# Get Publish Type
publish_type = frappe.db.get_list(
'App Device', filters={'name': iid}, fields='publish_type')
if len(publish_type) > 0:
publish_type = publish_type[0]['publish_type']
else:
return {"status": 0, "error": "Publish Type Not Set For: " + iid,"data":None}
BASE_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + str(publish_type) + '/'
if module == 'Feature Finder':
FULL_UPDATE_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + \
"{}".format(publish_type)+"_Full_Update/"
FULL_UPDATE_PATH_FILE = FULL_UPDATE_PATH + \
vehicle.replace(' ', '-') + \
'-feature_finder_full_update' + '.json'
LATEST_GLOBAL_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + \
'/' + "Global_Full_Update/"
LATEST_GLOBAL_FILE = LATEST_GLOBAL_PATH + \
vehicle.replace(' ', '-') + \
'-feature_finder_full_update' + '.json'
# if publish_type == 'Internal':
if os.path.isfile(FULL_UPDATE_PATH_FILE):
with open(FULL_UPDATE_PATH_FILE) as outfile:
data = json.load(outfile)
# data = data['data']
# filter_json = filter_publish_json(data, variant)
# data = filter_json
data = data.get('data')
data = data.get(variant)
elif os.path.isfile(LATEST_GLOBAL_FILE):
with open(LATEST_GLOBAL_FILE) as outfile:
data = json.load(outfile)
data = data.get('data')
data = data.get(variant)
else:
frappe.local.response['http_status_code'] = 200
return {'status': 0, 'error':"No Data Published", 'data':None }
elif module == 'Repair/Service Check Sheet':
FULL_UPDATE_FOLDER = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + \
"{}".format(publish_type)+"/"
FULL_UPDATE_PATH_FILE = FULL_UPDATE_FOLDER + \
vehicle.replace(' ', '-') + '-repair_check_sheet.json'
LATEST_GLOBAL_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + "Global/"
LATEST_GLOBAL_FILE = LATEST_GLOBAL_PATH + \
vehicle.replace(' ', '-') + '-repair_check_sheet.json'
if os.path.isfile(FULL_UPDATE_PATH_FILE):
with open(FULL_UPDATE_PATH_FILE) as outfile:
data = json.load(outfile)
data = data.get('data')
# data = data.get(variant)
elif os.path.isfile(LATEST_GLOBAL_FILE):
with open(LATEST_GLOBAL_FILE) as outfile:
data = json.load(outfile)
data = data.get('data')
else:
frappe.local.response['http_status_code'] = 200
return {'status': 0, 'error': "No Data Published", 'data':None }
elif module == 'QWIK Service':
FULL_UPDATE_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + \
"{}".format(publish_type)+"_Full_Update/"
FULL_UPDATE_PATH_FILE = FULL_UPDATE_PATH + \
vehicle.replace(' ', '-') + '-qwik_service_full_update.json'
LATEST_GLOBAL_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + \
'/' + "Global_Full_Update/"
LATEST_GLOBAL_FILE = LATEST_GLOBAL_PATH + \
vehicle.replace(' ', '-') + '-qwik_service_full_update.json'
# if publish_type == 'Internal':
if os.path.isfile(FULL_UPDATE_PATH_FILE):
with open(FULL_UPDATE_PATH_FILE) as outfile:
data = json.load(outfile)
# data = data['data']
# filter_json = filter_publish_json(data, variant)
# data = filter_json
data = data.get('data')
data = data.get(variant)
elif os.path.isfile(LATEST_GLOBAL_FILE):
with open(LATEST_GLOBAL_FILE) as outfile:
data = json.load(outfile)
# data = data['data']
# filter_json = filter_publish_json(data, variant)
# data = filter_json
data = data.get('data')
data = data.get(variant)
else:
frappe.local.response['http_status_code'] = 200
return {'status': 0, 'error': "No Data Published", 'data':None }
elif module == 'Training Information':
FULL_UPDATE_FOLDER = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + \
"{}".format(publish_type)+"/"
FULL_UPDATE_PATH_FILE = FULL_UPDATE_FOLDER + \
vehicle.replace(' ', '-') + '-training_information.json'
LATEST_GLOBAL_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + "Global/"
LATEST_GLOBAL_FILE = LATEST_GLOBAL_PATH + \
vehicle.replace(' ', '-') + '-training_information.json'
if os.path.isfile(FULL_UPDATE_PATH_FILE):
with open(FULL_UPDATE_PATH_FILE) as outfile:
data = json.load(outfile)
data = data.get('data')
elif os.path.isfile(LATEST_GLOBAL_FILE):
with open(LATEST_GLOBAL_FILE) as outfile:
data = json.load(outfile)
data = data.get('data')
else:
frappe.local.response['http_status_code'] = 200
return {'status': 0, 'error': "No Data Published", 'data':None }
elif module == 'Mahindra Special Tool Information':
FULL_UPDATE_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + \
"{}".format(publish_type)+"_Full_Update/"
FULL_UPDATE_PATH_FILE = FULL_UPDATE_PATH + \
vehicle.replace(' ', '-') + '-special_tool.json'
LATEST_GLOBAL_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + "Global_Full_Update/"
LATEST_GLOBAL_FILE = LATEST_GLOBAL_PATH + \
vehicle.replace(' ', '-') + '-special_tool.json'
if os.path.isfile(FULL_UPDATE_PATH_FILE):
with open(FULL_UPDATE_PATH_FILE) as outfile:
data = json.load(outfile)
data = data.get('data')
elif os.path.isfile(LATEST_GLOBAL_FILE):
with open(LATEST_GLOBAL_FILE) as outfile:
data = json.load(outfile)
data = data.get('data')
else:
frappe.local.response['http_status_code'] = 200
return {'status': 0, 'error': "No Data Published", 'data':None }
elif module == 'PDI Inspection':
pass
elif module == 'Torque Manual':
FULL_UPDATE_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + \
"{}".format(publish_type)+"_Full_Update/"
FULL_UPDATE_PATH_FILE = FULL_UPDATE_PATH + \
vehicle.replace(' ', '-') + '-torque_manual_full_update.json'
LATEST_GLOBAL_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + \
'/' + "Global_Full_Update/"
LATEST_GLOBAL_FILE = LATEST_GLOBAL_PATH + \
vehicle.replace(' ', '-') + '-torque_manual_full_update.json'
if os.path.isfile(FULL_UPDATE_PATH_FILE):
with open(FULL_UPDATE_PATH_FILE) as outfile:
data = json.load(outfile)
data = data.get('data')
data = data.get(variant)
elif os.path.isfile(LATEST_GLOBAL_FILE):
with open(LATEST_GLOBAL_FILE) as outfile:
data = json.load(outfile)
data = data.get('data')
data = data.get(variant)
else:
frappe.local.response['http_status_code'] = 200
return {'status': 0, 'error': "No Data Published", 'data':None }
frappe.log_error(str(vehicle_name))
torque_column_mapping = frappe.db.sql(
f'''select idx as display_order, concat('col',idx) as column_id,column_name from `tabTorque Column Mapping` where parent = "{vehicle_name}" order by idx; ''', as_dict=1)
data = {'torque_manual_mapping': torque_column_mapping,
'torque_manual_data': data}
return {'status': 1, 'error': None, 'data': data}
except Exception as e:
frappe.local.response['http_status_code'] = 400
return {'status': 0, 'error': str(e), 'data': None}
@frappe.whitelist(methods=['POST'], allow_guest=1)
def get_special_tool_information(vehicle):
try:
special_tool_information = frappe.db.sql('''select name,vehicle,tool_type,category,aggregate_name,tool_name,aggregate_image as 'tool_image',
pdf,image,video,keywords,display_order,category_display_order,my_id,active_status from `tabSpecial Tool Information`
where vehicle= '%s' ;''' % (vehicle), as_dict=1)
for s in special_tool_information:
s['instructions'] = frappe.db.sql('''select idx as 'display_order',step_name, content_type, content,attach_file,title
from `tabInstructions` where parent = '%s' order by display_order;''' % (s['name']), as_dict=1)
return True, special_tool_information
except Exception as e:
return False, e
# @frappe.whitelist(methods=['POST'], allow_guest=1)
def get_qwik_service(variant, language):
try:
qwik_service_details = frappe.db.sql('''select name,variant,vehicle,kilometers,language,service_time,active_status,
pdf,display_order,keywords,my_id from `tabQwik Service` where variant='%s' &&
language='%s';''' % (variant, language), as_dict=1)
for q in qwik_service_details:
q['pre_work'] = frappe.db.sql('''select idx as 'display_order', content from `tabQwik Service Content` where parent='%s'
&& content_type = 'Pre-work' order by display_order;''' % (q['name']), as_dict=1)
q['consumables'] = frappe.db.sql('''select idx as 'display_order', content from `tabQwik Service Content` where
parent='%s' && content_type = 'Consumables' order by display_order;''' % (q['name']), as_dict=1)
q['tools'] = frappe.db.sql('''select idx as 'display_order', content from `tabQwik Service Content` where
parent='%s' && content_type = 'Tools' order by display_order;''' % (q['name']), as_dict=1)
for p in qwik_service_details:
LHS = frappe.db.sql('''select idx as 'display_order',side,level,content from `tabQwik Procedure`
where parent ='%s' and side = 'LHS';''' % (p['name']), as_dict=1)
RHS = frappe.db.sql('''select idx as 'display_order',side,level,content from `tabQwik Procedure`
where parent ='%s' and side = 'RHS';''' % (p['name']), as_dict=1)
p['qwik_procedure'] = {'LHS': LHS, 'RHS': RHS}
return True, qwik_service_details
except Exception as e:
return False, e
@frappe.whitelist(methods=["POST"], allow_guest=1)
def get_torque_information(variant, language):
try:
torque_manual_details = frappe.db.sql('''select name,variant,vehicle,language,active_status,category,sub_category,display_order,keywords,my_id
from `tabTorque Manual` where variant ='%s' && language= '%s';''' % (variant, language), as_dict=1)
frappe
for t in torque_manual_details:
t['torque_table'] = frappe.db.sql('''select name,idx as display_order from
`tabTorque Manual Details` where parent = '%s' order by idx;''' % (t['name']), as_dict=1)
for d in t['torque_table']:
torque_data = frappe.db.sql('''select col1,col2,col3,col4,col5,col6,col7,col8,col9,col10 from
`tabTorque Manual Details` where name = '%s' order by idx;''' % (d['name']), as_dict=1)
# return torque_data
tor_list = []
for i in torque_data:
for k, v in i.items():
tor_list.append({'column_title': k, 'column_value': v})
d['torque_data'] = tor_list
success_reponse['data'] = torque_manual_details
return success_reponse
except Exception as e:
return False, e
@frappe.whitelist(methods=["POST"], allow_guest=1)
def get_training_information(vehicle, language):
try:
training_information_details = frappe.db.sql('''select name,vehicle,category,display_order,active_status,my_id,keywords from
`tabTraining Information` where vehicle = '%s' && language = '%s';''' % (vehicle, language), as_dict=1)
for i in training_information_details:
i['content'] = frappe.db.sql('''select idx as 'display_order',topic as file_type,file_url,file_name,scrom_file_url from `tabTraining Information Content Reference`
where parent = '%s' order by display_order;''' % (i['name']), as_dict=1)
return True, training_information_details
except Exception as e:
raise e
# @frappe.whitelist(allow_guest=1)
# def test_html(vehicle):
# base_path = BASE_URL + "/" + "/training" +"/"+ vehicle
# # Folder creation
# scrom_path = base_path +"/"+ "/scrom"
# html_path = base_path +"/"+ "/html"
# try:
# # if not os.path.exists(base_path):
# # os.makedirs(base_path)
# if not os.path.exists(scrom_path):
# os.makedirs(scrom_path)
# if not os.path.exists(html_path):
# os.makedirs(html_path)
# # Create zip file
# # try:
# # if path:
# # ext = path.split()[-1]
# # if ext.lower().endswith('.zip'):
# # shutil.unpack_archive(scrom_path, 'zip', base_path)
# # if path:
# # ext = path.split()[-1]
# # if ext.lower().endswith('.html'):
# # shutil.unpack_archive(html_path, 'html', base_path)
# # except:
# # return False, "Failed to create file"
# except Exception as e:
# return e
# @frappe.whitelist()
# def unzip_package(file_path):
# old_path = BASE_URL + file_path
# new_path = BASE_URL + "/training_information"
# shutil.unpack_archive(old_path, new_path)
@frappe.whitelist(allow_guest=1)
def update_publish_mapping(vehicle, variant, language, module):
frappe.set_user('Administrator')
pub_data = frappe.db.get_list('Module Publish Mapping', filters={
"vehicle": vehicle,
"variant": variant,
"language": language
}, fields=['name'])
if pub_data:
doc = frappe.get_doc('Module Publish Mapping', pub_data[0]['name'])
else:
doc = frappe.get_doc({
'doctype': 'Module Publish Mapping',
"vehicle": vehicle,
"variant": variant,
"language": language
})
if module == 'Automotive System':
doc.automotive_system = 1
doc.tsb = 1
doc.fsa = 1
doc.tekalert = 1
elif module == 'Feature Finder':
doc.feature_finder = 1
elif module == 'Repair service':
doc.repairservice_check_sheet = 1
doc.save()
return 1
def filter_publish_json(src_json, filter_cond):
try:
filtered_json = [src_json.get(filter_cond, None) for d in src_json]
return filtered_json[0]
except Exception as e:
frappe.throw("fil", str(e))
def input_validation(req):
sts = ""
i = 0
for key, value in req.items():
if value is None or value == "" or value == '':
if i != 0:
sts += ','
sts += str(key) + ""
i += 1
return sts
@frappe.whitelist()
def get_published_data():
data = frappe.db.sql("""select vehicle,variant,language,publish_type from `tabPublish` where not in (select vehicle,variant,language,publish_type from
`tabModule Publish Mapping`)""", as_dict=1)
return data

137
smart_service/apis/v2/phase2_test_publish.py

@ -0,0 +1,137 @@
import frappe
import re
from urllib import request
import datetime
from frappe import utils
import json
import html
import os
from frappe.utils import logger
from frappe.utils import cstr
frappe.utils.logger.set_log_level("DEBUG")
site_name = cstr(frappe.local.site)
BASE_URL = os.path.expanduser(
"~") + "/frappe-bench/sites/" + site_name + "/public"
date_format = "%Y-%m-%d %H:%M:%S.%f"
current_db_name = frappe.conf.get("db_name")
@frappe.whitelist(allow_guest = 1,methods = ['POST'])
def repair_checksheet_publish(vehicle = None, language = None
, publish_type = None , parent = None):
try:
req = json.loads(frappe.request.data)
logger_file = f'{vehicle} - {language} - {publish_type} - repair checksheet'
logger = frappe.logger(logger_file, allow_site=True, file_count=100)
logger.info(
f'Repair Checksheet Started-{vehicle}-{language}-{publish_type}-{parent}')
folder_url = base_url+"/"+vehicle.replace(' ', '-')+"-TEST" + "/"+language
logger.info(f'Created Folder-{vehicle}-{language}-{publish_type}')
'''Publish Ready Flags'''
publish_repair_checksheet = 0
repair_checksheet_tmp = []
'''Create Folder For Publish'''
create_publish_folders(folder_url)
file_path = folder_url + "/" + publish_type + "/" + \
vehicle.replace(' ', '-') + '-repair_check_sheet' + '.json'
full_update_path = folder_url + "/" + publish_type + "/" + \
vehicle.replace(' ', '-') + '-repair_check_sheet_full_update' + '.json'
'''Append Published Data to Json'''
logger.info(
f'Repair Checksheet Data Append Start::{vehicle}-{language}-{publish_type}')
vehicle_data = {
'vehicle': vehicle,
'vehicle_myid': vehicle_id,
'publish_type': publish_type,
'publish_description': release_description,
'publish_language': language,
'data': ''
}
'''update existing global json file'''
if os.path.isfile(file_path):
with open(file_path) as f:
published_data = json.load(f)
for i in parent:
repair_checksheet = repair_checksheet_data(vehicle, language,
publish_type, i.parent_name)
if repair_checksheet['status'] == 1:
publish_repair_checksheet = 1
repair_checksheet_tmp.append(
repair_checksheet['data'][0])
repair_checksheet_tmp = get_latest_data({'data': published_data['data']}, {
'data': repair_checksheet_tmp})
else:
for i in parent.repiar_checksheet_publish_docs:
repair_checksheet = repair_checksheet_data(
vehicle, language, publish_type, i.parent_name)
if repair_checksheet['status'] == 1:
publish_repair_checksheet = 1
if len(repair_checksheet['data']):
repair_checksheet_tmp.append(
repair_checksheet['data'][0])
repair_checksheet_tmp = get_latest_data(
{'data': repair_checksheet_tmp}, {'data': []})
if publish_repair_checksheet == 1:
""" Save publish file """
vehicle_data['data'] = repair_checksheet_tmp
with open(file_path, 'w') as outfile:
outfile.write(json.dumps(vehicle_data, indent=4, default=str))
return 1, file_path
except Exception as e:
logger.info(
f'{vehicle} - {language} - {publish_type} error in json creation' + str(e))
frappe.throw('Failed To Publish')
def repair_checksheet_data(vehicle=None, language=None,
publish_type=None, parent=None):
try:
logger_file = f'{vehicle} - {language} - {publish_type} - repair_checksheet_data'
logger = frappe.logger(logger_file,
allow_site=True, file_count=100)
logger.info(
f"start of fetching repair checksheet data - {vehicle} - {language}")
repair_service_details = frappe.db.sql(f"""select vehicle,vehicle_id,
name,language,check_list_name,
keywords,
active_status,display_order,my_id
from `tabRepair Service Mapping`
where vehicle = '{vehicle}'
and language = '{language}'
and name = '{parent}'""", as_dict=1)
for d in repair_service_details:
d['complaint'] = frappe.db.sql(f"""select complaint,remedial_action_ok,
remedial_action_not_ok,idx as display_order from `tabRepair Service Child`
where parent = '{d['name']}'
order by display_order ;""", as_dict=1)
logger.info(
f"end of fetching repair checksheet data {vehicle} - {language}")
success_reponse['data'] = repair_service_details
success_reponse[
'message'] = f'Repair Checksheet Fecthed Succesfully for {vehicle} - {language} - repair_checksheet_data '
return success_reponse
except Exception as e:
failure_reponse['error'] = f"{vehicle} - {language} has following error - " + str(
e)
logger.error('error in repair checksheet' + str(e))
return failure_reponse

3289
smart_service/fixtures/custom_docperm.json

File diff suppressed because it is too large

93
smart_service/fixtures/dashboard_chart.json

@ -17,7 +17,7 @@
"heatmap_year": null,
"is_public": 1,
"is_standard": 0,
"last_synced_on": "2023-02-08 09:55:09.460016",
"last_synced_on": "2023-10-06 16:38:08.651965",
"modified": "2022-03-28 14:33:10.648848",
"module": null,
"name": "Variant mapping",
@ -27,6 +27,7 @@
"parentfield": null,
"parenttype": null,
"report_name": null,
"roles": [],
"source": "",
"time_interval": "Yearly",
"timeseries": 0,
@ -66,6 +67,7 @@
"parentfield": null,
"parenttype": null,
"report_name": null,
"roles": [],
"source": "",
"time_interval": "Yearly",
"timeseries": 0,
@ -80,31 +82,32 @@
{
"aggregate_function_based_on": null,
"based_on": "",
"chart_name": "Publish",
"chart_name": "Procedure",
"chart_type": "Group By",
"color": "#7cbcf7",
"color": "#d6260f",
"custom_options": null,
"docstatus": 0,
"doctype": "Dashboard Chart",
"document_type": "Publish",
"document_type": "Procedure",
"dynamic_filters_json": "[]",
"filters_json": "[[\"Publish\",\"publish_type\",\"=\",null,false]]",
"filters_json": "[[\"Procedure\",\"workflow_state\",\"=\",null,false]]",
"from_date": null,
"group_by_based_on": "vehicle",
"group_by_based_on": "workflow_state",
"group_by_type": "Count",
"heatmap_year": null,
"is_public": 1,
"is_standard": 0,
"last_synced_on": "2022-11-07 15:36:06.864894",
"modified": "2022-04-21 10:00:30.763417",
"last_synced_on": "2023-09-29 11:53:18.864218",
"modified": "2022-04-12 19:59:36.324953",
"module": null,
"name": "Publish",
"name": "Procedure",
"number_of_groups": 0,
"parent": null,
"parent_document_type": "",
"parentfield": null,
"parenttype": null,
"report_name": null,
"roles": [],
"source": "",
"time_interval": "Yearly",
"timeseries": 0,
@ -134,7 +137,7 @@
"heatmap_year": null,
"is_public": 1,
"is_standard": 0,
"last_synced_on": "2022-11-07 15:36:06.930763",
"last_synced_on": "2023-09-29 11:53:19.260681",
"modified": "2022-04-11 18:23:00.494268",
"module": null,
"name": "Publish Status",
@ -144,6 +147,7 @@
"parentfield": null,
"parenttype": null,
"report_name": null,
"roles": [],
"source": "",
"time_interval": "Yearly",
"timeseries": 0,
@ -158,31 +162,32 @@
{
"aggregate_function_based_on": null,
"based_on": "",
"chart_name": "Procedure",
"chart_name": "KM Mapping",
"chart_type": "Group By",
"color": "#d6260f",
"color": "#449CF0",
"custom_options": null,
"docstatus": 0,
"doctype": "Dashboard Chart",
"document_type": "Procedure",
"document_type": "Kilometer Mapping",
"dynamic_filters_json": "[]",
"filters_json": "[[\"Procedure\",\"workflow_state\",\"=\",null,false]]",
"filters_json": "[[\"Kilometer Mapping\",\"workflow_state\",\"=\",null,false]]",
"from_date": null,
"group_by_based_on": "workflow_state",
"group_by_type": "Count",
"heatmap_year": null,
"is_public": 1,
"is_standard": 0,
"last_synced_on": "2022-11-07 15:36:06.728398",
"modified": "2022-04-12 19:59:36.324953",
"last_synced_on": "2023-09-29 11:53:18.941024",
"modified": "2022-05-10 13:05:25.011604",
"module": null,
"name": "Procedure",
"name": "KM Mapping",
"number_of_groups": 0,
"parent": null,
"parent_document_type": "",
"parentfield": null,
"parenttype": null,
"report_name": null,
"roles": [],
"source": "",
"time_interval": "Yearly",
"timeseries": 0,
@ -196,38 +201,39 @@
},
{
"aggregate_function_based_on": null,
"based_on": "creation",
"chart_name": "Test",
"chart_type": "Count",
"color": "#CB2929",
"based_on": "",
"chart_name": "Publish",
"chart_type": "Group By",
"color": "#7cbcf7",
"custom_options": null,
"docstatus": 0,
"doctype": "Dashboard Chart",
"document_type": "App Device",
"document_type": "Publish",
"dynamic_filters_json": "[]",
"filters_json": "[]",
"filters_json": "[[\"Publish\",\"publish_type\",\"=\",null,false]]",
"from_date": null,
"group_by_based_on": null,
"group_by_based_on": "vehicle",
"group_by_type": "Count",
"heatmap_year": null,
"is_public": 0,
"is_public": 1,
"is_standard": 0,
"last_synced_on": null,
"modified": "2022-05-11 11:06:15.280730",
"last_synced_on": "2023-09-29 11:53:18.864593",
"modified": "2022-04-21 10:00:30.763417",
"module": null,
"name": "Test",
"name": "Publish",
"number_of_groups": 0,
"parent": null,
"parent_document_type": "",
"parentfield": null,
"parenttype": null,
"report_name": null,
"roles": [],
"source": "",
"time_interval": "Yearly",
"timeseries": 1,
"timeseries": 0,
"timespan": "Last Year",
"to_date": null,
"type": "Line",
"type": "Bar",
"use_report_chart": 0,
"value_based_on": "",
"x_field": null,
@ -235,38 +241,39 @@
},
{
"aggregate_function_based_on": null,
"based_on": "",
"chart_name": "KM Mapping",
"chart_type": "Group By",
"color": "#449CF0",
"based_on": "creation",
"chart_name": "Test",
"chart_type": "Count",
"color": "#CB2929",
"custom_options": null,
"docstatus": 0,
"doctype": "Dashboard Chart",
"document_type": "Kilometer Mapping",
"document_type": "App Device",
"dynamic_filters_json": "[]",
"filters_json": "[[\"Kilometer Mapping\",\"workflow_state\",\"=\",null,false]]",
"filters_json": "[]",
"from_date": null,
"group_by_based_on": "workflow_state",
"group_by_based_on": null,
"group_by_type": "Count",
"heatmap_year": null,
"is_public": 1,
"is_public": 0,
"is_standard": 0,
"last_synced_on": "2022-11-07 15:36:06.500997",
"modified": "2022-05-10 13:05:25.011604",
"last_synced_on": null,
"modified": "2022-05-11 11:06:15.280730",
"module": null,
"name": "KM Mapping",
"name": "Test",
"number_of_groups": 0,
"parent": null,
"parent_document_type": "",
"parentfield": null,
"parenttype": null,
"report_name": null,
"roles": [],
"source": "",
"time_interval": "Yearly",
"timeseries": 0,
"timeseries": 1,
"timespan": "Last Year",
"to_date": null,
"type": "Bar",
"type": "Line",
"use_report_chart": 0,
"value_based_on": "",
"x_field": null,

618
smart_service/fixtures/property_setter.json

@ -815,23 +815,6 @@
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Procedure",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "active_status",
"modified": "2022-05-11 19:03:25.700743",
"name": "Procedure-active_status-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Procedure",
@ -1004,37 +987,54 @@
},
{
"default_value": null,
"doc_type": "App Labels",
"doc_type": "Variant",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "lft",
"modified": "2022-05-11 16:41:00.964578",
"name": "App Labels-lft-in_list_view",
"field_name": "variant",
"modified": "2022-05-12 17:24:41.980130",
"name": "Variant-variant-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "0"
"value": "1"
},
{
"default_value": null,
"doc_type": "App Labels",
"doc_type": "Variant",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "rgt",
"modified": "2022-05-11 16:41:08.907393",
"name": "App Labels-rgt-in_list_view",
"field_name": "vehicle",
"modified": "2022-05-12 17:24:41.996262",
"name": "Variant-vehicle-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "0"
"value": "1"
},
{
"default_value": null,
"doc_type": "Variant",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "vehicle_segment",
"modified": "2022-05-12 17:24:42.012068",
"name": "Variant-vehicle_segment-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
@ -1172,6 +1172,23 @@
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Variant",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "myid",
"modified": "2022-05-12 17:24:42.026438",
"name": "Variant-myid-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "App Labels",
@ -1257,6 +1274,23 @@
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Kilometer Mapping",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "variant_mapping",
"modified": "2022-05-12 17:28:54.921315",
"name": "Kilometer Mapping-variant_mapping-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Kilometer Mapping",
@ -1767,6 +1801,23 @@
"row_name": null,
"value": "0"
},
{
"default_value": null,
"doc_type": "Kilometer Mapping",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "vehicle",
"modified": "2022-05-12 17:28:54.935877",
"name": "Kilometer Mapping-vehicle-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Kilometer Mapping",
@ -1784,6 +1835,23 @@
"row_name": null,
"value": "0"
},
{
"default_value": null,
"doc_type": "Kilometer Mapping",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "kilometer_filter",
"modified": "2022-05-12 17:11:23.510135",
"name": "Kilometer Mapping-kilometer_filter-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "0"
},
{
"default_value": null,
"doc_type": "System Mapping",
@ -1886,6 +1954,23 @@
"row_name": null,
"value": "0"
},
{
"default_value": null,
"doc_type": "Kilometer Mapping",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "language",
"modified": "2022-05-12 17:28:54.948287",
"name": "Kilometer Mapping-language-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Sub Systems",
@ -1990,13 +2075,13 @@
},
{
"default_value": null,
"doc_type": "Variant",
"doc_type": "Report",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "variant",
"modified": "2022-05-12 17:24:41.980130",
"name": "Variant-variant-in_list_view",
"field_name": "ref_doctype",
"modified": "2022-05-17 14:52:06.272839",
"name": "Report-ref_doctype-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
@ -2007,13 +2092,13 @@
},
{
"default_value": null,
"doc_type": "Variant",
"doc_type": "Report",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "vehicle",
"modified": "2022-05-12 17:24:41.996262",
"name": "Variant-vehicle-in_list_view",
"field_name": "is_standard",
"modified": "2022-05-17 14:52:06.344189",
"name": "Report-is_standard-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
@ -2024,13 +2109,13 @@
},
{
"default_value": null,
"doc_type": "Variant",
"doc_type": "Report",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "vehicle_segment",
"modified": "2022-05-12 17:24:42.012068",
"name": "Variant-vehicle_segment-in_list_view",
"field_name": "module",
"modified": "2022-05-17 14:52:06.383416",
"name": "Report-module-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
@ -2041,115 +2126,115 @@
},
{
"default_value": null,
"doc_type": "Variant",
"doc_type": "Translation",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "myid",
"modified": "2022-05-12 17:24:42.026438",
"name": "Variant-myid-in_list_view",
"field_name": "language",
"modified": "2022-07-06 12:39:54.489733",
"name": "Translation-language-options",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"property": "options",
"property_type": "Link",
"row_name": null,
"value": "1"
"value": "Custom Languages"
},
{
"default_value": null,
"doc_type": "Kilometer Mapping",
"doc_type": "Notification Log",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "variant_mapping",
"modified": "2022-05-12 17:28:54.921315",
"name": "Kilometer Mapping-variant_mapping-in_list_view",
"field_name": "document_name",
"modified": "2022-07-28 13:56:54.746831",
"name": "Notification Log-document_name-length",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"property": "length",
"property_type": "Int",
"row_name": null,
"value": "1"
"value": "255"
},
{
"default_value": null,
"doc_type": "Kilometer Mapping",
"doc_type": "Web Form",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "vehicle",
"modified": "2022-05-12 17:28:54.935877",
"name": "Kilometer Mapping-vehicle-in_list_view",
"field_name": "title",
"modified": "2022-07-28 13:56:57.410645",
"name": "Web Form-title-default",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"property": "default",
"property_type": "Text",
"row_name": null,
"value": "1"
"value": "{doc_type} - {introduction_text}"
},
{
"default_value": null,
"doc_type": "Kilometer Mapping",
"doc_type": "Data Import",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "kilometer_filter",
"modified": "2022-05-12 17:11:23.510135",
"name": "Kilometer Mapping-kilometer_filter-in_list_view",
"field_name": "html_5",
"modified": "2022-08-04 11:12:18.733019",
"name": "Data Import-html_5-hidden",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property": "hidden",
"property_type": "Check",
"row_name": null,
"value": "0"
"value": "1"
},
{
"default_value": null,
"doc_type": "Kilometer Mapping",
"doc_type": "Data Import",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "language",
"modified": "2022-05-12 17:28:54.948287",
"name": "Kilometer Mapping-language-in_list_view",
"field_name": "google_sheets_url",
"modified": "2022-08-04 11:12:37.525357",
"name": "Data Import-google_sheets_url-hidden",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property": "hidden",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Report",
"doc_type": "Data Import",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "ref_doctype",
"modified": "2022-05-17 14:52:06.272839",
"name": "Report-ref_doctype-in_list_view",
"field_name": "refresh_google_sheet",
"modified": "2022-08-04 11:12:37.618615",
"name": "Data Import-refresh_google_sheet-hidden",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property": "hidden",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Report",
"doc_type": "Vehicle",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "is_standard",
"modified": "2022-05-17 14:52:06.344189",
"name": "Report-is_standard-in_list_view",
"field_name": "vehicle",
"modified": "2022-09-29 14:10:27.354547",
"name": "Vehicle-vehicle-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
@ -2160,13 +2245,13 @@
},
{
"default_value": null,
"doc_type": "Report",
"doc_type": "Vehicle",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "module",
"modified": "2022-05-17 14:52:06.383416",
"name": "Report-module-in_list_view",
"field_name": "vehicle_segment",
"modified": "2022-09-29 14:10:27.370481",
"name": "Vehicle-vehicle_segment-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
@ -2177,81 +2262,81 @@
},
{
"default_value": null,
"doc_type": "Translation",
"doc_type": "Vehicle",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "language",
"modified": "2022-07-06 12:39:54.489733",
"name": "Translation-language-options",
"field_name": "active_status",
"modified": "2022-09-29 14:10:27.409847",
"name": "Vehicle-active_status-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "options",
"property_type": "Link",
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "Custom Languages"
"value": "1"
},
{
"default_value": null,
"doc_type": "Data Import",
"doc_type": "Vehicle",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "html_5",
"modified": "2022-08-04 11:12:18.733019",
"name": "Data Import-html_5-hidden",
"field_name": "display_order",
"modified": "2022-09-29 14:10:27.396636",
"name": "Vehicle-display_order-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "hidden",
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Data Import",
"doc_type": "Vehicle",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "google_sheets_url",
"modified": "2022-08-04 11:12:37.525357",
"name": "Data Import-google_sheets_url-hidden",
"field_name": "myid",
"modified": "2022-09-29 14:10:27.383659",
"name": "Vehicle-myid-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "hidden",
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Data Import",
"doc_type": "Publish",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "refresh_google_sheet",
"modified": "2022-08-04 11:12:37.618615",
"name": "Data Import-refresh_google_sheet-hidden",
"field_name": "vehicle",
"modified": "2022-09-29 14:28:09.021766",
"name": "Publish-vehicle-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "hidden",
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Vehicle",
"doc_type": "Publish",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "vehicle",
"modified": "2022-09-29 14:10:27.354547",
"name": "Vehicle-vehicle-in_list_view",
"field_name": "publish_type",
"modified": "2022-09-29 14:28:08.978332",
"name": "Publish-publish_type-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
@ -2262,13 +2347,13 @@
},
{
"default_value": null,
"doc_type": "Vehicle",
"doc_type": "Publish",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "vehicle_segment",
"modified": "2022-09-29 14:10:27.370481",
"name": "Vehicle-vehicle_segment-in_list_view",
"field_name": "publish_status",
"modified": "2022-09-29 14:28:08.991358",
"name": "Publish-publish_status-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
@ -2279,13 +2364,30 @@
},
{
"default_value": null,
"doc_type": "Vehicle",
"doc_type": "Publish",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "version",
"modified": "2022-09-29 14:28:09.007243",
"name": "Publish-version-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Procedure",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "active_status",
"modified": "2022-09-29 14:10:27.409847",
"name": "Vehicle-active_status-in_list_view",
"modified": "2022-05-11 19:03:25.700743",
"name": "Procedure-active_status-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
@ -2296,13 +2398,166 @@
},
{
"default_value": null,
"doc_type": "Vehicle",
"doc_type": "App Labels",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "lft",
"modified": "2022-05-11 16:41:00.964578",
"name": "App Labels-lft-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "0"
},
{
"default_value": null,
"doc_type": "App Labels",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "rgt",
"modified": "2022-05-11 16:41:08.907393",
"name": "App Labels-rgt-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "0"
},
{
"default_value": null,
"doc_type": "Refresh Token",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "device_id",
"modified": "2023-06-29 10:22:48.728570",
"name": "Refresh Token-device_id-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Refresh Token",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "user",
"modified": "2023-06-29 10:22:48.791754",
"name": "Refresh Token-user-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Refresh Token",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "access_expiry_time",
"modified": "2023-06-29 10:22:48.803074",
"name": "Refresh Token-access_expiry_time-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Refresh Token",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "refresh_expiry_time",
"modified": "2023-06-29 10:22:48.816551",
"name": "Refresh Token-refresh_expiry_time-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Feature Finder",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "feature_type",
"modified": "2023-07-28 11:01:48.363209",
"name": "Feature Finder-feature_type-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Feature Finder",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "post_vin_cutoff_id",
"modified": "2023-07-28 11:01:48.381245",
"name": "Feature Finder-post_vin_cutoff_id-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Feature Finder",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "variant",
"modified": "2023-08-14 18:45:18.776901",
"name": "Feature Finder-variant-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Feature Finder",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "display_order",
"modified": "2022-09-29 14:10:27.396636",
"name": "Vehicle-display_order-in_list_view",
"modified": "2023-08-14 18:45:18.803322",
"name": "Feature Finder-display_order-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
@ -2313,13 +2568,13 @@
},
{
"default_value": null,
"doc_type": "Vehicle",
"doc_type": "Feature Finder",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "myid",
"modified": "2022-09-29 14:10:27.383659",
"name": "Vehicle-myid-in_list_view",
"field_name": "language",
"modified": "2023-08-14 18:45:18.791266",
"name": "Feature Finder-language-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
@ -2330,13 +2585,47 @@
},
{
"default_value": null,
"doc_type": "Publish",
"doc_type": "Feature Finder",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "feature_name",
"modified": "2023-08-14 18:44:14.991209",
"name": "Feature Finder-feature_name-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Repair Service Mapping",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "check_list_name",
"modified": "2023-08-14 18:44:02.290282",
"name": "Repair Service Mapping-check_list_name-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Repair Service Mapping",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "vehicle",
"modified": "2022-09-29 14:28:09.021766",
"name": "Publish-vehicle-in_list_view",
"modified": "2023-08-14 18:44:02.328727",
"name": "Repair Service Mapping-vehicle-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
@ -2347,13 +2636,13 @@
},
{
"default_value": null,
"doc_type": "Publish",
"doc_type": "Repair Service Mapping",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "publish_type",
"modified": "2022-09-29 14:28:08.978332",
"name": "Publish-publish_type-in_list_view",
"field_name": "language",
"modified": "2023-08-14 18:44:02.333514",
"name": "Repair Service Mapping-language-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
@ -2364,13 +2653,13 @@
},
{
"default_value": null,
"doc_type": "Publish",
"doc_type": "Repair Service Mapping",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "publish_status",
"modified": "2022-09-29 14:28:08.991358",
"name": "Publish-publish_status-in_list_view",
"field_name": "display_order",
"modified": "2023-08-14 18:44:02.338817",
"name": "Repair Service Mapping-display_order-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
@ -2381,13 +2670,64 @@
},
{
"default_value": null,
"doc_type": "Publish",
"doc_type": "Repair Service Mapping",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "version",
"modified": "2022-09-29 14:28:09.007243",
"name": "Publish-version-in_list_view",
"field_name": "my_id",
"modified": "2023-08-14 18:44:02.344262",
"name": "Repair Service Mapping-my_id-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Feature Finder",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "features_names",
"modified": "2023-08-14 18:45:18.825087",
"name": "Feature Finder-features_names-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Feature Finder",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "active_status",
"modified": "2023-08-14 18:45:18.813924",
"name": "Feature Finder-active_status-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Feature Finder",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "feature_category",
"modified": "2023-08-14 18:45:18.837273",
"name": "Feature Finder-feature_category-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,

449
smart_service/fixtures/report.json

@ -337,9 +337,9 @@
"javascript": null,
"json": null,
"letter_head": null,
"modified": "2021-11-24 16:55:09.198495",
"modified": "2022-05-17 15:53:35.929567",
"module": "Masters",
"name": "_Fuel Translation",
"name": "Fuel Translation",
"parent": null,
"parentfield": null,
"parenttype": null,
@ -347,21 +347,15 @@
"query": null,
"ref_doctype": "Fuel",
"reference_report": null,
"report_name": "_Fuel Translation",
"report_name": "Fuel Translation",
"report_script": null,
"report_type": "Script Report",
"roles": [
{
"parent": "_Fuel Translation",
"parent": "Fuel Translation",
"parentfield": "roles",
"parenttype": "Report",
"role": "System Manager"
},
{
"parent": "_Fuel Translation",
"parentfield": "roles",
"parenttype": "Report",
"role": "_Admin"
}
]
},
@ -377,9 +371,9 @@
"javascript": null,
"json": null,
"letter_head": null,
"modified": "2022-05-17 15:53:35.929567",
"modified": "2021-11-24 16:55:09.198495",
"module": "Masters",
"name": "Fuel Translation",
"name": "_Fuel Translation",
"parent": null,
"parentfield": null,
"parenttype": null,
@ -387,15 +381,21 @@
"query": null,
"ref_doctype": "Fuel",
"reference_report": null,
"report_name": "Fuel Translation",
"report_name": "_Fuel Translation",
"report_script": null,
"report_type": "Script Report",
"roles": [
{
"parent": "Fuel Translation",
"parent": "_Fuel Translation",
"parentfield": "roles",
"parenttype": "Report",
"role": "System Manager"
},
{
"parent": "_Fuel Translation",
"parentfield": "roles",
"parenttype": "Report",
"role": "_Admin"
}
]
},
@ -845,6 +845,33 @@
}
]
},
{
"add_total_row": 0,
"columns": [],
"disable_prepared_report": 0,
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"filters": [],
"is_standard": "Yes",
"javascript": null,
"json": null,
"letter_head": null,
"modified": "2022-01-27 11:38:32.657959",
"module": "Contacts",
"name": "Addresses And Contacts",
"parent": null,
"parentfield": null,
"parenttype": null,
"prepared_report": 0,
"query": null,
"ref_doctype": "Address",
"reference_report": null,
"report_name": "Addresses And Contacts",
"report_script": null,
"report_type": "Script Report",
"roles": []
},
{
"add_total_row": 0,
"columns": [],
@ -1293,29 +1320,173 @@
"docstatus": 0,
"doctype": "Report",
"filters": [],
"is_standard": "Yes",
"is_standard": "No",
"javascript": null,
"json": "{\"add_total_row\": 0, \"sort_by\": \"DocShare.modified\", \"sort_order\": \"desc\", \"sort_by_next\": null, \"filters\": [], \"sort_order_next\": \"desc\", \"columns\": [[\"name\", \"DocShare\"], [\"user\", \"DocShare\"], [\"share_doctype\", \"DocShare\"], [\"share_name\", \"DocShare\"], [\"read\", \"DocShare\"], [\"write\", \"DocShare\"], [\"share\", \"DocShare\"]]}",
"json": null,
"letter_head": null,
"modified": "2017-02-24 20:01:16.232286",
"modified": "2022-07-28 13:33:36.467399",
"module": "Desk",
"name": "_Test Report 1",
"parent": null,
"parentfield": null,
"parenttype": null,
"prepared_report": 0,
"query": null,
"ref_doctype": "Event",
"reference_report": null,
"report_name": "_Test Report 1",
"report_script": null,
"report_type": "Query Report",
"roles": [
{
"parent": "_Test Report 1",
"parentfield": "roles",
"parenttype": "Report",
"role": "All"
},
{
"parent": "_Test Report 1",
"parentfield": "roles",
"parenttype": "Report",
"role": "System Manager"
}
]
},
{
"add_total_row": 0,
"columns": [],
"disable_prepared_report": 0,
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"filters": [],
"is_standard": "No",
"javascript": null,
"json": "{\"columns\":[{\"fieldname\": \"email\", \"fieldtype\": \"Data\", \"label\": \"Email\", \"insert_after_index\": 0, \"link_field\": \"name\", \"doctype\": \"User\", \"options\": \"Email\", \"width\": 100, \"id\": \"email\", \"name\": \"Email\"}]}",
"letter_head": null,
"modified": "2022-07-28 13:54:05.702182",
"module": "Core",
"name": "Document Share Report",
"name": "Permitted Documents For User Custom",
"parent": null,
"parentfield": null,
"parenttype": null,
"prepared_report": 0,
"query": null,
"ref_doctype": "DocShare",
"ref_doctype": "User",
"reference_report": "Permitted Documents For User",
"report_name": "Permitted Documents For User Custom",
"report_script": null,
"report_type": "Custom Report",
"roles": [
{
"parent": "Permitted Documents For User Custom",
"parentfield": "roles",
"parenttype": "Report",
"role": "System Manager"
},
{
"parent": "Permitted Documents For User Custom",
"parentfield": "roles",
"parenttype": "Report",
"role": "CMS Admin"
},
{
"parent": "Permitted Documents For User Custom",
"parentfield": "roles",
"parenttype": "Report",
"role": "User_Account_Manager"
}
]
},
{
"add_total_row": 0,
"columns": [],
"disable_prepared_report": 0,
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"filters": [],
"is_standard": "No",
"javascript": null,
"json": null,
"letter_head": null,
"modified": "2022-07-28 13:54:06.034408",
"module": "Core",
"name": "Test Non Standard Script Report",
"parent": null,
"parentfield": null,
"parenttype": null,
"prepared_report": 0,
"query": null,
"ref_doctype": "User",
"reference_report": null,
"report_name": "Document Share Report",
"report_name": "Test Non Standard Script Report",
"report_script": "\ntotals = {}\nfor user in frappe.get_all('User', fields = ['name', 'user_type', 'creation']):\n\tif not user.user_type in totals:\n\t\ttotals[user.user_type] = 0\n\ttotals[user.user_type] = totals[user.user_type] + 1\n\ndata = [\n\t[\n\t\t{'fieldname': 'type', 'label': 'Type'},\n\t\t{'fieldname': 'value', 'label': 'Value'}\n\t],\n\t[\n\t\t{\"type\":key, \"value\": value} for key, value in totals.items()\n\t]\n]\n",
"report_type": "Script Report",
"roles": [
{
"parent": "Test Non Standard Script Report",
"parentfield": "roles",
"parenttype": "Report",
"role": "System Manager"
},
{
"parent": "Test Non Standard Script Report",
"parentfield": "roles",
"parenttype": "Report",
"role": "CMS Admin"
},
{
"parent": "Test Non Standard Script Report",
"parentfield": "roles",
"parenttype": "Report",
"role": "User_Account_Manager"
}
]
},
{
"add_total_row": 0,
"columns": [],
"disable_prepared_report": 0,
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"filters": [],
"is_standard": "No",
"javascript": null,
"json": "{\"filters\":[],\"columns\":[[\"name\",\"User\"],[\"user_type\",\"User\"],[\"first_name\",\"User\"],[\"last_name\",\"User\"],[\"last_active\",\"User\"],[\"role\",\"Has Role\"]],\"sort_by\":\"User.modified\",\"sort_order\":\"desc\",\"sort_by_next\":null,\"sort_order_next\":\"desc\"}",
"letter_head": null,
"modified": "2022-07-28 13:54:06.094984",
"module": "Core",
"name": "User Activity Report",
"parent": null,
"parentfield": null,
"parenttype": null,
"prepared_report": 0,
"query": null,
"ref_doctype": "User",
"reference_report": null,
"report_name": "User Activity Report",
"report_script": null,
"report_type": "Report Builder",
"roles": [
{
"parent": "Document Share Report",
"parent": "User Activity Report",
"parentfield": "roles",
"parenttype": "Report",
"role": "System Manager"
},
{
"parent": "User Activity Report",
"parentfield": "roles",
"parenttype": "Report",
"role": "CMS Admin"
},
{
"parent": "User Activity Report",
"parentfield": "roles",
"parenttype": "Report",
"role": "User_Account_Manager"
}
]
},
@ -1327,24 +1498,246 @@
"docstatus": 0,
"doctype": "Report",
"filters": [],
"is_standard": "Yes",
"is_standard": "No",
"javascript": null,
"json": null,
"letter_head": null,
"modified": "2022-01-27 11:38:32.657959",
"module": "Contacts",
"name": "Addresses And Contacts",
"modified": "2022-07-28 13:54:06.184634",
"module": "Core",
"name": "Test Report",
"parent": null,
"parentfield": null,
"parenttype": null,
"prepared_report": 0,
"query": null,
"ref_doctype": "Address",
"ref_doctype": "User",
"reference_report": null,
"report_name": "Addresses And Contacts",
"report_name": "Test Report",
"report_script": null,
"report_type": "Query Report",
"roles": [
{
"parent": "Test Report",
"parentfield": "roles",
"parenttype": "Report",
"role": "Test Has Role"
}
]
},
{
"add_total_row": 0,
"columns": [],
"disable_prepared_report": 0,
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"filters": [],
"is_standard": "No",
"javascript": null,
"json": "{}",
"letter_head": null,
"modified": "2022-07-28 13:54:06.276627",
"module": "Core",
"name": "Test Delete Report",
"parent": null,
"parentfield": null,
"parenttype": null,
"prepared_report": 0,
"query": null,
"ref_doctype": "User",
"reference_report": null,
"report_name": "Test Delete Report",
"report_script": null,
"report_type": "Report Builder",
"roles": [
{
"parent": "Test Delete Report",
"parentfield": "roles",
"parenttype": "Report",
"role": "System Manager"
},
{
"parent": "Test Delete Report",
"parentfield": "roles",
"parenttype": "Report",
"role": "CMS Admin"
},
{
"parent": "Test Delete Report",
"parentfield": "roles",
"parenttype": "Report",
"role": "User_Account_Manager"
}
]
},
{
"add_total_row": 0,
"columns": [
{
"fieldname": "type",
"fieldtype": "Data",
"label": "Type",
"options": null,
"parent": "Test Script Report With Columns",
"parentfield": "columns",
"parenttype": "Report",
"width": 0
},
{
"fieldname": "value",
"fieldtype": "Int",
"label": "Value",
"options": null,
"parent": "Test Script Report With Columns",
"parentfield": "columns",
"parenttype": "Report",
"width": 0
}
],
"disable_prepared_report": 0,
"disabled": 1,
"docstatus": 0,
"doctype": "Report",
"filters": [],
"is_standard": "No",
"javascript": null,
"json": null,
"letter_head": null,
"modified": "2022-07-28 13:54:07.019617",
"module": "Core",
"name": "Test Script Report With Columns",
"parent": null,
"parentfield": null,
"parenttype": null,
"prepared_report": 0,
"query": null,
"ref_doctype": "User",
"reference_report": null,
"report_name": "Test Script Report With Columns",
"report_script": "\ntotals = {}\nfor user in frappe.get_all('User', fields = ['name', 'user_type', 'creation']):\n\tif not user.user_type in totals:\n\t\ttotals[user.user_type] = 0\n\ttotals[user.user_type] = totals[user.user_type] + 1\n\nresult = [\n\t\t{\"type\":key, \"value\": value} for key, value in totals.items()\n\t]\n",
"report_type": "Script Report",
"roles": []
"roles": [
{
"parent": "Test Script Report With Columns",
"parentfield": "roles",
"parenttype": "Report",
"role": "System Manager"
},
{
"parent": "Test Script Report With Columns",
"parentfield": "roles",
"parenttype": "Report",
"role": "CMS Admin"
},
{
"parent": "Test Script Report With Columns",
"parentfield": "roles",
"parenttype": "Report",
"role": "User_Account_Manager"
}
]
},
{
"add_total_row": 1,
"columns": [],
"disable_prepared_report": 0,
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"filters": [],
"is_standard": "Yes",
"javascript": null,
"json": null,
"letter_head": "abc",
"modified": "2022-10-19 02:59:00.365307",
"module": "Core",
"name": "Database Storage Usage By Tables",
"parent": null,
"parentfield": null,
"parenttype": null,
"prepared_report": 0,
"query": "",
"ref_doctype": "Error Log",
"reference_report": null,
"report_name": "Database Storage Usage By Tables",
"report_script": null,
"report_type": "Script Report",
"roles": [
{
"parent": "Database Storage Usage By Tables",
"parentfield": "roles",
"parenttype": "Report",
"role": "System Manager"
}
]
},
{
"add_total_row": 0,
"columns": [],
"disable_prepared_report": 0,
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"filters": [],
"is_standard": "Yes",
"javascript": null,
"json": null,
"letter_head": "",
"modified": "2023-01-31 14:53:37.778576",
"module": "Custom",
"name": "Audit System Hooks",
"parent": null,
"parentfield": null,
"parenttype": null,
"prepared_report": 0,
"query": "",
"ref_doctype": "Property Setter",
"reference_report": null,
"report_name": "Audit System Hooks",
"report_script": null,
"report_type": "Script Report",
"roles": [
{
"parent": "Audit System Hooks",
"parentfield": "roles",
"parenttype": "Report",
"role": "System Manager"
}
]
},
{
"add_total_row": 0,
"columns": [],
"disable_prepared_report": 0,
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"filters": [],
"is_standard": "Yes",
"javascript": null,
"json": "{\"add_total_row\": 0, \"sort_by\": \"DocShare.modified\", \"sort_order\": \"desc\", \"sort_by_next\": null, \"filters\": [], \"sort_order_next\": \"desc\", \"columns\": [[\"name\", \"DocShare\"], [\"user\", \"DocShare\"], [\"share_doctype\", \"DocShare\"], [\"share_name\", \"DocShare\"], [\"read\", \"DocShare\"], [\"write\", \"DocShare\"], [\"share\", \"DocShare\"]]}",
"letter_head": null,
"modified": "2017-02-24 20:01:16.232286",
"module": "Core",
"name": "Document Share Report",
"parent": null,
"parentfield": null,
"parenttype": null,
"prepared_report": 0,
"query": null,
"ref_doctype": "DocShare",
"reference_report": null,
"report_name": "Document Share Report",
"report_script": null,
"report_type": "Report Builder",
"roles": [
{
"parent": "Document Share Report",
"parentfield": "roles",
"parenttype": "Report",
"role": "System Manager"
}
]
},
{
"add_total_row": 0,

542
smart_service/fixtures/role.json

@ -2,7 +2,7 @@
{
"bulk_actions": 0,
"dashboard": 0,
"desk_access": 1,
"desk_access": 0,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
@ -10,14 +10,14 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2021-10-28 10:04:14.605904",
"name": "System Manager",
"modified": "2022-04-22 17:14:51.896651",
"name": "Guest",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "System Manager",
"role_name": "Guest",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
@ -26,7 +26,7 @@
{
"bulk_actions": 0,
"dashboard": 0,
"desk_access": 0,
"desk_access": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
@ -34,14 +34,14 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2021-10-28 10:04:14.608515",
"name": "Guest",
"modified": "2022-04-22 17:14:51.900138",
"name": "All",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Guest",
"role_name": "All",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
@ -58,17 +58,17 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2021-11-03 14:16:00.977805",
"name": "All",
"modified": "2022-04-22 17:14:51.903835",
"name": "System Manager",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "All",
"role_name": "System Manager",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 1,
"two_factor_auth": 0,
"view_switcher": 0
},
{
@ -82,7 +82,7 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2021-10-28 10:04:14.682594",
"modified": "2022-04-22 17:14:51.907212",
"name": "Administrator",
"notifications": 0,
"parent": null,
@ -106,7 +106,7 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2021-10-28 10:04:16.452178",
"modified": "2022-04-22 17:14:52.641553",
"name": "Website Manager",
"notifications": 0,
"parent": null,
@ -130,7 +130,7 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2021-10-28 10:04:18.436472",
"modified": "2022-04-22 17:14:53.430016",
"name": "Dashboard Manager",
"notifications": 0,
"parent": null,
@ -154,14 +154,14 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2021-10-28 10:04:21.420899",
"name": "Prepared Report User",
"modified": "2022-04-22 17:14:56.067640",
"name": "Inbox User",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Prepared Report User",
"role_name": "Inbox User",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
@ -178,14 +178,14 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2021-10-28 10:04:30.353595",
"name": "Script Manager",
"modified": "2022-04-22 17:14:56.747692",
"name": "Report Manager",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Script Manager",
"role_name": "Report Manager",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
@ -202,167 +202,167 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2021-10-28 10:04:36.241950",
"name": "Report Manager",
"modified": "2022-04-22 17:14:57.506747",
"name": "Script Manager",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Report Manager",
"role_name": "Script Manager",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
"view_switcher": 0
},
{
"bulk_actions": 1,
"dashboard": 1,
"bulk_actions": 0,
"dashboard": 0,
"desk_access": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
"form_sidebar": 1,
"form_sidebar": 0,
"home_page": null,
"is_custom": 0,
"list_sidebar": 1,
"modified": "2021-10-28 10:05:30.659486",
"name": "Translator",
"notifications": 1,
"list_sidebar": 0,
"modified": "2022-04-22 17:14:57.697515",
"name": "Prepared Report User",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Translator",
"search_bar": 1,
"timeline": 1,
"role_name": "Prepared Report User",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
"view_switcher": 1
"view_switcher": 0
},
{
"bulk_actions": 1,
"dashboard": 1,
"bulk_actions": 0,
"dashboard": 0,
"desk_access": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
"form_sidebar": 1,
"form_sidebar": 0,
"home_page": null,
"is_custom": 0,
"list_sidebar": 1,
"modified": "2021-10-28 11:55:20.975010",
"name": "_Author",
"notifications": 1,
"list_sidebar": 0,
"modified": "2022-04-22 17:14:59.667920",
"name": "Blogger",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "_Author",
"search_bar": 1,
"timeline": 1,
"role_name": "Blogger",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
"view_switcher": 1
"view_switcher": 0
},
{
"bulk_actions": 1,
"dashboard": 1,
"bulk_actions": 0,
"dashboard": 0,
"desk_access": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
"form_sidebar": 1,
"form_sidebar": 0,
"home_page": null,
"is_custom": 0,
"list_sidebar": 1,
"modified": "2021-10-28 11:56:35.051909",
"name": "_Reviewer",
"notifications": 1,
"list_sidebar": 0,
"modified": "2022-04-22 17:15:00.539504",
"name": "Knowledge Base Contributor",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "_Reviewer",
"search_bar": 1,
"timeline": 1,
"role_name": "Knowledge Base Contributor",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
"view_switcher": 1
"view_switcher": 0
},
{
"bulk_actions": 1,
"dashboard": 1,
"bulk_actions": 0,
"dashboard": 0,
"desk_access": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
"form_sidebar": 1,
"form_sidebar": 0,
"home_page": null,
"is_custom": 0,
"list_sidebar": 1,
"modified": "2021-10-28 11:56:49.848317",
"name": "_Approver",
"notifications": 1,
"list_sidebar": 0,
"modified": "2022-04-22 17:15:00.543275",
"name": "Knowledge Base Editor",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "_Approver",
"search_bar": 1,
"timeline": 1,
"role_name": "Knowledge Base Editor",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
"view_switcher": 1
"view_switcher": 0
},
{
"bulk_actions": 1,
"dashboard": 1,
"bulk_actions": 0,
"dashboard": 0,
"desk_access": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
"form_sidebar": 1,
"form_sidebar": 0,
"home_page": null,
"is_custom": 0,
"list_sidebar": 1,
"modified": "2021-10-28 11:56:57.354933",
"name": "_Publisher",
"notifications": 1,
"list_sidebar": 0,
"modified": "2022-04-22 17:15:03.569814",
"name": "Newsletter Manager",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "_Publisher",
"search_bar": 1,
"timeline": 1,
"role_name": "Newsletter Manager",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
"view_switcher": 1
"view_switcher": 0
},
{
"bulk_actions": 1,
"dashboard": 1,
"bulk_actions": 0,
"dashboard": 0,
"desk_access": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
"form_sidebar": 1,
"form_sidebar": 0,
"home_page": null,
"is_custom": 0,
"list_sidebar": 1,
"modified": "2021-12-29 09:32:09.095126",
"name": "CMS Admin",
"notifications": 1,
"list_sidebar": 0,
"modified": "2022-04-22 17:15:05.641241",
"name": "Sales User",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "CMS Admin",
"search_bar": 1,
"timeline": 1,
"role_name": "Sales User",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
"view_switcher": 1
"view_switcher": 0
},
{
"bulk_actions": 0,
"dashboard": 0,
"desk_access": 0,
"desk_access": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
@ -370,14 +370,14 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2022-01-28 18:05:06.707011",
"name": "_AppUser",
"modified": "2022-04-22 17:15:05.645265",
"name": "Purchase User",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "_AppUser",
"role_name": "Purchase User",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
@ -394,66 +394,66 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2022-02-01 17:17:33.430575",
"name": "Blogger",
"modified": "2022-04-22 17:15:05.648651",
"name": "Accounts User",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Blogger",
"role_name": "Accounts User",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
"view_switcher": 0
},
{
"bulk_actions": 1,
"dashboard": 1,
"bulk_actions": 0,
"dashboard": 0,
"desk_access": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
"form_sidebar": 1,
"form_sidebar": 0,
"home_page": null,
"is_custom": 0,
"list_sidebar": 1,
"modified": "2022-02-22 10:28:00.880225",
"name": "CMS User",
"notifications": 1,
"list_sidebar": 0,
"modified": "2022-04-22 17:15:11.485402",
"name": "Maintenance User",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "CMS User",
"search_bar": 1,
"timeline": 1,
"role_name": "Maintenance User",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
"view_switcher": 1
"view_switcher": 0
},
{
"bulk_actions": 1,
"dashboard": 1,
"bulk_actions": 0,
"dashboard": 0,
"desk_access": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
"form_sidebar": 1,
"form_sidebar": 0,
"home_page": null,
"is_custom": 0,
"list_sidebar": 1,
"modified": "2022-02-25 12:09:33.176233",
"name": "User_Account_Manager",
"notifications": 1,
"list_sidebar": 0,
"modified": "2022-04-22 17:15:11.883257",
"name": "Maintenance Manager",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "User_Account_Manager",
"search_bar": 1,
"timeline": 1,
"role_name": "Maintenance Manager",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
"view_switcher": 1
"view_switcher": 0
},
{
"bulk_actions": 0,
@ -466,14 +466,14 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2022-02-11 10:40:44.382256",
"name": "Inbox User",
"modified": "2022-04-22 17:15:11.886907",
"name": "Sales Master Manager",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Inbox User",
"role_name": "Sales Master Manager",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
@ -490,14 +490,14 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2022-02-11 10:40:45.372226",
"name": "Knowledge Base Editor",
"modified": "2022-04-22 17:15:11.890452",
"name": "Accounts Manager",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Knowledge Base Editor",
"role_name": "Accounts Manager",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
@ -514,14 +514,14 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2022-02-11 10:40:45.377507",
"name": "Knowledge Base Contributor",
"modified": "2022-04-22 17:15:11.894131",
"name": "Purchase Manager",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Knowledge Base Contributor",
"role_name": "Purchase Manager",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
@ -538,14 +538,14 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2022-02-11 10:40:45.828780",
"name": "Newsletter Manager",
"modified": "2022-04-22 17:15:11.898011",
"name": "Purchase Master Manager",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Newsletter Manager",
"role_name": "Purchase Master Manager",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
@ -562,42 +562,42 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2022-02-11 10:40:47.131499",
"name": "Purchase User",
"modified": "2022-04-22 17:15:11.902747",
"name": "Sales Manager",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Purchase User",
"role_name": "Sales Manager",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
"view_switcher": 0
},
{
"bulk_actions": 0,
"dashboard": 0,
"bulk_actions": 1,
"dashboard": 1,
"desk_access": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
"form_sidebar": 0,
"form_sidebar": 1,
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2022-02-11 10:40:47.140070",
"name": "Sales User",
"notifications": 0,
"list_sidebar": 1,
"modified": "2022-04-22 17:15:17.169479",
"name": "Translator",
"notifications": 1,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Sales User",
"search_bar": 0,
"timeline": 0,
"role_name": "Translator",
"search_bar": 1,
"timeline": 1,
"two_factor_auth": 0,
"view_switcher": 0
"view_switcher": 1
},
{
"bulk_actions": 0,
@ -610,14 +610,14 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2022-02-11 10:40:47.144898",
"name": "Accounts User",
"modified": "2022-04-22 17:16:07.804491",
"name": "GSS User Manual Editor",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Accounts User",
"role_name": "GSS User Manual Editor",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
@ -634,95 +634,119 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2022-02-11 10:40:47.514063",
"name": "Sales Master Manager",
"modified": "2022-04-22 17:16:10.036340",
"name": "_Author",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Sales Master Manager",
"role_name": "_Author",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
"view_switcher": 0
},
{
"bulk_actions": 0,
"dashboard": 0,
"bulk_actions": 1,
"dashboard": 1,
"desk_access": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
"form_sidebar": 0,
"form_sidebar": 1,
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2022-02-11 10:40:47.519036",
"name": "Purchase Master Manager",
"notifications": 0,
"list_sidebar": 1,
"modified": "2021-10-28 11:56:35.051909",
"name": "_Reviewer",
"notifications": 1,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Purchase Master Manager",
"search_bar": 0,
"timeline": 0,
"role_name": "_Reviewer",
"search_bar": 1,
"timeline": 1,
"two_factor_auth": 0,
"view_switcher": 0
"view_switcher": 1
},
{
"bulk_actions": 0,
"dashboard": 0,
"bulk_actions": 1,
"dashboard": 1,
"desk_access": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
"form_sidebar": 0,
"form_sidebar": 1,
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2022-02-11 10:40:47.532826",
"name": "Sales Manager",
"notifications": 0,
"list_sidebar": 1,
"modified": "2021-10-28 11:56:49.848317",
"name": "_Approver",
"notifications": 1,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Sales Manager",
"search_bar": 0,
"timeline": 0,
"role_name": "_Approver",
"search_bar": 1,
"timeline": 1,
"two_factor_auth": 0,
"view_switcher": 0
"view_switcher": 1
},
{
"bulk_actions": 0,
"dashboard": 0,
"bulk_actions": 1,
"dashboard": 1,
"desk_access": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
"form_sidebar": 0,
"form_sidebar": 1,
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2022-02-11 10:40:47.539067",
"name": "Accounts Manager",
"notifications": 0,
"list_sidebar": 1,
"modified": "2021-10-28 11:56:57.354933",
"name": "_Publisher",
"notifications": 1,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Accounts Manager",
"search_bar": 0,
"timeline": 0,
"role_name": "_Publisher",
"search_bar": 1,
"timeline": 1,
"two_factor_auth": 0,
"view_switcher": 0
"view_switcher": 1
},
{
"bulk_actions": 1,
"dashboard": 1,
"desk_access": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
"form_sidebar": 1,
"home_page": null,
"is_custom": 0,
"list_sidebar": 1,
"modified": "2021-12-29 09:32:09.095126",
"name": "CMS Admin",
"notifications": 1,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "CMS Admin",
"search_bar": 1,
"timeline": 1,
"two_factor_auth": 0,
"view_switcher": 1
},
{
"bulk_actions": 0,
"dashboard": 0,
"desk_access": 1,
"desk_access": 0,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
@ -730,23 +754,71 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2022-02-11 10:40:47.544062",
"name": "Maintenance Manager",
"modified": "2022-01-28 18:05:06.707011",
"name": "_AppUser",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Maintenance Manager",
"role_name": "_AppUser",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
"view_switcher": 0
},
{
"bulk_actions": 1,
"dashboard": 1,
"desk_access": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
"form_sidebar": 1,
"home_page": null,
"is_custom": 0,
"list_sidebar": 1,
"modified": "2022-07-28 13:33:30.003641",
"name": "_Test Role",
"notifications": 1,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "_Test Role",
"search_bar": 1,
"timeline": 1,
"two_factor_auth": 0,
"view_switcher": 1
},
{
"bulk_actions": 1,
"dashboard": 1,
"desk_access": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
"form_sidebar": 1,
"home_page": null,
"is_custom": 0,
"list_sidebar": 1,
"modified": "2022-07-28 13:54:08.522433",
"name": "_Test Role 3",
"notifications": 1,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "_Test Role 3",
"search_bar": 1,
"timeline": 1,
"two_factor_auth": 0,
"view_switcher": 1
},
{
"bulk_actions": 0,
"dashboard": 0,
"desk_access": 1,
"desk_access": 0,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
@ -754,23 +826,47 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2022-02-11 10:40:47.548971",
"name": "Maintenance User",
"modified": "2022-07-28 13:33:30.274487",
"name": "_Test Role 4",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Maintenance User",
"role_name": "_Test Role 4",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
"view_switcher": 0
},
{
"bulk_actions": 1,
"dashboard": 1,
"desk_access": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
"form_sidebar": 1,
"home_page": null,
"is_custom": 0,
"list_sidebar": 1,
"modified": "2022-07-28 13:54:06.148515",
"name": "Test Has Role",
"notifications": 1,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Test Has Role",
"search_bar": 1,
"timeline": 1,
"two_factor_auth": 0,
"view_switcher": 1
},
{
"bulk_actions": 0,
"dashboard": 0,
"desk_access": 1,
"desk_access": 0,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
@ -778,14 +874,14 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 0,
"modified": "2022-02-11 10:40:47.554124",
"name": "Purchase Manager",
"modified": "2022-07-28 13:54:08.098253",
"name": "desk-access-test",
"notifications": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "Purchase Manager",
"role_name": "desk-access-test",
"search_bar": 0,
"timeline": 0,
"two_factor_auth": 0,
@ -802,14 +898,62 @@
"home_page": null,
"is_custom": 0,
"list_sidebar": 1,
"modified": "2022-02-21 16:49:26.740814",
"name": "GSS User Manual Editor",
"modified": "2022-07-28 13:56:32.523672",
"name": "_Test Role 2",
"notifications": 1,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "GSS User Manual Editor",
"role_name": "_Test Role 2",
"search_bar": 1,
"timeline": 1,
"two_factor_auth": 0,
"view_switcher": 1
},
{
"bulk_actions": 1,
"dashboard": 1,
"desk_access": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
"form_sidebar": 1,
"home_page": null,
"is_custom": 0,
"list_sidebar": 1,
"modified": "2022-02-22 10:28:00.880225",
"name": "CMS User",
"notifications": 1,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "CMS User",
"search_bar": 1,
"timeline": 1,
"two_factor_auth": 0,
"view_switcher": 1
},
{
"bulk_actions": 1,
"dashboard": 1,
"desk_access": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Role",
"form_sidebar": 1,
"home_page": null,
"is_custom": 0,
"list_sidebar": 1,
"modified": "2022-02-25 12:09:33.176233",
"name": "User_Account_Manager",
"notifications": 1,
"parent": null,
"parentfield": null,
"parenttype": null,
"restrict_to_domain": null,
"role_name": "User_Account_Manager",
"search_bar": 1,
"timeline": 1,
"two_factor_auth": 0,

11
smart_service/fixtures/role_profile.json

@ -112,5 +112,16 @@
"role": "User_Account_Manager"
}
]
},
{
"docstatus": 0,
"doctype": "Role Profile",
"modified": "2022-07-28 13:54:08.752850",
"name": "Test 1",
"parent": null,
"parentfield": null,
"parenttype": null,
"role_profile": "Test 1",
"roles": []
}
]

6
smart_service/fixtures/workflow_action_master.json

@ -2,7 +2,7 @@
{
"docstatus": 0,
"doctype": "Workflow Action Master",
"modified": "2021-10-28 10:05:30.859488",
"modified": "2022-04-22 17:15:17.213186",
"name": "Approve",
"parent": null,
"parentfield": null,
@ -12,7 +12,7 @@
{
"docstatus": 0,
"doctype": "Workflow Action Master",
"modified": "2021-10-28 10:05:30.861967",
"modified": "2022-04-22 17:15:17.216432",
"name": "Reject",
"parent": null,
"parentfield": null,
@ -22,7 +22,7 @@
{
"docstatus": 0,
"doctype": "Workflow Action Master",
"modified": "2021-10-28 10:05:30.864039",
"modified": "2022-04-22 17:15:17.219145",
"name": "Review",
"parent": null,
"parentfield": null,

30
smart_service/fixtures/workflow_state.json

@ -3,7 +3,7 @@
"docstatus": 0,
"doctype": "Workflow State",
"icon": "question-sign",
"modified": "2021-10-28 10:05:30.766665",
"modified": "2022-04-22 17:15:17.190891",
"name": "Pending",
"parent": null,
"parentfield": null,
@ -15,7 +15,7 @@
"docstatus": 0,
"doctype": "Workflow State",
"icon": "ok-sign",
"modified": "2021-10-28 10:05:30.769376",
"modified": "2022-04-22 17:15:17.195155",
"name": "Approved",
"parent": null,
"parentfield": null,
@ -27,7 +27,7 @@
"docstatus": 0,
"doctype": "Workflow State",
"icon": "remove",
"modified": "2021-10-28 10:05:30.771963",
"modified": "2022-04-22 17:15:17.198336",
"name": "Rejected",
"parent": null,
"parentfield": null,
@ -35,6 +35,18 @@
"style": "Danger",
"workflow_state_name": "Rejected"
},
{
"docstatus": 0,
"doctype": "Workflow State",
"icon": "",
"modified": "2022-03-24 12:59:27.717741",
"name": "Draft",
"parent": null,
"parentfield": null,
"parenttype": null,
"style": "Danger",
"workflow_state_name": "Draft"
},
{
"docstatus": 0,
"doctype": "Workflow State",
@ -107,18 +119,6 @@
"style": "Primary",
"workflow_state_name": "Publish Approval Pending"
},
{
"docstatus": 0,
"doctype": "Workflow State",
"icon": "",
"modified": "2022-03-24 12:59:27.717741",
"name": "Draft",
"parent": null,
"parentfield": null,
"parenttype": null,
"style": "Danger",
"workflow_state_name": "Draft"
},
{
"docstatus": 0,
"doctype": "Workflow State",

1847
smart_service/fixtures/workspace.json

File diff suppressed because it is too large

22
smart_service/hooks.py

@ -17,7 +17,7 @@ app_logo_url = "/assets/smart_service/images/Mahindra Rise2.png"
app_include_css = ["/assets/css/smart_service.min.css"]
# for web css
web_include_css = ["/assets/css/smart_service.min.css"]
app_include_js = "/assets/smart_service/js/common_fun.js"
# Icons
website_context = {
"favicon": "/assets/smart_service/images/Logo Fav Icon.png",
@ -210,17 +210,17 @@ fixtures = [
# "filters": [{"is_standard":0}]
# }
# "Custom Field",
# "Property Setter",
"Property Setter",
# "Client Script",
# "Server Script",
# "Workflow",
# "Workflow Action Master",
# "Workflow State",
# "Role",
# "Workspace",
# "Custom DocPerm",
# "Role Profile",
# "Report",
# "Dashboard Chart"
"Workflow",
"Workflow Action Master",
"Workflow State",
"Role",
"Workspace",
"Custom DocPerm",
"Role Profile",
"Report",
"Dashboard Chart"
]

33
smart_service/masters/doctype/app_labels/app_labels.js

@ -1,27 +1,30 @@
// Copyright (c) 2021, Hard n Soft Technologies Pvt Ltd and contributors
// For license information, please see license.txt
var regex = /[!@#$%^&]+/;
frappe.ui.form.on('App Labels', {
is_group: function(frm) {
if (frm.doc.is_group){
is_group: function (frm) {
if (frm.doc.is_group) {
frm.set_value("language", "en");
frm.set_df_property('language', 'read_only', 1);
frm.set_df_property('label', 'read_only', 1);
frm.set_df_property('parent_app_labels', 'hidden', 1);
frm.set_df_property('language', 'read_only', 1);
frm.set_df_property('label', 'read_only', 1);
frm.set_df_property('parent_app_labels', 'hidden', 1);
} else {
frm.set_df_property('language', 'read_only', 0);
frm.set_df_property('label', 'read_only', 0);
frm.set_df_property('parent_app_labels', 'hidden', 0);
frm.set_df_property('language', 'read_only', 0);
frm.set_df_property('label', 'read_only', 0);
frm.set_df_property('parent_app_labels', 'hidden', 0);
}
},
english_label: function(frm) {
if (frm.doc.is_group){
english_label: function (frm) {
if (frm.doc.is_group) {
frm.set_value("label", frm.doc.english_label);
}
},
validate: function (frm) {
if (frm.doc.is_group) {
frm.doc.parent_app_labels = null
}
if (frm.doc.english_label) {
if (frm.doc.english_label.length > 100) {
frappe.msgprint("<b>English Label :</b> Only <b> 50 </b> characters allowed")
@ -36,9 +39,11 @@ frappe.ui.form.on('App Labels', {
frappe.throw(__("Just a <b>.</b> is not prescribed!"));
frappe.validated = false;
}
var regex = /[!@#$%^&*()+\=\[\]{};`~':"\\|.<>\/]+/;
// var regex = /[!@#$%^&*()+\=\[\]{};`~'"\\|.<>\/]+/;
if (frm.doc.english_label) {
console.log(regex.test(frm.doc.english_label))
if (regex.test(frm.doc.english_label) === true) {
debugger
frappe.throw(__("<b>English Label :</b> Only letters, numbers and <b> - , </b> are allowed."));
frappe.validated = false;
} else if (frm.doc.english_label) {
@ -63,7 +68,7 @@ frappe.ui.form.on('App Labels', {
frappe.throw(__("Just a <b>.</b> is not prescribed!"));
frappe.validated = false;
}
var regex = /[!@#$%^&*()+\=\[\]{};`~':"\\|.<>\/?]+/;
// var regex = /[!@#$%^&*()+\=\[\]{};`~'"\\|.<>\/?]+/;
if (frm.doc.page_name) {
if (regex.test(frm.doc.page_name) === true) {
frappe.throw(__("<b>Page Name :</b> Only letters, numbers and <b> -,</b> are allowed."));
@ -90,7 +95,7 @@ frappe.ui.form.on('App Labels', {
frappe.throw(__("Just a <b>.</b> is not prescribed!"));
frappe.validated = false;
}
var regex = /[!@#$%^&*()+\=\[\]{};`~':"\\|.<>\/]+/;
// var regex = /[!@#$%^&*()+\=\[\]{};`~'"\\|.<>\/]+/;
if (frm.doc.label) {
if (regex.test(frm.doc.label) === true) {
frappe.throw(__("<b>Translated Label :</b> Only letters, numbers and <b> -,</b> are allowed."));

7
smart_service/masters/doctype/app_labels/app_labels.json

@ -34,7 +34,7 @@
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Translated Label",
"reqd": 1
"mandatory_depends_on": "eval:doc.language!=\"en\";"
},
{
"fieldname": "english_label",
@ -42,7 +42,8 @@
"in_list_view": 1,
"in_standard_filter": 1,
"label": "English Label",
"reqd": 1
"reqd": 1,
"set_only_once": 1
},
{
"fieldname": "column_break_2",
@ -95,7 +96,7 @@
"index_web_pages_for_search": 1,
"is_tree": 1,
"links": [],
"modified": "2022-01-04 14:37:33.603797",
"modified": "2023-12-06 14:59:55.361789",
"modified_by": "Administrator",
"module": "Masters",
"name": "App Labels",

5
smart_service/masters/doctype/custom_languages/custom_languages.json

@ -25,7 +25,8 @@
"in_standard_filter": 1,
"label": "Lang Code",
"options": "Language",
"reqd": 1
"reqd": 1,
"set_only_once": 1
},
{
"fieldname": "column_break_2",
@ -90,7 +91,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-07-11 15:55:25.503377",
"modified": "2023-11-08 14:08:58.792793",
"modified_by": "Administrator",
"module": "Masters",
"name": "Custom Languages",

3
smart_service/masters/doctype/drive/drive.json

@ -1,7 +1,6 @@
{
"actions": [],
"allow_import": 1,
"allow_rename": 1,
"autoname": "format:{drive}",
"creation": "2021-10-28 13:22:52.454082",
"doctype": "DocType",
@ -43,7 +42,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-03-28 16:16:40.291574",
"modified": "2023-11-08 14:00:38.435142",
"modified_by": "Administrator",
"module": "Masters",
"name": "Drive",

3
smart_service/masters/doctype/fuel/fuel.json

@ -1,7 +1,6 @@
{
"actions": [],
"allow_import": 1,
"allow_rename": 1,
"autoname": "format: {fuel}",
"creation": "2021-10-28 13:06:03.207653",
"doctype": "DocType",
@ -44,7 +43,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-03-28 16:16:24.261317",
"modified": "2023-11-08 13:56:20.882519",
"modified_by": "Administrator",
"module": "Masters",
"name": "Fuel",

0
smart_service/masters/doctype/module_master/__init__.py

55
smart_service/masters/doctype/module_master/module_master.js

@ -0,0 +1,55 @@
// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
// For license information, please see license.txt
var original_display_order = 0;
var module_name_count=0;
frappe.require('assets/smart_service/js/utils.js', () => {})
frappe.ui.form.on('Module Master', {
onload: function (frm) {
// Set Display Order
if (frm.is_new()) {
frm.set_df_property('display_order', 'read_only', 1);
} else {
frm.set_df_property('display_order', 'read_only', 0);
}
frappe.db.count('Module Master')
.then(count => {
module_name_count = count + 1;
if (frm.is_new()) {
frm.set_value("display_order", module_name_count);
} else {
original_display_order = frm.doc.display_order;
}
});
},
refresh: function (frm) {
// Set Display Order
if (frm.is_new()) {
frm.set_df_property('display_order', 'read_only', 1);
} else {
frm.set_df_property('display_order', 'read_only', 0);
}
frappe.db.count('Module Master')
.then(count => {
module_name_count = count + 1;
if (frm.is_new()) {
frm.set_value("display_order", module_name_count);
} else {
original_display_order = frm.doc.display_order;
}
});
},
after_save:function(frm){
cur_frm.refresh_fields("display_order")
},
validate: function (frm) {
//For Display Order
cur_frm.refresh_fields("display_order")
// console.log(module_name_count,"----",original_display_order)
display_order_validation(frm, module_name_count, original_display_order,frm.doc.module_name)
}
});

73
smart_service/masters/doctype/module_master/module_master.json

@ -0,0 +1,73 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "format:{module_name}",
"creation": "2023-07-19 13:36:02.668693",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"module_name",
"active_status",
"display_order",
"app_menu_id"
],
"fields": [
{
"fieldname": "module_name",
"fieldtype": "Data",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Module Name",
"reqd": 1,
"set_only_once": 1
},
{
"fieldname": "active_status",
"fieldtype": "Select",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Active Status",
"options": "Active\nInactive",
"reqd": 1
},
{
"fieldname": "display_order",
"fieldtype": "Int",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Display Order",
"reqd": 1
},
{
"fieldname": "app_menu_id",
"fieldtype": "Int",
"label": "App Menu Id",
"reqd": 1
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-01-03 16:04:06.524640",
"modified_by": "Administrator",
"module": "Masters",
"name": "Module Master",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "module_name"
}

21
smart_service/masters/doctype/module_master/module_master.py

@ -0,0 +1,21 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
import frappe
from frappe.model.document import Document
class ModuleMaster(Document):
def validate(self):
if self.module_name:
self.module_name = self.module_name.strip()
# def autoname(self):
# if self.is_new():
# count = frappe.db.sql(
# '''select max(my_id) as max_count from `tabModule Master`;''')
# if count[0][0] is not None:
# self.my_id = count[0][0] + 1
# else:
# self.my_id = 1

8
smart_service/masters/doctype/module_master/test_module_master.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and Contributors
# See license.txt
# import frappe
import unittest
class TestModuleMaster(unittest.TestCase):
pass

4
smart_service/masters/doctype/procedure_name/procedure_name.json

@ -1,7 +1,6 @@
{
"actions": [],
"allow_import": 1,
"allow_rename": 1,
"autoname": "format:{procedure_name}",
"creation": "2022-07-06 12:53:36.916465",
"doctype": "DocType",
@ -19,12 +18,13 @@
"in_preview": 1,
"label": "Procedure Name",
"reqd": 1,
"set_only_once": 1,
"unique": 1
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-07-06 12:53:36.916465",
"modified": "2023-11-08 15:04:12.123682",
"modified_by": "Administrator",
"module": "Masters",
"name": "Procedure Name",

4
smart_service/masters/doctype/procedure_step_name/procedure_step_name.json

@ -1,7 +1,6 @@
{
"actions": [],
"allow_import": 1,
"allow_rename": 1,
"autoname": "format:{step_name}",
"creation": "2022-07-06 12:56:39.780095",
"doctype": "DocType",
@ -19,12 +18,13 @@
"in_preview": 1,
"label": "Step Name",
"reqd": 1,
"set_only_once": 1,
"unique": 1
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-07-06 12:56:39.780095",
"modified": "2023-11-08 15:04:29.660451",
"modified_by": "Administrator",
"module": "Masters",
"name": "Procedure Step Name",

0
smart_service/masters/doctype/role_master/__init__.py

122
smart_service/masters/doctype/role_master/role_master.js

@ -0,0 +1,122 @@
// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
// For license information, please see license.txt
var original_display_order = 0;
var role_name_count = 0;
frappe.require('assets/smart_service/js/utils.js', () => { })
frappe.ui.form.on('Role Master', {
onload: function (frm) {
// Set Display Order
// if (frm.is_new()) {
// frm.set_df_property('display_order', 'read_only', 1);
// } else {
// frm.set_df_property('display_order', 'read_only', 0);
// }
// frappe.db.count('Role Master')
// .then(count => {
// role_name_count = count + 1;
// if (frm.is_new()) {
// frm.set_value("display_order", role_name_count);
// } else {
// original_display_order = frm.doc.display_order;
// }
// });
},
refresh: function (frm) {
// Set Display Order
// if (frm.is_new()) {
// frm.set_df_property('display_order', 'read_only', 1);
// } else {
// frm.set_df_property('display_order', 'read_only', 0);
// }
// frappe.db.count('Role Master')
// .then(count => {
// role_name_count = count + 1;
// if (frm.is_new()) {
// frm.set_value("display_order", role_name_count);
// } else {
// original_display_order = frm.doc.display_order;
// }
// });
//for Module Master
// frappe.db.get_list('Module Master', {
// fields: ['module_name', 'name'],
// filters: {
// }
// }).then(records => {
frappe.call({
method: "smart_service.masters.doctype.role_master.role_master.get_module_names",
args: { vehicle: frm.doc.vehicle, language_label: frm.doc.language_label, publish_type: frm.doc.publish_type },
callback: function (r) {
if (r.message) {
let res = cur_frm.fields_dict.module_master_html.$wrapper.empty()
let module_html = "<div class='module-container' style='float:left;display:flex'>"
module_html += "<div class='row' style='margin-left:5px !important;'>"
r.message.map(val => {
var id_name = (val.name).replace(" ","_")
id_name = id_name.toLowerCase()
if (!frm.is_new() && frm.doc.modules && frm.doc.modules.includes(val.module_name)) {
module_html += "<div class='col-3' style='padding-left:0px !important;padding-right:0px !important'>"
module_html += "<input type='checkbox' id=" + "'" + id_name + "'" + " name='vehicle1' value=" + "'" + val.module_name + "'" + " checked>"
module_html += "<label for=" + val.name + " style='padding-right:20px'>" + val.module_name + "</label></div>"
} else {
module_html += "<div class='col-3' style='padding-left:0px !important;padding-right:0px !important'>"
module_html += "<input type='checkbox' id=" + "'" + id_name + "'" + " name='vehicle1' value=" + "'" + val.module_name + "'" + " >"
module_html += "<label for=" + val.name + " style='padding-right:20px'>" + val.module_name + "</label></div>"
}
})
res.append(module_html)
// $( document ).ready(function() {
// console.log(":hiiiii")
// console.log( $("#automotive_system input:checkbox"))
// $("#automotive_system").click(function(){
// if($(this).is(':checked')){
// $("#component").prop('checked', true);
// $("#feature_finder").prop('checked', true);
// $("#symptom").prop('checked', true);
// }
// else{
// $("#component").prop('checked', false)
// $("#feature_finder").prop('checked', false);
// $("#symptom").prop('checked', false);
// }
// });
// });
}
}
})
},
after_save: function (frm) {
cur_frm.refresh_fields("display_order")
},
validate: function (frm) {
//check html if has Module name value
var val = ""
$(':checkbox:checked').each(function (i) {
let value = $(this).val();
val += $(this).val() + ","
});
val = val.substring(0, val.length - 1);
// console.log(val,"val")
frm.set_value('modules', val);
cur_frm.refresh_fields();
//For Display Order
// cur_frm.refresh_fields("display_order")
// console.log(module_name_count,"----",original_display_order)
// display_order_validation(frm, role_name_count, original_display_order,frm.doc.role)
}
});

93
smart_service/masters/doctype/role_master/role_master.json

@ -0,0 +1,93 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "format:{role}",
"creation": "2023-07-19 13:42:52.880565",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"role",
"column_break_ffrrr",
"modules",
"skill_id",
"active_status",
"section_break_bkwnr",
"module_name_configuration",
"module_master_html"
],
"fields": [
{
"fieldname": "role",
"fieldtype": "Data",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Role",
"reqd": 1,
"set_only_once": 1
},
{
"fieldname": "column_break_ffrrr",
"fieldtype": "Column Break"
},
{
"fieldname": "module_master_html",
"fieldtype": "HTML",
"label": "Module Master",
"read_only": 1
},
{
"fieldname": "module_name_configuration",
"fieldtype": "Heading",
"label": "Module Name Configuration"
},
{
"fieldname": "modules",
"fieldtype": "Small Text",
"hidden": 1,
"label": "Modules"
},
{
"fieldname": "skill_id",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Skill Id",
"reqd": 1,
"set_only_once": 1
},
{
"fieldname": "section_break_bkwnr",
"fieldtype": "Section Break"
},
{
"fieldname": "active_status",
"fieldtype": "Select",
"label": "Active Status",
"options": "Active\nInactive"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-01-09 18:00:03.439171",
"modified_by": "Administrator",
"module": "Masters",
"name": "Role Master",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "role"
}

25
smart_service/masters/doctype/role_master/role_master.py

@ -0,0 +1,25 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
import frappe
from frappe.model.document import Document
class RoleMaster(Document):
pass
# def validate(self):
# if self.is_new():
# count = frappe.db.sql(
# '''select max(my_id) as max_count from `tabRole Master`;''')
# if count[0][0] is not None:
# self.my_id = count[0][0] + 1
# else:
# self.my_id = 1
# if self.role:
# self.role = self.role.strip()
@ frappe.whitelist()
def get_module_names():
data = frappe.db.sql(f'''
select name,module_name from `tabModule Master`''', as_dict=1)
return data

8
smart_service/masters/doctype/role_master/test_role_master.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and Contributors
# See license.txt
# import frappe
import unittest
class TestRoleMaster(unittest.TestCase):
pass

3
smart_service/masters/doctype/sub_systems/sub_systems.json

@ -1,7 +1,6 @@
{
"actions": [],
"allow_import": 1,
"allow_rename": 1,
"autoname": "format:{sub_system_name}",
"creation": "2021-10-28 13:38:29.929359",
"doctype": "DocType",
@ -43,7 +42,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-03-28 16:18:17.899428",
"modified": "2023-11-08 14:01:19.359553",
"modified_by": "Administrator",
"module": "Masters",
"name": "Sub Systems",

3
smart_service/masters/doctype/systems/systems.json

@ -1,7 +1,6 @@
{
"actions": [],
"allow_import": 1,
"allow_rename": 1,
"autoname": "format:{system_name}",
"creation": "2021-10-28 13:30:53.639882",
"doctype": "DocType",
@ -60,7 +59,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-04-01 13:01:57.103930",
"modified": "2023-11-08 14:01:08.915044",
"modified_by": "Administrator",
"module": "Masters",
"name": "Systems",

3
smart_service/masters/doctype/transmission/transmission.json

@ -1,7 +1,6 @@
{
"actions": [],
"allow_import": 1,
"allow_rename": 1,
"autoname": "format:{transmission}",
"creation": "2021-10-28 13:17:21.403818",
"doctype": "DocType",
@ -43,7 +42,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-03-28 16:17:00.779363",
"modified": "2023-11-08 14:00:15.698582",
"modified_by": "Administrator",
"module": "Masters",
"name": "Transmission",

6
smart_service/masters/doctype/variant/variant.json

@ -1,7 +1,6 @@
{
"actions": [],
"allow_import": 1,
"allow_rename": 1,
"creation": "2021-10-28 12:45:38.664344",
"doctype": "DocType",
"editable_grid": 1,
@ -28,7 +27,8 @@
"in_standard_filter": 1,
"label": "Vehicle",
"options": "Vehicle",
"reqd": 1
"reqd": 1,
"set_only_once": 1
},
{
"allow_in_quick_entry": 1,
@ -102,7 +102,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-04-09 16:55:08.379111",
"modified": "2023-12-06 14:24:53.008660",
"modified_by": "Administrator",
"module": "Masters",
"name": "Variant",

82
smart_service/masters/report/drive_translation/drive_translation.py

@ -5,62 +5,68 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe.utils import cstr
from frappe import msgprint, _
current_db_name = frappe.conf.get("db_name")
def execute(filters=None):
columns, data = [], []
columns,lang = get_columns()
data = get_data()
return columns, data
columns, data = [], []
columns, lang = get_columns()
data = get_data()
return columns, data
def get_data():
custom_lang = frappe.db.sql("""SELECT lang_code FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_list=True)
def get_data():
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN %s.tabTranslation.translated_text ELSE null END) as %s" %(d[0],current_db_name,d[0])
queryAppendLang += q
custom_lang = frappe.db.sql(
"""SELECT lang_code FROM `tabCustom Languages` where lang_code <> "en" order by lang_name;""", as_list=1)
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s"%(d[0],d[0])
sel+= r
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN tabTranslation.translated_text ELSE null END) as %s" % (
d[0], d[0])
queryAppendLang += q
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s" % (d[0], d[0])
sel += r
actualQuery = """Select
actualQuery = """Select
`tabDrive`.modified as "Modified On",
`tabDrive`.active_status as "Status",
`tabDrive`.drive as 'Drive'
%s
From %s.`tabDrive`
LEFT JOIN %s.`tabTranslation` as tabTrans
ON %s.`tabDrive`.drive = tabTrans.source_text
From `tabDrive`
LEFT JOIN `tabTranslation` as tabTrans
ON `tabDrive`.drive = tabTrans.source_text
LEFT JOIN (Select tabLang.languageCode as languageCode
,%s.tabTranslation.source_text as sourceText
, %s.tabTranslation.translated_text as translated_text
,tabTranslation.source_text as sourceText
,tabTranslation.translated_text as translated_text
%s
From %s.tabTranslation
From tabTranslation
INNER JOIN (SELECT tanLang.language_name as language_name
, tanLang.language_code as languageCode
FROM %s.tabLanguage as tanLang) as tabLang
ON %s.tabTranslation.language = tabLang.languageCode) as tabTranslation
ON %s.`tabDrive`.drive = tabTranslation.sourceText;""" % (sel,current_db_name,current_db_name,current_db_name,current_db_name,current_db_name,queryAppendLang,current_db_name,current_db_name,current_db_name,current_db_name)
FROM tabLanguage as tanLang) as tabLang
ON tabTranslation.language = tabLang.languageCode) as tabTranslation
ON `tabDrive`.drive = tabTranslation.sourceText
ORDER BY `tabDrive`.modified DESC;""" % (sel, queryAppendLang)
data = frappe.db.sql(actualQuery, as_list=True)
data = frappe.db.sql(actualQuery,as_list=True)
return data
return data
def get_columns():
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") + ":Data/:100",_("<b>Drive</b>") + ":Data/:220",
]
lang = []
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>"+ "::220")
columns += lang
return columns,lang
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") +
":Data/:100", _("<b>Drive</b>") + ":Data/:220",
]
lang = []
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM `tabCustom Languages` where lang_code <> "en"
order by lang_name""", as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>" + "::220")
columns += lang
return columns, lang

66
smart_service/masters/report/fuel_translation/fuel_translation.py

@ -5,31 +5,34 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe.utils import cstr
from frappe import msgprint, _
def execute(filters=None):
columns, data = [], []
columns,lang = get_columns()
data = get_data()
return columns, data
columns, data = [], []
columns, lang = get_columns()
data = get_data()
return columns, data
def get_data():
custom_lang = frappe.db.sql("""SELECT lang_code FROM `tabCustom Languages` where lang_code <> "en" order by lang_name""",as_list=True)
def get_data():
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN tabTranslation.translated_text ELSE null END) as %s" %(d[0],d[0])
queryAppendLang += q
custom_lang = frappe.db.sql(
"""SELECT lang_code FROM `tabCustom Languages` where lang_code <> "en" order by lang_name""", as_list=1)
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s"%(d[0],d[0])
sel+= r
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN tabTranslation.translated_text ELSE null END) as %s" % (
d[0], d[0])
queryAppendLang += q
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s" % (d[0], d[0])
sel += r
actualQuery = """Select
actualQuery = """Select
`tabFuel`.modified as "Modified On",
`tabFuel`.active_status as "Status",
`tabFuel`.fuel as 'Fuel'
@ -46,24 +49,25 @@ def get_data():
, tanLang.language_code as languageCode
FROM tabLanguage as tanLang) as tabLang
ON tabTranslation.language = tabLang.languageCode) as tabTranslation
ON `tabFuel`.fuel = tabTranslation.sourceText;""" % (sel ,queryAppendLang)
ON `tabFuel`.fuel = tabTranslation.sourceText ORDER BY `tabFuel`.modified DESC;""" % (sel, queryAppendLang)
data = frappe.db.sql(actualQuery,as_list=True)
data = frappe.db.sql(actualQuery, as_list=True)
return data
return data
def get_columns():
current_db_name = frappe.conf.get("db_name")
current_db_name = frappe.conf.get("db_name")
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") + ":Data/:100",_("<b>Fuel</b>") + ":Data/:220",
]
lang = []
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM {}.`tabCustom Languages` where lang_code <> "en" order by lang_name """.format(current_db_name),as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>"+ "::220")
columns += lang
return columns,lang
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") +
":Data/:100", _("<b>Fuel</b>") + ":Data/:220",
]
lang = []
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM `tabCustom Languages` where lang_code <> "en"
order by lang_name; """, as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>" + "::220")
columns += lang
return columns, lang

98
smart_service/masters/report/sub_systems_translation/sub_systems_translation.py

@ -5,66 +5,70 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe.utils import cstr
from frappe import msgprint, _
current_db_name = frappe.conf.get("db_name")
def execute(filters=None):
columns, data = [], []
columns,lang = get_columns()
data = get_data()
return columns, data
columns, data = [], []
columns, lang = get_columns()
data = get_data()
return columns, data
def get_data():
custom_lang = frappe.db.sql("""SELECT lang_code FROM {}.`tabCustom Languages` where lang_code <> "en" order by lang_name""".format(current_db_name),as_list=True)
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN %s.tabTranslation.translated_text ELSE null END) as %s" %(d[0],current_db_name,d[0])
queryAppendLang += q
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s"%(d[0],d[0])
sel+= r
def get_data():
actualQuery = """Select
{0}.`tabSub Systems`.modified as "Modified On",
{0}.`tabSub Systems`.active_status as "Status",
{0}.`tabSub Systems`.sub_system_name as 'Vehicle Segment'
{1}
From {0}.`tabSub Systems`
LEFT JOIN {0}.`tabTranslation` as tabTrans
ON {0}.`tabSub Systems`.sub_system_name = tabTrans.source_text
custom_lang = frappe.db.sql(
"""SELECT lang_code FROM `tabCustom Languages` where lang_code <> "en" order by lang_name;""", as_list=1)
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN tabTranslation.translated_text ELSE null END) as %s" % (
d[0], d[0])
queryAppendLang += q
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s" % (d[0], d[0])
sel += r
actualQuery = """Select
`tabSub Systems`.modified as "Modified On",
`tabSub Systems`.active_status as "Status",
`tabSub Systems`.sub_system_name as 'Vehicle Segment'
{0}
From `tabSub Systems`
LEFT JOIN `tabTranslation` as tabTrans
ON `tabSub Systems`.sub_system_name = tabTrans.source_text
LEFT JOIN (Select tabLang.languageCode as languageCode
,{0}.tabTranslation.source_text as sourceText
, {0}.tabTranslation.translated_text as translated_text
{2}
From {0}.tabTranslation
,tabTranslation.source_text as sourceText
, tabTranslation.translated_text as translated_text
{1}
From tabTranslation
INNER JOIN (SELECT tanLang.language_name as language_name
, tanLang.language_code as languageCode
FROM {0}.tabLanguage as tanLang) as tabLang
ON {0}.tabTranslation.language = tabLang.languageCode) as tabTranslation
ON {0}.`tabSub Systems`.sub_system_name = tabTranslation.sourceText;""" .format(current_db_name,sel ,queryAppendLang)
FROM tabLanguage as tanLang) as tabLang
ON tabTranslation.language = tabLang.languageCode) as tabTranslation
ON `tabSub Systems`.sub_system_name = tabTranslation.sourceText
ORDER BY `tabSub Systems`.modified DESC;""" .format(sel, queryAppendLang)
data = frappe.db.sql(actualQuery,as_list=True)
data = frappe.db.sql(actualQuery, as_list=True)
return data
return data
def get_columns():
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") + ":Data/:100",_("<b>Sub Systems</b>") + ":Data/:300",
]
lang = []
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM {0}.`tabCustom Languages` where lang_code <> "en" order by lang_name""".format(current_db_name),as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>"+ "::300")
columns += lang
return columns,lang
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") +
":Data/:100", _("<b>Sub Systems</b>") + ":Data/:300",
]
lang = []
custom_lang = frappe.db.sql(
"""SELECT lang_code,lang_name,active_status FROM `tabCustom Languages`
where lang_code <> "en" order by lang_name;""", as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>" + "::300")
columns += lang
return columns, lang

83
smart_service/masters/report/systems_translation/systems_translation.py

@ -5,63 +5,70 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe.utils import cstr
from frappe import msgprint, _
current_db_name = frappe.conf.get("db_name")
# = frappe.conf.get("db_name")
def execute(filters=None):
columns, data = [], []
columns,lang = get_columns()
data = get_data()
return columns, data
columns, data = [], []
columns, lang = get_columns()
data = get_data()
return columns, data
def get_data():
custom_lang = frappe.db.sql("""SELECT lang_code FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_list=True)
def get_data():
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN %s.tabTranslation.translated_text ELSE null END) as %s" %(d[0],current_db_name,d[0])
queryAppendLang += q
custom_lang = frappe.db.sql("""SELECT lang_code FROM `tabCustom Languages` where lang_code <> "en"
order by lang_name;""", as_list=1)
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s"%(d[0],d[0])
sel+= r
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN tabTranslation.translated_text ELSE null END) as %s" % (
d[0], d[0])
queryAppendLang += q
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s" % (d[0], d[0])
sel += r
actualQuery = """Select
actualQuery = """Select
`tabSystems`.modified as "Modified On",
`tabSystems`.active_status as "Status",
`tabSystems`.system_name as 'Vehicle Segment'
%s
From %s.`tabSystems`
LEFT JOIN %s.`tabTranslation` as tabTrans
ON %s.`tabSystems`.system_name = tabTrans.source_text
From `tabSystems`
LEFT JOIN `tabTranslation` as tabTrans
ON `tabSystems`.system_name = tabTrans.source_text
LEFT JOIN (Select tabLang.languageCode as languageCode
,%s.tabTranslation.source_text as sourceText
, %s.tabTranslation.translated_text as translated_text
,tabTranslation.source_text as sourceText
,tabTranslation.translated_text as translated_text
%s
From %s.tabTranslation
From tabTranslation
INNER JOIN (SELECT tanLang.language_name as language_name
, tanLang.language_code as languageCode
FROM %s.tabLanguage as tanLang) as tabLang
ON %s.tabTranslation.language = tabLang.languageCode) as tabTranslation
ON %s.`tabSystems`.system_name = tabTranslation.sourceText;""" % (sel,current_db_name,current_db_name,current_db_name,current_db_name,current_db_name ,queryAppendLang,current_db_name,current_db_name,current_db_name,current_db_name)
FROM tabLanguage as tanLang) as tabLang
ON tabTranslation.language = tabLang.languageCode) as tabTranslation
ON `tabSystems`.system_name = tabTranslation.sourceText;""" % (sel, queryAppendLang)
data = frappe.db.sql(actualQuery, as_list=True)
data = frappe.db.sql(actualQuery,as_list=True)
return data
return data
def get_columns():
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") + ":Data/:100",_("<b>Systems</b>") + ":Data/:300",
]
lang = []
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>"+ "::300")
columns += lang
return columns,lang
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") +
":Data/:100", _("<b>Systems</b>") + ":Data/:300",
]
lang = []
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM `tabCustom Languages` where lang_code <> "en"
order by lang_name;""", as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>" + "::300")
columns += lang
return columns, lang

82
smart_service/masters/report/transmission_translation/transmission_translation.py

@ -5,61 +5,67 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe.utils import cstr
from frappe import msgprint, _
current_db_name = frappe.conf.get("db_name")
def execute(filters=None):
columns, data = [], []
columns,lang = get_columns()
data = get_data()
return columns, data
columns, data = [], []
columns, lang = get_columns()
data = get_data()
return columns, data
def get_data():
custom_lang = frappe.db.sql("""SELECT lang_code FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_list=True)
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN %s.tabTranslation.translated_text ELSE null END) as %s" %(d[0],current_db_name,d[0])
queryAppendLang += q
def get_data():
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s"%(d[0],d[0])
sel+= r
custom_lang = frappe.db.sql(
"""SELECT lang_code FROM `tabCustom Languages` where lang_code <> "en" order by lang_name;""", as_list=True)
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN tabTranslation.translated_text ELSE null END) as %s" % (
d[0], d[0])
queryAppendLang += q
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s" % (d[0], d[0])
sel += r
actualQuery = """Select
actualQuery = """Select
`tabTransmission`.modified as "Modified On",
`tabTransmission`.active_status as "Status",
`tabTransmission`.transmission as 'Transmission'
%s
From %s.`tabTransmission`
LEFT JOIN %s.`tabTranslation` as tabTrans
ON %s.`tabTransmission`.transmission = tabTrans.source_text
From `tabTransmission`
LEFT JOIN `tabTranslation` as tabTrans
ON `tabTransmission`.transmission = tabTrans.source_text
LEFT JOIN (Select tabLang.languageCode as languageCode
,%s.tabTranslation.source_text as sourceText
, %s.tabTranslation.translated_text as translated_text
,tabTranslation.source_text as sourceText
, tabTranslation.translated_text as translated_text
%s
From %s.tabTranslation
From tabTranslation
INNER JOIN (SELECT tanLang.language_name as language_name
, tanLang.language_code as languageCode
FROM %s.tabLanguage as tanLang) as tabLang
ON %s.tabTranslation.language = tabLang.languageCode) as tabTranslation
ON %s.`tabTransmission`.transmission = tabTranslation.sourceText;""" % (sel,current_db_name,current_db_name,current_db_name,current_db_name,current_db_name ,queryAppendLang,current_db_name,current_db_name,current_db_name,current_db_name)
FROM tabLanguage as tanLang) as tabLang
ON tabTranslation.language = tabLang.languageCode) as tabTranslation
ON `tabTransmission`.transmission = tabTranslation.sourceText
ORDER BY `tabTransmission`.modified DESC;""" % (sel, queryAppendLang)
data = frappe.db.sql(actualQuery, as_list=True)
return data
data = frappe.db.sql(actualQuery,as_list=True)
return data
def get_columns():
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") + ":Data/:100",_("<b>Transmission</b>") + ":Data/:220",
]
lang = []
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>"+ "::220")
columns += lang
return columns,lang
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") +
":Data/:100", _("<b>Transmission</b>") + ":Data/:220",
]
lang = []
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM `tabCustom Languages` where lang_code <> "en"
order by lang_name;""", as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>" + "::220")
columns += lang
return columns, lang

66
smart_service/masters/report/variant_translation/variant_translation.py

@ -5,35 +5,37 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe.utils import cstr
from frappe import msgprint, _
current_db_name = frappe.conf.get("db_name")
def execute(filters=None):
columns, data = [], []
columns,lang = get_columns()
data = get_data()
return columns, data
columns, data = [], []
columns, lang = get_columns()
data = get_data()
return columns, data
def get_data():
custom_lang = frappe.db.sql("""SELECT lang_code FROM `tabCustom Languages` where lang_code <> "en" order by lang_name""",as_list=True)
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN tabTranslation.translated_text ELSE null END) as %s" %(d[0],d[0])
queryAppendLang += q
custom_lang = frappe.db.sql(
"""SELECT lang_code FROM `tabCustom Languages` where lang_code <> "en" order by lang_name;""", as_list=True)
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN tabTranslation.translated_text ELSE null END) as %s" % (
d[0], d[0])
queryAppendLang += q
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s"%(d[0],d[0])
sel+= r
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s" % (d[0], d[0])
sel += r
actualQuery = """Select
actualQuery = """Select
`tabVariant`.modified as "Modified On",
`tabVariant`.active_status as "Status",
`tabVariant`.vehicle as "Vehicle",
`tabVariant`.variant as 'Variant'
%s
From `tabVariant`
LEFT JOIN `tabTranslation` as tabTrans
@ -47,21 +49,25 @@ def get_data():
, tanLang.language_code as languageCode
FROM tabLanguage as tanLang) as tabLang
ON tabTranslation.language = tabLang.languageCode) as tabTranslation
ON `tabVariant`.variant = tabTranslation.sourceText;""" % (sel ,queryAppendLang)
ON `tabVariant`.variant = tabTranslation.sourceText ORDER BY `tabVariant`.modified DESC;""" % (sel, queryAppendLang)
data = frappe.db.sql(actualQuery,as_list=True)
return data
data = frappe.db.sql(actualQuery, as_list=True)
return data
def get_columns():
columns = []
columns += [
_("<b>Modified On</b>") + ":Data/:240", _("<b>Status</b>") + ":Data/:100", _("<b>Vehicle</b>") + ":Data/:200",_("<b>Variant</b>") + ":Data/:220",
]
lang = []
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>"+ "::220")
columns += lang
return columns,lang
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:240", _("<b>Status</b>") +
":Data/:100", _("<b>Vehicle</b>") +
":Data/:200", _("<b>Variant</b>") + ":Data/:220",
]
lang = []
custom_lang = frappe.db.sql(
"""SELECT lang_code,lang_name,active_status FROM `tabCustom Languages` where lang_code <> "en"
order by lang_name;""", as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>" + "::220")
columns += lang
return columns, lang

114
smart_service/masters/report/vehicle_segment_translation/vehicle_segment_translation.py

@ -5,67 +5,71 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe.utils import cstr
from frappe import msgprint, _
current_db_name = frappe.conf.get("db_name")
def execute(filters=None):
columns, data = [], []
columns,lang = get_columns()
data = get_data()
return columns, data
def get_data():
custom_lang = frappe.db.sql("""SELECT lang_code FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_list=True)
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN %s.tabTranslation.translated_text ELSE null END) as %s" %(d[0],current_db_name,d[0])
queryAppendLang += q
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s"%(d[0],d[0])
sel+= r
actualQuery = """Select
`tabVehicle Segment`.modified as "Modified On",
`tabVehicle Segment`.active_status as "Status",
`tabVehicle Segment`.vehicle_segment as 'Vehicle Segment'
%s
From %s.`tabVehicle Segment`
LEFT JOIN %s.`tabTranslation` as tabTrans
ON %s.`tabVehicle Segment`.vehicle_segment = tabTrans.source_text
LEFT JOIN (Select tabLang.languageCode as languageCode
,%s.tabTranslation.source_text as sourceText
, %s.tabTranslation.translated_text as translated_text
%s
From %s.tabTranslation
INNER JOIN (SELECT tanLang.language_name as language_name
, tanLang.language_code as languageCode
FROM %s.tabLanguage as tanLang) as tabLang
ON %s.tabTranslation.language = tabLang.languageCode) as tabTranslation
ON %s.`tabVehicle Segment`.vehicle_segment = tabTranslation.sourceText;""" % (sel,current_db_name,current_db_name,current_db_name,current_db_name,current_db_name ,queryAppendLang,current_db_name,current_db_name,current_db_name,current_db_name)
def execute(filters=None):
columns, data = [], []
columns, lang = get_columns()
data = get_data()
return columns, data
data = frappe.db.sql(actualQuery,as_list=True)
return data
def get_data():
try:
custom_lang = frappe.db.sql(
"""SELECT lang_code FROM `tabCustom Languages` where lang_code <> "en" order by lang_name;""", as_list=True)
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN tabTranslation.translated_text ELSE null END) as %s" % (
d[0], d[0])
queryAppendLang += q
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s" % (d[0], d[0])
sel += r
actualQuery = """Select
`tabVehicle Segment`.modified as "Modified On",
`tabVehicle Segment`.active_status as "Status",
`tabVehicle Segment`.vehicle_segment as 'Vehicle Segment'
%s
From `tabVehicle Segment`
LEFT JOIN `tabTranslation` as tabTrans
ON `tabVehicle Segment`.vehicle_segment = tabTrans.source_text
LEFT JOIN (Select tabLang.languageCode as languageCode
,tabTranslation.source_text as sourceText
, tabTranslation.translated_text as translated_text
%s
From tabTranslation
INNER JOIN (SELECT tanLang.language_name as language_name
, tanLang.language_code as languageCode
FROM tabLanguage as tanLang) as tabLang
ON tabTranslation.language = tabLang.languageCode) as tabTranslation
ON `tabVehicle Segment`.vehicle_segment = tabTranslation.sourceText
ORDER BY `tabVehicle Segment`.modified DESC;""" % (sel, queryAppendLang)
data = frappe.db.sql(actualQuery, as_list=True)
return data
except Exception as e:
frappe.throw(str(frappe.get_traceback()))
def get_columns():
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") + ":Data/:100",_("<b>Vehicle Segment</b>") + ":Data/:220",
]
lang = []
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>"+ "::220")
columns += lang
return columns,lang
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") +
":Data/:100", _("<b>Vehicle Segment</b>") + ":Data/:220",
]
lang = []
custom_lang = frappe.db.sql(
"""SELECT lang_code,lang_name,active_status FROM `tabCustom Languages` where lang_code <> "en"
order by lang_name;""", as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>" + "::220")
columns += lang
return columns, lang

82
smart_service/masters/report/vehicle_translation/vehicle_translation.py

@ -5,61 +5,67 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe.utils import cstr
from frappe import msgprint, _
current_db_name = frappe.conf.get("db_name")
def execute(filters=None):
columns, data = [], []
columns,lang = get_columns()
data = get_data()
return columns, data
columns, data = [], []
columns, lang = get_columns()
data = get_data()
return columns, data
def get_data():
custom_lang = frappe.db.sql("""SELECT lang_code FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_list=True)
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN %s.tabTranslation.translated_text ELSE null END) as %s" %(d[0],current_db_name,d[0])
queryAppendLang += q
def get_data():
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s"%(d[0],d[0])
sel+= r
custom_lang = frappe.db.sql(
"""SELECT lang_code FROM `tabCustom Languages` where lang_code <> "en" order by lang_name;""", as_list=1)
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN tabTranslation.translated_text ELSE null END) as %s" % (
d[0], d[0])
queryAppendLang += q
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s" % (d[0], d[0])
sel += r
actualQuery = """Select
actualQuery = """Select
`tabVehicle`.modified as "Modified On",
`tabVehicle`.active_status as "Status",
`tabVehicle`.vehicle as 'Vehicle'
%s
From %s.`tabVehicle`
LEFT JOIN %s.`tabTranslation` as tabTrans
ON %s.`tabVehicle`.vehicle = tabTrans.source_text
From `tabVehicle`
LEFT JOIN `tabTranslation` as tabTrans
ON `tabVehicle`.vehicle = tabTrans.source_text
LEFT JOIN (Select tabLang.languageCode as languageCode
,%s.tabTranslation.source_text as sourceText
, %s.tabTranslation.translated_text as translated_text
,tabTranslation.source_text as sourceText
, tabTranslation.translated_text as translated_text
%s
From %s.tabTranslation
From tabTranslation
INNER JOIN (SELECT tanLang.language_name as language_name
, tanLang.language_code as languageCode
FROM %s.tabLanguage as tanLang) as tabLang
ON %s.tabTranslation.language = tabLang.languageCode) as tabTranslation
ON %s.`tabVehicle`.vehicle = tabTranslation.sourceText;""" % (sel,current_db_name,current_db_name,current_db_name,current_db_name,current_db_name ,queryAppendLang,current_db_name,current_db_name,current_db_name,current_db_name)
FROM tabLanguage as tanLang) as tabLang
ON tabTranslation.language = tabLang.languageCode) as tabTranslation
ON `tabVehicle`.vehicle = tabTranslation.sourceText ORDER BY `tabVehicle`.modified DESC;""" % (sel, queryAppendLang)
data = frappe.db.sql(actualQuery, as_list=True)
return data
data = frappe.db.sql(actualQuery,as_list=True)
return data
def get_columns():
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") + ":Data/:100",_("<b>Vehicle</b>") + ":Data/:220",
]
lang = []
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>"+ "::220")
columns += lang
return columns,lang
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") +
":Data/:100", _("<b>Vehicle</b>") + ":Data/:220",
]
lang = []
custom_lang = frappe.db.sql(
"""SELECT lang_code,lang_name,active_status FROM `tabCustom Languages` where lang_code <> "en"
order by lang_name;""", as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>" + "::220")
columns += lang
return columns, lang

1
smart_service/modules.txt

@ -2,3 +2,4 @@ Add Ons
Masters
Reports
Transactions
Phase-2

2
smart_service/overrides/overrides/override_file.py

@ -3,7 +3,7 @@ import frappe, json
import json
from frappe.utils import cstr, flt, cint, random_string
def validate(doc=None,method=None):
data = ['.jpg', '.png','.mp4', '.docx','.xls', '.pdf','.tiff','.ppt','.m4v','.doc','.pps','.pptx']
data = ['.jpg', '.png','.mp4', '.docx','.xls', '.pdf','.tiff','.m4v','.doc','.pps']
file_name = doc.file_name
total_count = 0
for i in data:

0
smart_service/phase_2/__init__.py

0
smart_service/phase_2/doctype/__init__.py

0
smart_service/phase_2/doctype/feature_finder/__init__.py

1254
smart_service/phase_2/doctype/feature_finder/feature_finder.js

File diff suppressed because it is too large

233
smart_service/phase_2/doctype/feature_finder/feature_finder.json

@ -0,0 +1,233 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "format:{variant}-{features_names}-{language}",
"creation": "2023-07-21 13:31:57.705945",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"is_published",
"section_break_o8kze",
"variant",
"language",
"display_order",
"active_status",
"column_break_mmuuc",
"vehicle",
"feature_name",
"features_names",
"translated_feature_name",
"feature_category",
"sop_name",
"keywords",
"section_break_u9bx1",
"image_html",
"create_feature_finder_images",
"post_vin_cutoff_id_tab",
"test_html",
"specification",
"feature_finder_images",
"feature_finder_content",
"vehicle_id",
"variant_id",
"tab_ref"
],
"fields": [
{
"fetch_from": "variant.vehicle",
"fieldname": "vehicle",
"fieldtype": "Data",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Vehicle",
"read_only": 1,
"reqd": 1
},
{
"fieldname": "language",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Language",
"options": "Custom Languages",
"reqd": 1,
"set_only_once": 1
},
{
"fieldname": "column_break_mmuuc",
"fieldtype": "Column Break"
},
{
"fieldname": "variant",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Variant",
"options": "Variant Mapping",
"reqd": 1,
"set_only_once": 1
},
{
"fieldname": "feature_name",
"fieldtype": "Link",
"hidden": 1,
"in_list_view": 1,
"label": "Feature Name1",
"options": "Feature Finder Master",
"read_only": 1,
"set_only_once": 1
},
{
"description": "Upload *.png(1920x1080 pixel) 1 MB",
"fieldname": "feature_finder_images",
"fieldtype": "Table",
"hidden": 1,
"label": "Feature Finder Images",
"options": "Feature Finder Images"
},
{
"fieldname": "feature_finder_content",
"fieldtype": "Table",
"hidden": 1,
"label": "Feature Finder Content",
"options": "Feature Finder Content"
},
{
"fieldname": "section_break_u9bx1",
"fieldtype": "Section Break"
},
{
"fieldname": "image_html",
"fieldtype": "HTML",
"label": "Image HTML"
},
{
"fieldname": "create_feature_finder_images",
"fieldtype": "Button",
"hidden": 1,
"label": "Add Feature Finder Images"
},
{
"fieldname": "display_order",
"fieldtype": "Int",
"in_list_view": 1,
"label": "Display Order",
"read_only_depends_on": "eval:doc.language!=\"en\""
},
{
"fieldname": "active_status",
"fieldtype": "Select",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Active Status",
"options": "Active\nInactive"
},
{
"fieldname": "specification",
"fieldtype": "Table",
"hidden": 1,
"label": "Specification",
"options": "Feature Finder Specification"
},
{
"depends_on": "eval:doc.feature_name",
"fetch_from": "feature_name.feature_category",
"fieldname": "feature_category",
"fieldtype": "Data",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Feature Category"
},
{
"depends_on": "eval:doc.variant",
"fieldname": "features_names",
"fieldtype": "Select",
"label": "Feature Name",
"reqd": 1,
"set_only_once": 1
},
{
"fieldname": "test_html",
"fieldtype": "HTML",
"label": "Test Html"
},
{
"fieldname": "post_vin_cutoff_id_tab",
"fieldtype": "Table",
"label": "Post Vin Cutoff ID",
"options": "Post Vin Cutoff ID"
},
{
"fetch_from": "variant.vehicle_id",
"fieldname": "vehicle_id",
"fieldtype": "Int",
"hidden": 1,
"label": "Vehicle Id"
},
{
"fetch_from": "variant.name",
"fieldname": "variant_id",
"fieldtype": "Data",
"hidden": 1,
"label": "Variant Id"
},
{
"fieldname": "translated_feature_name",
"fieldtype": "Data",
"label": "Translated Feature Name",
"mandatory_depends_on": "eval:doc.language!=\"en\"",
"read_only_depends_on": "eval:doc.language==\"en\""
},
{
"default": "0",
"fieldname": "is_published",
"fieldtype": "Check",
"label": "Published",
"read_only": 1
},
{
"fieldname": "section_break_o8kze",
"fieldtype": "Section Break"
},
{
"fieldname": "tab_ref",
"fieldtype": "Data",
"hidden": 1,
"label": "Tab Ref"
},
{
"fieldname": "keywords",
"fieldtype": "Small Text",
"label": "Keywords"
},
{
"fieldname": "sop_name",
"fieldtype": "Data",
"label": "SOP Name"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-11-24 16:28:33.427222",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC"
}

334
smart_service/phase_2/doctype/feature_finder/feature_finder.py

@ -0,0 +1,334 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
import frappe
from frappe.model.document import Document
import json
class FeatureFinder(Document):
# def validate(self):
# if self.feature_name and self.feature_type=="SOP":
# check_existing = frappe.db.sql(f"""select name from `tabFeature Finder` where feature_name='{self.feature_name}' and feature_type='SOP'
# and name!='{self.name}'""",as_dict=1)
# if len(check_existing)>0:
# frappe.throw("This Feature Name and Feature Type already exists")
# def autoname(self):
# if self.feature_type == "SOP":
# self.name = self.variant+"-"+self.features_names + \
# "-"+self.language+"-"+self.feature_type
# else:
# self.name = self.variant+"-"+self.features_names+"-" + \
# self.language+"-"+self.feature_type+"-"+self.post_vin_cutoff_id
def validate(self):
try:
if self.sop_name:
self.sop_name = self.sop_name.strip()
if self.is_new():
self.tab_ref = "SOP"
if self.variant and self.language and self.feature_name:
# check_exe = frappe.db.get_list("Feature Finder",
# filters={"variant": self.variant, "language": "en",
# "features_names": self.features_names,
# "name": ["!=", self.name]},
# fields={"name", "language", "display_order", "active_status"})
# check_exe = frappe.db.sql(f''' select * from `tabFeature Finder` where variant='{self.variant}' and features_names='{self.features_names}'
# and language='en' and name != '{self.name}' ;
# ''', as_dict=1)
check_exe = frappe.db.sql(''' select * from `tabFeature Finder` where variant='%s' and features_names='%s'
and language='en' and name != '%s' ;
''' % (self.variant, self.features_names, self.name), as_dict=1)
# frappe.log_error("check_exe",str(check_exe))
if check_exe:
if self.language != "en":
for d in check_exe:
self.display_order = d['display_order']
self.active_status = d['active_status']
if not check_exe:
if self.language != "en":
frappe.throw("First language will be english only")
if not self.is_new() and self.is_published == 1:
self.is_published = 0
# if len(self.specification)>0:
# specification = frappe.db.sql(f"""select * from `tabFeature Finder Specification` where parent = '{self.name}'""",as_dict=1)
# for d in self.specification:
# specification.append(d)
# set_idx = 0
# for k in specification:
# set_idx +=1
# k['']
except Exception as e:
raise e
def on_update(self):
if self.language == "en":
try:
check_exe = frappe.db.get_list("Feature Finder",
filters={"variant": self.variant, "language": ["!=", "en"],
"feature_name": self.feature_name,
"name": ["!=", self.name]},
fields={"name", "language", "display_order", "active_status"})
if check_exe:
for i in check_exe:
res = frappe.get_doc(
"Feature Finder", i['name'])
res.display_order = self.display_order
res.active_status = self.active_status
res.save()
except Exception as e:
raise e
@frappe.whitelist()
def get_feature_list(vehicle, language):
features_list = frappe.db.sql(
"""select feature_name from `tabFeature Finder Master` where vehicle='%s' and language = '%s';""" % (vehicle, language), as_list=1)
return features_list
@frappe.whitelist()
def get_list_data(name, val):
specification = frappe.db.sql(
"""select *,'Feature Finder Specification' as doctype from `tabFeature Finder Specification` where parent = '%s' and
post_vin_cutoff_name='%s'""" % (name, val), as_dict=1)
feature_finder_images = frappe.db.sql(
"""select * from `tabFeature Finder Images` where parent = '%s' and post_vin_cutoff_name='%s'""" % (name, val), as_dict=1)
feature_finder_content = frappe.db.sql(
"""select * from `tabFeature Finder Content` where parent = '%s' and post_vin_cutoff_name='%s'""" % (name, val), as_dict=1)
return specification, feature_finder_images, feature_finder_content
@frappe.whitelist()
def insert_spec_data(doc_name, values, tab_ref=None):
try:
val = json.loads(values)
get_count = frappe.db.sql("""select name from `tabFeature Finder Specification` where parent='%s' and feature_type='%s'""" % (
doc_name, val.get('feature_type')), as_dict=1)
get_count = len(get_count)+1
result = frappe.get_doc("Feature Finder", doc_name)
result.tab_ref = tab_ref
result.save()
frappe.db.commit()
if val.get('name') != None:
doc = frappe.get_doc("Feature Finder Specification", val['name'])
doc.specification = val.get('specification')
doc.value = val.get('value')
# doc.active_status = val.get('active_status')
doc.feature_type = val.get('feature_type')
doc.display_order = val.get('display_order')
doc.save()
frappe.db.commit()
else:
res = frappe.get_doc("Feature Finder", doc_name)
val['display_order'] = get_count
res.append("specification", val)
res.save()
return {"status": "success"}
except Exception as e:
frappe.log_error("insert_spec_data", str(e))
return {"status": "failure"}
@frappe.whitelist()
def delete_spec_data(values,doc_name):
try:
val = json.loads(values)
if len(val) > 0:
for d in val:
frappe.delete_doc("Feature Finder Specification", d)
frappe.db.commit()
if doc_name:
frappe.db.sql("""UPDATE `tabFeature Finder` set is_published='0' WHERE name ='%s'""" % (doc_name))
frappe.db.commit()
return {"status": "success"}
except Exception as e:
frappe.log_error("delete_spec_data", str(e))
@frappe.whitelist()
def insert_image_data(doc_name, values, tab_ref):
try:
val = json.loads(values)
get_count = frappe.db.sql("""select name from `tabFeature Finder Images` where parent='%s' and
feature_type='%s'""" % (doc_name, val.get('feature_type')), as_dict=1)
get_count = len(get_count)+1
result = frappe.get_doc("Feature Finder", doc_name)
result.tab_ref = tab_ref
result.save()
frappe.db.commit()
if val.get('name') != None:
doc = frappe.get_doc("Feature Finder Images", val['name'])
doc.image = val.get('image')
# doc.active_status = val.get('active_status')
doc.feature_type = val.get('feature_type')
doc.display_order = val.get('display_order')
doc.save()
frappe.db.commit()
else:
res = frappe.get_doc("Feature Finder", doc_name)
val['display_order'] = get_count
res.append("feature_finder_images", val)
res.save()
frappe.db.commit()
return {"status": "success"}
except Exception as e:
frappe.log_error("insert_image_data", str(e))
return {"status": "failure"}
@frappe.whitelist()
def delete_image_data(values,doc_name):
try:
val = json.loads(values)
if len(val) > 0:
for d in val:
frappe.delete_doc("Feature Finder Images", d)
frappe.db.commit()
if doc_name:
frappe.db.sql("""UPDATE `tabFeature Finder` set is_published='0' WHERE name ='%s'""" % (doc_name))
frappe.db.commit()
return {"status": "success"}
except Exception as e:
frappe.log_error("delete_image_data", str(e))
@frappe.whitelist()
def insert_content_data(doc_name, values, tab_ref=None):
try:
val = json.loads(values)
get_count = frappe.db.sql("""select name from `tabFeature Finder Content` where parent='%s' and
feature_type='%s'""" % (doc_name, val.get('feature_type')), as_dict=1)
get_count = len(get_count)+1
result = frappe.get_doc("Feature Finder", doc_name)
result.tab_ref = tab_ref
result.save()
frappe.db.commit()
if val.get('name') != None:
doc = frappe.get_doc("Feature Finder Content", val['name'])
doc.content = val.get('content')
# doc.active_status = val.get('active_status')
doc.feature_type = val.get('feature_type')
doc.display_order = val.get('display_order')
doc.save()
frappe.db.commit()
else:
res = frappe.get_doc("Feature Finder", doc_name)
val['display_order'] = get_count
res.append("feature_finder_content", val)
res.save()
frappe.db.commit()
return {"status": "success"}
except Exception as e:
frappe.log_error("insert_content_data", str(e))
return {"status": "failure"}
@frappe.whitelist()
def delete_content_data(values,doc_name):
try:
val = json.loads(values)
if len(val) > 0:
for d in val:
frappe.delete_doc("Feature Finder Content", d)
frappe.db.commit()
if doc_name:
frappe.db.sql("""UPDATE `tabFeature Finder` set is_published='0' WHERE name ='%s'""" % (doc_name))
frappe.db.commit()
return {"status": "success"}
except Exception as e:
frappe.log_error("delete_image_data", str(e))
# res.append("specification",{
# "specification":val.get('specification'),
# "value":val.get('value'),
# "active_status":val.get('active_status'),
# "feature_type":val.get('feature_type')
# })
@frappe.whitelist()
def set_display_order(doctype_name, values):
try:
if len(values) > 0:
val = json.loads(values)
if len(val) > 0:
count_val = 0
for k in val:
count_val += 1
frappe.log_error("k", (str(k)))
if k:
res = frappe.get_doc(doctype_name, k)
# frappe.msgprint(str(k)+"-"+str(count_val))
res.display_order = count_val
res.save()
frappe.db.commit()
return {"status": "success"}
else:
return {"status": "fail"}
except Exception as e:
frappe.log_error("set_display_order", frappe.get_traceback())
pass
@frappe.whitelist()
def get_specification_list():
res = frappe.db.sql(
"""select name from `tabFeature Finder Specification Master`""", as_dict=1)
return res
@frappe.whitelist()
def insert_tab_ref(docname, tab_ref):
try:
if docname and tab_ref:
frappe.db.sql("""UPDATE `tabFeature Finder` set tab_ref='%s' WHERE name ='%s'""" % (
tab_ref, docname))
frappe.db.commit()
except Exception as e:
frappe.log_error("insert_tab", frappe.get_traceback())
@frappe.whitelist()
def file_validation(image=None):
from smart_service.apis.utils import check_png_ext, check_img_ext,details_of_image
if image:
res = check_img_ext(image)
res1 = check_png_ext(image)
if res == True or res1==True:
(width, height, size) = details_of_image(image)
if width > 1920 or height > 1080 and image:
val = delete_feature_image(image)
if val == True:
return (False, 2)
else:
return True
else:
val = delete_feature_image(image)
if res == False:
ret = res
else:
ret = res1
return ret, 1
def delete_feature_image(file_url):
image_name = frappe.db.sql(f"""select name from `tabFile` where file_url='{file_url}'""",as_dict=1)
if len(image_name) > 0:
frappe.delete_doc('File', image_name[0]['name'])
return True

8
smart_service/phase_2/doctype/feature_finder/test_feature_finder.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and Contributors
# See license.txt
# import frappe
import unittest
class TestFeatureFinder(unittest.TestCase):
pass

0
smart_service/phase_2/doctype/feature_finder_category_master/__init__.py

29
smart_service/phase_2/doctype/feature_finder_category_master/feature_finder_category_master.js

@ -0,0 +1,29 @@
// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
// For license information, please see license.txt
frappe.ui.form.on('Feature Finder Category Master', {
validate: function (frm) {
check_field_character(frm.doc.feature_category)
check_field_character(frm.doc.feature_name)
}
});
function check_field_character(field_name) {
if (field_name) {
var alphanum = /^[a-zA-Z]+/;
if (field_name.length > 1) {
if (field_name.length > 50) {
frappe.throw("<b>Feature Finder Category Master:</b> Only <b> 100 </b> characters are allowed")
frappe.validated = false;
} else {
if (alphanum.test(field_name) === true) {
} else if (field_name) {
frappe.throw(__("<b>Feature Finder Category Master:</b> Enter letter or alpha numeric characters only."));
frappe.validated = false;
}
}
} else {
frappe.throw("<b>Feature Finder Category Master:</b> Single character not allowed")
frappe.validated = false;
}
}
}

75
smart_service/phase_2/doctype/feature_finder_category_master/feature_finder_category_master.json

@ -0,0 +1,75 @@
{
"_comments": "[]",
"_liked_by": "[]",
"actions": [],
"allow_rename": 1,
"autoname": "format:{feature_name}",
"creation": "2023-08-04 11:36:36.503213",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"feature_category",
"feature_name",
"column_break_qkvjq",
"active_status"
],
"fields": [
{
"fieldname": "feature_category",
"fieldtype": "Data",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Feature Category",
"reqd": 1,
"set_only_once": 1
},
{
"fieldname": "feature_name",
"fieldtype": "Data",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Feature Name",
"reqd": 1,
"set_only_once": 1,
"unique": 1
},
{
"fieldname": "active_status",
"fieldtype": "Select",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Active Status",
"options": "Active\nInactive"
},
{
"fieldname": "column_break_qkvjq",
"fieldtype": "Column Break"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-09-04 17:40:56.588347",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder Category Master",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"search_fields": "feature_name",
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "feature_name"
}

8
smart_service/phase_2/doctype/feature_finder_category_master/feature_finder_category_master.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
# import frappe
from frappe.model.document import Document
class FeatureFinderCategoryMaster(Document):
pass

8
smart_service/phase_2/doctype/feature_finder_category_master/test_feature_finder_category_master.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and Contributors
# See license.txt
# import frappe
import unittest
class TestFeatureFinderCategoryMaster(unittest.TestCase):
pass

0
smart_service/phase_2/doctype/feature_finder_content/__init__.py

50
smart_service/phase_2/doctype/feature_finder_content/feature_finder_content.json

@ -0,0 +1,50 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-07-21 13:55:18.779535",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"content",
"feature_type",
"post_vin_cutoff_name",
"display_order"
],
"fields": [
{
"fieldname": "content",
"fieldtype": "Small Text",
"in_list_view": 1,
"label": "Content"
},
{
"fieldname": "feature_type",
"fieldtype": "Data",
"label": "Feature Type"
},
{
"fieldname": "post_vin_cutoff_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Post Vin Cutoff Name"
},
{
"fieldname": "display_order",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Display Order"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-09-01 14:53:19.397112",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder Content",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}

8
smart_service/phase_2/doctype/feature_finder_content/feature_finder_content.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
# import frappe
from frappe.model.document import Document
class FeatureFinderContent(Document):
pass

0
smart_service/phase_2/doctype/feature_finder_disclaimer/__init__.py

30
smart_service/phase_2/doctype/feature_finder_disclaimer/feature_finder_disclaimer.json

@ -0,0 +1,30 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-07-21 14:37:31.662625",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"content"
],
"fields": [
{
"fieldname": "content",
"fieldtype": "Small Text",
"in_list_view": 1,
"label": "Content"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-09-01 16:56:05.940778",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder Disclaimer",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}

8
smart_service/phase_2/doctype/feature_finder_disclaimer/feature_finder_disclaimer.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
# import frappe
from frappe.model.document import Document
class FeatureFinderDisclaimer(Document):
pass

0
smart_service/phase_2/doctype/feature_finder_images/__init__.py

51
smart_service/phase_2/doctype/feature_finder_images/feature_finder_images.json

@ -0,0 +1,51 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-07-21 13:53:04.565458",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"image",
"feature_type",
"post_vin_cutoff_name",
"display_order"
],
"fields": [
{
"description": "Upload *.png(1920x1080 pixel) 1 MB",
"fieldname": "image",
"fieldtype": "Attach",
"in_list_view": 1,
"label": "Image"
},
{
"fieldname": "feature_type",
"fieldtype": "Data",
"label": "Feature Type"
},
{
"fieldname": "post_vin_cutoff_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Post Vin Cutoff Name"
},
{
"fieldname": "display_order",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Display Order"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-10-06 11:51:56.748496",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder Images",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}

8
smart_service/phase_2/doctype/feature_finder_images/feature_finder_images.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
# import frappe
from frappe.model.document import Document
class FeatureFinderImages(Document):
pass

0
smart_service/phase_2/doctype/feature_finder_master/__init__.py

35
smart_service/phase_2/doctype/feature_finder_master/feature_finder_master.js

@ -0,0 +1,35 @@
// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
// For license information, please see license.txt
frappe.ui.form.on('Feature Finder Master', {
refresh: function(frm) {
frm.set_query("feature_name", function() {
return {
"filters": {
"active_status": "Active",
}
};
});
},
validate:function(frm){
frappe.call({
method: "smart_service.phase_2.doctype.feature_finder_master.feature_finder_master.file_validation",
args: {
image: frm.doc.feature_pdf,
name:frm.doc.name
},
callback: function (r) {
console.log(r.message, "r.message")
if (r.message && r.message[0] == false) {
if (r.message[1] == 1) {
frappe.validated = false;
frappe.msgprint("Invalid file type")
}
}
}
})
}
});

103
smart_service/phase_2/doctype/feature_finder_master/feature_finder_master.json

@ -0,0 +1,103 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "format:{vehicle}-{feature_name}-{language}",
"creation": "2023-07-21 14:37:42.551453",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"vehicle",
"feature_name",
"feature_pdf",
"column_break_5ksna",
"language",
"feature_category",
"section_break_lyzco",
"feature_finder_disclaimer"
],
"fields": [
{
"fieldname": "feature_name",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Feature Name",
"options": "Feature Finder Category Master",
"reqd": 1,
"set_only_once": 1
},
{
"description": "Upload *.pdf 1 MB",
"fieldname": "feature_pdf",
"fieldtype": "Attach",
"label": "Compare PDF"
},
{
"fieldname": "feature_finder_disclaimer",
"fieldtype": "Table",
"label": "Feature Finder Disclaimer",
"options": "Feature Finder Disclaimer",
"reqd": 1
},
{
"fieldname": "column_break_5ksna",
"fieldtype": "Column Break"
},
{
"fieldname": "section_break_lyzco",
"fieldtype": "Section Break"
},
{
"fieldname": "vehicle",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Vehicle",
"options": "Vehicle",
"reqd": 1
},
{
"fieldname": "language",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Language",
"options": "Custom Languages",
"reqd": 1
},
{
"fetch_from": "feature_name.feature_category",
"fieldname": "feature_category",
"fieldtype": "Data",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Feature Category"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-10-06 11:50:42.654103",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder Master",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"search_fields": "feature_name",
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "feature_name"
}

42
smart_service/phase_2/doctype/feature_finder_master/feature_finder_master.py

@ -0,0 +1,42 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
import frappe
from frappe.model.document import Document
class FeatureFinderMaster(Document):
pass
@frappe.whitelist()
def file_validation(image =None, name=None, value=None):
from smart_service.apis.utils import check_png_ext, check_img_ext,check_pdf_ext,details_of_image
if image:
res = check_pdf_ext(image)
if res == True:
pass
# (width, height, size) = details_of_image(image)
# if width > 640 or height > 360 and image:
# val = delete_feature_image(image)
# if val == True:
# return (False, 2)
# else:
# return True
else:
val = delete_file(image, 'Feature Finder Master',
"feature_pdf", name)
if res == False:
ret = res
return ret, 1
def delete_file(file_url, attached_to_doctype, attached_to_field, docname, is_child=None):
image_name = frappe.db.get_list("File", fields={"name"}, filters={"file_url": file_url,
"attached_to_doctype": attached_to_doctype,
"attached_to_field": attached_to_field,
"attached_to_name": docname})
if len(image_name) > 0:
frappe.delete_doc('File', image_name[0]['name'])
return True

8
smart_service/phase_2/doctype/feature_finder_master/test_feature_finder_master.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and Contributors
# See license.txt
# import frappe
import unittest
class TestFeatureFinderMaster(unittest.TestCase):
pass

0
smart_service/phase_2/doctype/feature_finder_publish_data/__init__.py

137
smart_service/phase_2/doctype/feature_finder_publish_data/feature_finder_publish_data.json

@ -0,0 +1,137 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-08-10 22:37:14.844640",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"is_published",
"variant",
"language",
"display_order",
"column_break_mmuuc",
"vehicle",
"feature_name",
"features_names",
"feature_category",
"vehicle_id",
"variant_id",
"parent1",
"data_9xkxt"
],
"fields": [
{
"default": "0",
"fieldname": "is_published",
"fieldtype": "Check",
"label": "Published",
"read_only": 1
},
{
"fieldname": "variant",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Variant",
"options": "Variant Mapping",
"read_only": 1,
"set_only_once": 1
},
{
"fieldname": "language",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Language",
"options": "Custom Languages",
"read_only": 1,
"set_only_once": 1
},
{
"fieldname": "display_order",
"fieldtype": "Int",
"label": "Display Order",
"read_only": 1,
"read_only_depends_on": "eval:doc.language!=\"en\""
},
{
"fieldname": "column_break_mmuuc",
"fieldtype": "Column Break"
},
{
"fetch_from": "variant.vehicle",
"fieldname": "vehicle",
"fieldtype": "Data",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Vehicle",
"read_only": 1
},
{
"depends_on": "eval:doc.variant!=\"\"",
"fieldname": "feature_name",
"fieldtype": "Link",
"hidden": 1,
"label": "Feature Name1",
"options": "Feature Finder Master",
"read_only": 1,
"set_only_once": 1
},
{
"depends_on": "eval:doc.variant",
"fieldname": "features_names",
"fieldtype": "Data",
"label": "Feature Name",
"read_only": 1,
"set_only_once": 1
},
{
"depends_on": "eval:doc.feature_name",
"fetch_from": "feature_name.feature_category",
"fieldname": "feature_category",
"fieldtype": "Data",
"label": "Feature Category",
"read_only": 1
},
{
"fetch_from": "variant.vehicle_id",
"fieldname": "vehicle_id",
"fieldtype": "Int",
"hidden": 1,
"label": "Vehicle Id",
"read_only": 1
},
{
"fetch_from": "variant.name",
"fieldname": "variant_id",
"fieldtype": "Data",
"hidden": 1,
"label": "Variant Id",
"read_only": 1
},
{
"fieldname": "parent1",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Parent",
"options": "Feature Finder",
"read_only": 1
},
{
"fieldname": "data_9xkxt",
"fieldtype": "Data"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-09-01 15:49:01.572389",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder Publish Data",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}

8
smart_service/phase_2/doctype/feature_finder_publish_data/feature_finder_publish_data.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
# import frappe
from frappe.model.document import Document
class FeatureFinderPublishData(Document):
pass

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save