|
|
@ -59,25 +59,24 @@ class Publish(Document): |
|
|
|
|
|
|
|
def on_submit(self): |
|
|
|
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Repair service' and self.publish_type == 'Internal': |
|
|
|
repair_res_obj=repair_checksheet_publish(self.vehicle, self.vehicle_id, |
|
|
|
repair_res_obj = repair_checksheet_publish(self.vehicle, self.vehicle_id, |
|
|
|
self.language, self.publish_type, |
|
|
|
self.release_description, self.variant, |
|
|
|
self.repiar_checksheet_publish_docs) |
|
|
|
|
|
|
|
|
|
|
|
update_publish_status = frappe.db.sql( |
|
|
|
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name)) |
|
|
|
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Qwik Service' and self.publish_type == 'Internal': |
|
|
|
qwik_service_publish(self.vehicle, self.vehicle_id,self.variant, |
|
|
|
self.language,self.publish_type, |
|
|
|
self.release_description,self.qwik_service_publish_docs) |
|
|
|
qwik_service_publish(self.vehicle, self.vehicle_id, self.variant, |
|
|
|
self.language, self.publish_type, |
|
|
|
self.release_description, self.qwik_service_publish_docs) |
|
|
|
|
|
|
|
update_publish_status = frappe.db.sql( |
|
|
|
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name)) |
|
|
|
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Qwik Service' and self.publish_type == 'Global' and self.qwik_service_publish_docs: |
|
|
|
qwik_service_publish(self.vehicle, self.vehicle_id,self.variant, |
|
|
|
self.language,self.publish_type, |
|
|
|
self.release_description,self.qwik_service_publish_docs) |
|
|
|
qwik_service_publish(self.vehicle, self.vehicle_id, self.variant, |
|
|
|
self.language, self.publish_type, |
|
|
|
self.release_description, self.qwik_service_publish_docs) |
|
|
|
update_publish_status = frappe.db.sql( |
|
|
|
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name)) |
|
|
|
|
|
|
@ -125,7 +124,9 @@ class Publish(Document): |
|
|
|
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name)) |
|
|
|
|
|
|
|
variant = self.variant_mapping_details.split('/n') |
|
|
|
|
|
|
|
frappe.log_error('publish type', str(self.publish_type)) |
|
|
|
update_publish_mapping(self.vehicle, self.variant_mapping, |
|
|
|
self.language, self.publish_module, self.publish_type) |
|
|
|
|
|
|
|
def on_cancel(self): |
|
|
|
# Published document should not allow to cancel |
|
|
@ -184,16 +185,19 @@ def update_procedure(vehicle, lang, publish_type, doc): |
|
|
|
frappe.throw("There is no item for global publish") |
|
|
|
|
|
|
|
# Generate Publish versions |
|
|
|
|
|
|
|
|
|
|
|
def update_qwik_published_docs(self): |
|
|
|
try: |
|
|
|
for d in self.qwik_service_publish_docs: |
|
|
|
frappe.db.sql( |
|
|
|
"""UPDATE `tabQwik Service` set is_published=1 where name='{0}'""".format(d.parent1)) |
|
|
|
"""UPDATE `tabQwik Service` set is_published=1 where name='{0}'; """.format(d.parent1)) |
|
|
|
frappe.db.commit() |
|
|
|
|
|
|
|
except Exception as ex: |
|
|
|
return str(ex) |
|
|
|
|
|
|
|
|
|
|
|
def update_publish_mapping(vehicle, variant, language, module, publish_type): |
|
|
|
frappe.set_user('Administrator') |
|
|
|
if module == 'Repair service': |
|
|
@ -209,6 +213,18 @@ def update_publish_mapping(vehicle, variant, language, module, publish_type): |
|
|
|
f"""UPDATE `tabModule Publish Mapping` set repairservice_check_sheet='1' and publish_type='1' where name ='{d['name']}'""", as_dict=1) |
|
|
|
frappe.db.commit() |
|
|
|
|
|
|
|
elif module == 'Special Tool': |
|
|
|
pub_data = frappe.db.get_list('Module Publish Mapping', filters={ |
|
|
|
"vehicle": vehicle, |
|
|
|
"language": language, |
|
|
|
"publish_type": publish_type |
|
|
|
}, fields=['name']) |
|
|
|
if len(pub_data) > 0: |
|
|
|
for d in pub_data: |
|
|
|
if d['name']: |
|
|
|
frappe.db.sql( |
|
|
|
f"""UPDATE `tabModule Publish Mapping` set mahindra_special_tool_information='1' and publish_type='1' where name ='{d['name']}'""", as_dict=1) |
|
|
|
frappe.db.commit() |
|
|
|
else: |
|
|
|
pub_data = frappe.db.get_list('Module Publish Mapping', filters={ |
|
|
|
"vehicle": vehicle, |
|
|
@ -224,7 +240,8 @@ def update_publish_mapping(vehicle, variant, language, module, publish_type): |
|
|
|
'doctype': 'Module Publish Mapping', |
|
|
|
"vehicle": vehicle, |
|
|
|
"variant": variant, |
|
|
|
"language": language |
|
|
|
"language": language, |
|
|
|
"publish_type": publish_type |
|
|
|
}) |
|
|
|
if module == 'Automotive System': |
|
|
|
doc.automotive_system = 1 |
|
|
@ -235,6 +252,8 @@ def update_publish_mapping(vehicle, variant, language, module, publish_type): |
|
|
|
elif module == 'Feature Finder': |
|
|
|
doc.feature_finder = 1 |
|
|
|
|
|
|
|
elif module == 'Qwik Service': |
|
|
|
doc.qwik_service = 1 |
|
|
|
|
|
|
|
doc.save() |
|
|
|
|
|
|
@ -555,9 +574,7 @@ def update_procedure_value(name, file_path): |
|
|
|
|
|
|
|
def update_feature_published_docs(self): |
|
|
|
try: |
|
|
|
|
|
|
|
for d in self.feature_finder_publish_docs: |
|
|
|
|
|
|
|
frappe.db.sql( |
|
|
|
"""UPDATE `tabFeature Finder` set is_published=1 where name='{0}'""".format(d.parent1)) |
|
|
|
frappe.db.commit() |
|
|
@ -568,9 +585,7 @@ def update_feature_published_docs(self): |
|
|
|
|
|
|
|
def update_repair_published_docs(self): |
|
|
|
try: |
|
|
|
|
|
|
|
for d in self.repair_checksheet_publish: |
|
|
|
|
|
|
|
frappe.db.sql( |
|
|
|
"""UPDATE `tabRepair Service Mapping` set published=1 where name='{0}'""".format(d.parent_name)) |
|
|
|
frappe.db.commit() |
|
|
@ -578,11 +593,10 @@ def update_repair_published_docs(self): |
|
|
|
except Exception as e: |
|
|
|
frappe.throw(str(e)) |
|
|
|
|
|
|
|
|
|
|
|
def update_special_tool_publish_docs(self): |
|
|
|
try: |
|
|
|
|
|
|
|
for d in self.special_tool_publish_docs: |
|
|
|
|
|
|
|
frappe.db.sql( |
|
|
|
"""UPDATE `tabSpecial Tool Information` set published=1 where name='{0}'""".format(d.parent1)) |
|
|
|
frappe.db.commit() |
|
|
@ -592,7 +606,6 @@ def update_special_tool_publish_docs(self): |
|
|
|
|
|
|
|
def create_publish_folders(folder_url): |
|
|
|
try: |
|
|
|
|
|
|
|
if not os.path.isdir(folder_url + "/" + "Global"): |
|
|
|
os.makedirs(folder_url + "/" + "Global") |
|
|
|
|
|
|
@ -604,6 +617,7 @@ def create_publish_folders(folder_url): |
|
|
|
frappe.throw(str(e)) |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
'''New Module Publish Section''' |
|
|
|
|
|
|
|
|
|
|
@ -717,8 +731,6 @@ def repair_checksheet_publish(vehicle, vehicle_id, |
|
|
|
frappe.throw('Failed To Publish') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def feature_finder_publish(vehicle=None, vehicle_id=None, |
|
|
|
language=None, publish_type=None, |
|
|
|
release_description=None, parent=None, |
|
|
@ -830,9 +842,10 @@ def feature_finder_publish(vehicle=None, vehicle_id=None, |
|
|
|
f'{vehicle} - {language} - {publish_type} - {module_name} error in json creation' + str(e)) |
|
|
|
frappe.throw('Failed To Publish') |
|
|
|
|
|
|
|
def qwik_service_publish(vehicle = None , vehicle_id = None,variant = None, |
|
|
|
language = None,publish_type = None, |
|
|
|
release_description=None,parent = None): |
|
|
|
|
|
|
|
def qwik_service_publish(vehicle=None, vehicle_id=None, variant=None, |
|
|
|
language=None, publish_type=None, |
|
|
|
release_description=None, parent=None): |
|
|
|
try: |
|
|
|
logger_file = f'{variant} - {language} - {publish_type} - Qwik_service' |
|
|
|
logger = frappe.logger(logger_file, allow_site=True, file_count=100) |
|
|
@ -845,7 +858,7 @@ def qwik_service_publish(vehicle = None , vehicle_id = None,variant = None, |
|
|
|
'''Publish Ready Flags''' |
|
|
|
publish_qwik_service = 0 |
|
|
|
qwik_service_tmp = [] |
|
|
|
qwik_service='' |
|
|
|
qwik_service = '' |
|
|
|
|
|
|
|
'''Create Folder For Publish''' |
|
|
|
create_publish_folders(folder_url) |
|
|
@ -861,7 +874,7 @@ def qwik_service_publish(vehicle = None , vehicle_id = None,variant = None, |
|
|
|
vehicle_data = { |
|
|
|
'vehicle': vehicle, |
|
|
|
'vehicle_myid': vehicle_id, |
|
|
|
'variant':variant, |
|
|
|
'variant': variant, |
|
|
|
'publish_type': publish_type, |
|
|
|
'publish_description': release_description, |
|
|
|
'publish_language': language, |
|
|
@ -874,8 +887,8 @@ def qwik_service_publish(vehicle = None , vehicle_id = None,variant = None, |
|
|
|
|
|
|
|
for i in parent: |
|
|
|
qwik_service = qwik_service_data( |
|
|
|
language,publish_type,i.variant,i.parent1,vehicle) |
|
|
|
if qwik_service['status'] == 1 and len(qwik_service['data'])>0: |
|
|
|
language, publish_type, i.variant, i.parent1, vehicle) |
|
|
|
if qwik_service['status'] == 1 and len(qwik_service['data']) > 0: |
|
|
|
publish_qwik_service = 1 |
|
|
|
qwik_service_tmp.append( |
|
|
|
qwik_service['data'][0]) |
|
|
@ -894,15 +907,14 @@ def qwik_service_publish(vehicle = None , vehicle_id = None,variant = None, |
|
|
|
published_data = json.load(f) |
|
|
|
for i in parent: |
|
|
|
qwik_service = qwik_service_data( |
|
|
|
language,publish_type,i.variant,i.parent1,vehicle) |
|
|
|
if qwik_service['status'] == 1 and len(qwik_service['data'])>0: |
|
|
|
language, publish_type, i.variant, i.parent1, vehicle) |
|
|
|
if qwik_service['status'] == 1 and len(qwik_service['data']) > 0: |
|
|
|
publish_qwik_service = 1 |
|
|
|
qwik_service_tmp.append( |
|
|
|
qwik_service['data'][0]) |
|
|
|
|
|
|
|
qwik_service_tmp = create_df(qwik_service_tmp) |
|
|
|
|
|
|
|
|
|
|
|
vehi_data = compare_get_data({'data': published_data['data']}, { |
|
|
|
'data': qwik_service_tmp}) |
|
|
|
if vehi_data: |
|
|
@ -914,9 +926,9 @@ def qwik_service_publish(vehicle = None , vehicle_id = None,variant = None, |
|
|
|
else: |
|
|
|
for i in parent: |
|
|
|
qwik_service = qwik_service_data( |
|
|
|
language,publish_type,i.variant,i.parent1,vehicle) |
|
|
|
language, publish_type, i.variant, i.parent1, vehicle) |
|
|
|
|
|
|
|
if qwik_service['status'] == 1 and len(qwik_service['data'])>0: |
|
|
|
if qwik_service['status'] == 1 and len(qwik_service['data']) > 0: |
|
|
|
publish_qwik_service = 1 |
|
|
|
qwik_service_tmp.append( |
|
|
|
qwik_service['data'][0]) |
|
|
@ -933,9 +945,10 @@ def qwik_service_publish(vehicle = None , vehicle_id = None,variant = None, |
|
|
|
with open(file_path, 'w') as outfile: |
|
|
|
outfile.write(json.dumps(vehicle_data, indent=4, default=str)) |
|
|
|
|
|
|
|
|
|
|
|
except Exception as e: |
|
|
|
logger.error(f'{variant} - {language} - {publish_type} - Qwik_service'+str(e)) |
|
|
|
logger.error( |
|
|
|
f'{variant} - {language} - {publish_type} - Qwik_service'+str(e)) |
|
|
|
|
|
|
|
|
|
|
|
def special_tool_publish(vehicle, vehicle_id, |
|
|
|
publish_type, release_description, |
|
|
@ -957,7 +970,7 @@ def special_tool_publish(vehicle, vehicle_id, |
|
|
|
create_publish_folders(folder_url) |
|
|
|
file_path = folder_url + "/" + publish_type + "/" + \ |
|
|
|
vehicle.replace(' ', '-') + '-special_tool' + '.json' |
|
|
|
existing_global= folder_url + "/" + "Global" + "/" + \ |
|
|
|
existing_global = folder_url + "/" + "Global" + "/" + \ |
|
|
|
vehicle.replace(' ', '-') + '-special_tool' + '.json' |
|
|
|
|
|
|
|
'''Append Published Data to Json''' |
|
|
@ -972,24 +985,26 @@ def special_tool_publish(vehicle, vehicle_id, |
|
|
|
} |
|
|
|
|
|
|
|
'''update existing global json file''' |
|
|
|
if os.path.isfile(existing_global) and publish_type=='Internal': |
|
|
|
if os.path.isfile(existing_global) and publish_type == 'Internal': |
|
|
|
with open(existing_global) as f: |
|
|
|
published_data = json.load(f) |
|
|
|
for i in parent: |
|
|
|
special_tool = special_tool_data(vehicle,publish_type, i.parent1) |
|
|
|
if special_tool['status'] == 1 and len(special_tool['data'])>0: |
|
|
|
special_tool = special_tool_data( |
|
|
|
vehicle, publish_type, i.parent1) |
|
|
|
if special_tool['status'] == 1 and len(special_tool['data']) > 0: |
|
|
|
publish_special_tool = 1 |
|
|
|
special_tool_tmp.append( |
|
|
|
special_tool['data'][0]) |
|
|
|
|
|
|
|
special_tool_tmp = get_latest_data({'data': published_data['data']}, { |
|
|
|
'data': special_tool_tmp}) |
|
|
|
elif os.path.isfile(file_path) and publish_type=='Global': |
|
|
|
elif os.path.isfile(file_path) and publish_type == 'Global': |
|
|
|
with open(existing_global) as f: |
|
|
|
published_data = json.load(f) |
|
|
|
for i in parent: |
|
|
|
special_tool = special_tool_data(vehicle,publish_type, i.parent1) |
|
|
|
if special_tool['status'] == 1 and len(special_tool['data'])>0: |
|
|
|
special_tool = special_tool_data( |
|
|
|
vehicle, publish_type, i.parent1) |
|
|
|
if special_tool['status'] == 1 and len(special_tool['data']) > 0: |
|
|
|
publish_special_tool = 1 |
|
|
|
special_tool_tmp.append( |
|
|
|
special_tool['data'][0]) |
|
|
@ -1004,13 +1019,13 @@ def special_tool_publish(vehicle, vehicle_id, |
|
|
|
|
|
|
|
if special_tool['status'] == 1: |
|
|
|
publish_special_tool = 1 |
|
|
|
if len(special_tool['data'])>0: |
|
|
|
if len(special_tool['data']) > 0: |
|
|
|
special_tool_tmp.append( |
|
|
|
special_tool['data'][0]) |
|
|
|
special_tool_tmp = get_latest_data( |
|
|
|
{'data': special_tool_tmp}, {'data': []}) |
|
|
|
|
|
|
|
if publish_special_tool== 1: |
|
|
|
if publish_special_tool == 1: |
|
|
|
""" Save publish file """ |
|
|
|
vehicle_data['data'] = special_tool_tmp |
|
|
|
|
|
|
@ -1262,7 +1277,9 @@ def feature_finder_data(vehicle=None, language=None, |
|
|
|
e) |
|
|
|
logger.error('error in repair checksheet' + str(e)) |
|
|
|
return failure_reponse |
|
|
|
def qwik_service_data(language,publish_type,variant,parent,vehicle): |
|
|
|
|
|
|
|
|
|
|
|
def qwik_service_data(language, publish_type, variant, parent, vehicle): |
|
|
|
|
|
|
|
try: |
|
|
|
logger_file = f'fetch qwik data {variant} - {language}' |
|
|
@ -1301,6 +1318,7 @@ def qwik_service_data(language,publish_type,variant,parent,vehicle): |
|
|
|
|
|
|
|
logger.error('error in qwik service data' + str(e)) |
|
|
|
|
|
|
|
|
|
|
|
def special_tool_data(vehicle=None, |
|
|
|
publish_type=None, parent=None): |
|
|
|
try: |
|
|
@ -1310,7 +1328,6 @@ def special_tool_data(vehicle=None, |
|
|
|
logger.info( |
|
|
|
f"start of fetching special tool data - {parent}") |
|
|
|
|
|
|
|
|
|
|
|
special_tool_information = frappe.db.sql(''' select name,vehicle,tool_type, |
|
|
|
category,tool_name,aggregate_name,aggregate_image, |
|
|
|
pdf,keywords,display_order,my_id,active_status from |
|
|
@ -1336,6 +1353,7 @@ def special_tool_data(vehicle=None, |
|
|
|
logger.error('error in special tool' + str(e)) |
|
|
|
return failure_reponse |
|
|
|
|
|
|
|
|
|
|
|
@frappe.whitelist() |
|
|
|
def max_publish_new_module(doc): |
|
|
|
doc = frappe.get_doc("Publish", doc) |
|
|
@ -1372,18 +1390,20 @@ def cal_ver_new_module(vehicle, lang, publish_type, doc): |
|
|
|
frappe.db.commit() |
|
|
|
return v |
|
|
|
|
|
|
|
|
|
|
|
@frappe.whitelist() |
|
|
|
def get_qwik_service(variant=None,language_label=None,kilometers=None): |
|
|
|
def get_qwik_service(variant=None, language_label=None, kilometers=None): |
|
|
|
try: |
|
|
|
data = frappe.db.sql("""select * from `tabQwik Service` where variant='%s' |
|
|
|
and language = '%s' and is_published = '%s';"""%(variant,language_label,0),as_dict=1) |
|
|
|
and language = '%s' and is_published = '%s';""" % (variant, language_label, 0), as_dict=1) |
|
|
|
|
|
|
|
return data |
|
|
|
except Exception as e: |
|
|
|
return e |
|
|
|
|
|
|
|
|
|
|
|
@frappe.whitelist() |
|
|
|
def get_special_tool(vehicle=None, publish_type=None): |
|
|
|
data = frappe.db.sql(''' |
|
|
|
select * from `tabSpecial Tool Information` where vehicle ='%s' and published = '%s';'''%(vehicle,0), as_dict=1) |
|
|
|
select * from `tabSpecial Tool Information` where vehicle ='%s' and published = '%s';''' % (vehicle, 0), as_dict=1) |
|
|
|
return data |