Browse Source

Feature fiinder

version2
venkataakhil 1 year ago
parent
commit
7ebe7d5749
  1. 44
      smart_service/phase_2/doctype/feature_finder/feature_finder.js
  2. 2
      smart_service/phase_2/doctype/feature_finder/feature_finder.json
  3. 14
      smart_service/phase_2/doctype/feature_finder_publish_data/feature_finder_publish_data.json
  4. 45
      smart_service/phase_2/doctype/publish_test/publish_test.js
  5. 9
      smart_service/phase_2/doctype/publish_test/publish_test.json
  6. 185
      smart_service/phase_2/doctype/publish_test/publish_test.py

44
smart_service/phase_2/doctype/feature_finder/feature_finder.js

@ -747,7 +747,7 @@ function custom_tab_html(frm) {
default: spec_dialog_value.specification,
get_query() {
return {
filters: { 'Active Status': 'Active' }
filters: { 'active_status': 'Active' }
}
}
@ -983,33 +983,33 @@ function set_display_order(frm) {
});
}
frappe.ui.form.on('Feature Finder Specification', {
// frappe.ui.form.on('Feature Finder Specification', {
specification_add: function (frm, cdt, cdn) {
var child2 = locals[cdt][cdn];
child2.post_vin_cutoff_name = filter_value
refresh_field("specification");
}
// specification_add: function (frm, cdt, cdn) {
// var child2 = locals[cdt][cdn];
// child2.post_vin_cutoff_name = filter_value
// refresh_field("specification");
// }
})
// })
frappe.ui.form.on('Feature Finder Content', {
// frappe.ui.form.on('Feature Finder Content', {
feature_finder_content_add: function (frm, cdt, cdn) {
var child = locals[cdt][cdn];
child.post_vin_cutoff_name = filter_value
refresh_field("feature_finder_content");
},
})
// feature_finder_content_add: function (frm, cdt, cdn) {
// var child = locals[cdt][cdn];
// child.post_vin_cutoff_name = filter_value
// refresh_field("feature_finder_content");
// },
// })
frappe.ui.form.on('Feature Finder Images', {
// frappe.ui.form.on('Feature Finder Images', {
feature_finder_images_add: function (frm, cdt, cdn) {
var child = locals[cdt][cdn];
child.post_vin_cutoff_name = filter_value
refresh_field("feature_finder_images");
},
})
// feature_finder_images_add: function (frm, cdt, cdn) {
// var child = locals[cdt][cdn];
// child.post_vin_cutoff_name = filter_value
// refresh_field("feature_finder_images");
// },
// })

2
smart_service/phase_2/doctype/feature_finder/feature_finder.json

@ -194,7 +194,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-08-14 17:49:28.825452",
"modified": "2023-08-16 11:07:09.586411",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder",

14
smart_service/phase_2/doctype/feature_finder_publish_data/feature_finder_publish_data.json

@ -17,7 +17,8 @@
"features_names",
"feature_category",
"vehicle_id",
"variant_id"
"variant_id",
"parent1"
],
"fields": [
{
@ -48,13 +49,13 @@
{
"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,
"label": "Active Status",
"options": "Active\nIn Active"
},
@ -108,12 +109,19 @@
"fieldtype": "Data",
"hidden": 1,
"label": "Variant Id"
},
{
"fieldname": "parent1",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Parent",
"options": "Feature Finder"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-08-10 22:37:14.844640",
"modified": "2023-08-16 11:16:08.697524",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder Publish Data",

45
smart_service/phase_2/doctype/publish_test/publish_test.js

@ -53,23 +53,7 @@ frappe.ui.form.on('Publish Test', {
},
refresh: function (frm) {
// if (frm.doc.docstatus == 1 && !frm.is_new() && frm.doc.publish_type != "Global" && frm.doc.publish_module=='Others') {
// frm.add_custom_button(__('Global Publish'), function () {
// // frappe.call({
// // method: "tsmcvcms.transactions.doctype.publish_details.publish_details.generate_global_publish",
// // args: {
// // name: frm.doc.name
// // },
// // callback: function (r) {
// // if (r.message.status == "success") {
// // window.location.href = r.message.url + "/app/publish-details" + "/" + r.message.message
// // }
// // }
// // })
// }).addClass("btn-primary");
// }
// $('[data-route="Form/Publish Test/' + frm.doc.name + '"]').find('.primary-action').html("Internal Publish")
if (frm.doc.docstatus == 0 && !frm.is_new() && frm.doc.publish_type != "Global") {
$('[data-route="Form/Publish Test/' + frm.doc.name + '"]').find('.primary-action').html("Internal Publish")
}
@ -360,7 +344,7 @@ frappe.ui.form.on('Publish Test', {
}
//check for atleast one data to publish
if (frm.doc.publish_module == 'Others' && !frm.doc.hasOwnProperty('repair_checksheet_publish')) {
if (frm.doc.publish_module == 'Others' && !frm.doc.hasOwnProperty('repair_checksheet_publish') && !frm.doc.hasOwnProperty('feature_finder_publish')) {
frappe.throw('No Data Found To Publish')
@ -619,10 +603,9 @@ function add_to_publish(frm) {
method: "smart_service.phase_2.doctype.publish_test.publish_test.get_service_repair",
args: { vehicle: frm.doc.vehicle, language_label: frm.doc.language, publish_type: frm.doc.publish_type },
callback: function (r) {
if (r.message) {
if (r.message.length>0) {
cur_frm.set_df_property('repair_checksheet_publish', 'hidden', 0)
var records = r.message
debugger
records.map(v => {
var childTable = cur_frm.add_child("repair_checksheet_publish");
childTable.parent_name = v['name'];
@ -637,7 +620,29 @@ function add_to_publish(frm) {
childTable.lang_myid = v['lang_myid'];
})
cur_frm.refresh_fields("repair_checksheet_publish");
cur_frm.refresh_field("repair_checksheet_publish");
}
}
})
frappe.call({
method: "smart_service.phase_2.doctype.publish_test.publish_test.get_feature_finder",
args: { vehicle: frm.doc.vehicle, language_label: frm.doc.language, publish_type: frm.doc.publish_type },
callback: function (r) {
if (r.message.length>0) {
cur_frm.set_df_property('feature_finder_publish', 'hidden', 0)
var records = r.message
records.map(v => {
var childTable = cur_frm.add_child("feature_finder_publish");
childTable.parent1 = v['name'];
childTable.vehicle = v['vehicle'];
childTable.language = v['language'];
childTable.variant = v['variant'];
childTable.active_status = v['active_status'];
})
cur_frm.refresh_field("feature_finder_publish");
}
}
})

9
smart_service/phase_2/doctype/publish_test/publish_test.json

@ -45,6 +45,7 @@
"section_break_5",
"publish_documents",
"repair_checksheet_publish",
"feature_finder_publish",
"amended_from"
],
"fields": [
@ -324,12 +325,18 @@
"options": "Publish Test",
"print_hide": 1,
"read_only": 1
},
{
"fieldname": "feature_finder_publish",
"fieldtype": "Table",
"label": "Feature Finder Publish",
"options": "Feature Finder Publish Data"
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2023-08-11 12:19:11.733139",
"modified": "2023-08-16 10:54:06.672131",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Publish Test",

185
smart_service/phase_2/doctype/publish_test/publish_test.py

@ -20,6 +20,7 @@ base_url = os.path.expanduser(
frappe.utils.logger.set_log_level("DEBUG")
success_reponse = {"status": 1, "data": "", "message": ""}
failure_reponse = {"status": 0, "data": "", "error": ""}
module_name='feature_finder'
class PublishTest(Document):
@ -51,6 +52,8 @@ class PublishTest(Document):
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Others' and self.publish_type == 'Internal':
repair_checksheet_publish(self.vehicle, self.vehicle_id, self.language, self.publish_type,
self.release_description, self.variant, self.repair_checksheet_publish)
feature_finder_publish(self.vehicle, self.vehicle_id, self.language, self.publish_type,
self.release_description,self.feature_finder_publish)
update_publish_status = frappe.db.sql(
"""update `tabPublish Test` set publish_status='Published' where name='{0}'""".format(self.name))
if self.docstatus == 1 and self.publish_module == 'Others' and self.publish_type == 'Global':
@ -267,7 +270,8 @@ def generate_global_publish(name):
"language": res.language,
"release_description": res.release_description,
"publish_module": res.publish_module,
"repair_checksheet_publish": res.repair_checksheet_publish
"repair_checksheet_publish": res.repair_checksheet_publish,
"feature_finder_publish":res.feature_finder_publish
})
ret.insert()
return {"status": "success", "message": ret.name, "url": frappe.utils.get_url()}
@ -440,12 +444,21 @@ def update_procedure_value(name, file_path):
@frappe.whitelist()
def get_service_repair(vehicle, language_label, publish_type):
def get_service_repair(vehicle,
language_label, publish_type):
data = frappe.db.sql(f'''
select * from `tabRepair Service Mapping` where vehicle = '{vehicle}' and language='{language_label}' and published = 0;
''', as_dict=1)
return data
@frappe.whitelist()
def get_feature_finder(vehicle,language_label):
try:
data=frappe.db.sql(f"""select * from `tabFeature Finder` where vehicle='{vehicle}' and language='{language_label}' and is_published=0""",as_dict=1)
return data
except Exception as e:
return str(e)
def repair_checksheet_publish(vehicle, vehicle_id,
language, publish_type, release_description,
@ -489,15 +502,12 @@ def repair_checksheet_publish(vehicle, vehicle_id,
publish_type, i.parent_name)
if repair_checksheet['status'] == 1:
publish_repair_checksheet = 1
if len(repair_checksheet['data']) > 0:
# Compare with existing
global_publish['data']['repair_checksheet'].append(
repair_checksheet_tmp.append(
repair_checksheet['data'][0])
repair_checksheet_tmp = published_data['data']['repair_checksheet']
frappe.msgprint('file_exists' + str(published_data))
repair_checksheet_tmp=get_latest_data({'data':published_data['data']},{'data':repair_checksheet_tmp})
else:
frappe.msgprint(str('new file'))
for i in parent:
repair_checksheet = repair_checksheet_data(
vehicle, language, publish_type, i.parent_name)
@ -507,6 +517,9 @@ def repair_checksheet_publish(vehicle, vehicle_id,
if len(repair_checksheet['data']):
repair_checksheet_tmp.append(
repair_checksheet['data'][0])
# frappe.msgprint(str(repair_checksheet['data'][0]))
repair_checksheet_tmp=get_latest_data({'data':repair_checksheet_tmp},{'data':[]})
frappe.msgprint(str(repair_checksheet_tmp))
if publish_repair_checksheet == 1:
""" Save publish file """
@ -522,6 +535,87 @@ def repair_checksheet_publish(vehicle, vehicle_id,
f'{vehicle} - {language} - {publish_type} error in json creation' + str(e))
frappe.throw('Failed To Publish')
def feature_finder_publish(vehicle=None, language=None,
vehicle_id=None,publish_type=None,
release_description=None,parent=None):
try:
logger_file = f'{vehicle} - {language} - {publish_type} - {module_name}'
logger = frappe.logger(logger_file,
allow_site=True, file_count=100)
logger.info(
f"start of fetching repair checksheet data - {vehicle} - {language} - {module_name}")
folder_url = base_url+"/"+vehicle.replace(' ', '-') + "/"+language
logger.info(f'Created Folder-{vehicle}-{language}-{publish_type}')
'''Final Json'''
vehicle_data = {
'vehicle': vehicle,
'vehicle_myid': vehicle_id,
'publish_type': publish_type,
'publish_description': release_description,
'publish_language': language,
'data': ''
}
'''Publish Ready Flags'''
publish_feature_finder = 0
feature_finder_tmp = []
'''Create Folder For Publish'''
create_publish_folders(folder_url)
file_path = folder_url + "/" + publish_type + "/" + \
vehicle.replace(' ', '-') + '-feature_finder' + '.json'
'''Append Published Data to Json'''
logger.info(
f'Repair Checksheet Data Append Start::{vehicle}-{language}-{publish_type}')
'''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:
feature_finder = feature_finder_data(
vehicle, language, publish_type, i.parent)
if feature_finder['status'] == 1:
publish_feature_finder = 1
if len(feature_finder['data']):
feature_finder_tmp.append(
feature_finder['data'][0])
feature_finder_tmp=get_latest_data({'data':feature_finder_tmp},{'data':[]})
frappe.msgprint(str(feature_finder_tmp))
if publish_feature_finder == 1:
""" Save publish file """
vehicle_data['data'] = feature_finder_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} - {module_name} error in json creation' + str(e))
frappe.throw('Failed To Publish')
def update_published_docs(self):
try:
@ -565,6 +659,7 @@ def get_key_value_data(data):
def get_latest_data(prev_data, latest_data):
data_dic1 = get_key_value_data(prev_data)
data_dic2 = get_key_value_data(latest_data)
@ -581,6 +676,8 @@ def get_latest_data(prev_data, latest_data):
final_dic.update({d2: data_dic2[d2]})
final_list = list(final_dic.values())
frappe.msgprint(str(final_list))
return final_list
@ -625,6 +722,74 @@ def repair_checksheet_data(vehicle=None, language=None,
def feature_finder_data(vehicle=None, language=None,
publish_type=None, parent=None):
try:
pass
logger_file = f'{vehicle} - {language} - {publish_type} - {module_name}'
logger = frappe.logger(logger_file,
allow_site=True, file_count=100)
logger.info(
f"start of fetching feature finder checksheet data - {vehicle} - {language} - {module_name}")
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.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} and ff.name="{parent}";
""", 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.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}" and ff.name="{parent}" ; """, as_dict=1)
for f in feature_finder_details:
f['disclaimer'] = frappe.db.sql(f'''
SELECT name,content,active_status,idx as display_order FROM `tabFeature Finder Disclaimer`
where parent = '{str(f['vehicle'])+ str('-')+ str(f['feature_name']) +str('-')+str(f['language'])}';
''', as_dict=1)
sop_images = frappe.db.sql(f""" select image,idx as display_order,active_status from `tabFeature Finder Images` where
parent = '{f['name']}' and feature_type ='SOP';""", as_dict=1)
sop_content = frappe.db.sql(f"""select content,idx as display_order, active_status from `tabFeature Finder Content`
where parent = '{f['name']}' and feature_type ='SOP';""", as_dict=1)
sop_specification = frappe.db.sql(f"""select specification,value,idx as display_order,active_status from `tabFeature Finder Specification`
where parent = '{f['name']}' and feature_type ='SOP';""", as_dict=1)
f['sop'] = {'content': sop_content, 'images': sop_images,
'specificaton': sop_specification}
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']}';''', as_dict=1)
for p in post_vin_data:
vin_content = frappe.db.sql(f"""select content,idx as display_order, active_status from `tabFeature Finder Content`
where parent = '{f['name']}' and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}';""", as_dict=1)
vin_images = frappe.db.sql(f""" select image,idx as display_order,active_status from `tabFeature Finder Images` where
parent = '{f['name']}' and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}';""", as_dict=1)
vin_specification = frappe.db.sql(f"""select specification,value,idx as display_order,active_status from `tabFeature Finder Specification`
where parent = '{f['name']}' and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}';""", as_dict=1)
p['content'] = vin_content
p['images'] = vin_images
p['specificaton'] = vin_specification
f['post_vin'] = post_vin_data
logger.info(
f"end of fetching feature finder data {vehicle} - {language}")
success_reponse['data'] = feature_finder_details
success_reponse[
'message'] = f'Repair Checksheet Fecthed Succesfully for {vehicle} - {language}'
return success_reponse
except Exception as e:
pass
failure_reponse['error'] = f"{vehicle} - {language} has following error - " + str(
e)
logger.error('error in repair checksheet' + str(e))
return failure_reponse

Loading…
Cancel
Save