Browse Source

vehicle preview depends condition and special char updated

master
Ubuntu 3 years ago
parent
commit
886ac15224
  1. 27
      smart_service/apis/master_api.py
  2. 12
      smart_service/fixtures/client_script.json
  3. 3
      smart_service/masters/doctype/systems/systems.json
  4. 50
      smart_service/masters/doctype/systems/systems.py
  5. 3
      smart_service/masters/doctype/vehicle/vehicle.json
  6. 21
      smart_service/masters/doctype/vehicle/vehicle.py
  7. 26
      smart_service/transactions/report/audit_report/audit_report.py

27
smart_service/apis/master_api.py

@ -8,7 +8,6 @@ from frappe.utils import cstr
current_db_name = frappe.conf.get("db_name")
@frappe.whitelist()
def masters(args, LSD):
try:
@ -16,7 +15,7 @@ def masters(args, LSD):
api = frappe.db.get_list(
"Vehicle",
fields=[
"vehicle",
"name as vehicle",
"vehicle_segment",
"vehicle_segment_id",
"image",
@ -38,7 +37,7 @@ def masters(args, LSD):
api = frappe.db.get_list(
"Variant",
fields=[
"vehicle",
"name as vehicle",
"vehicle_segment",
"variant",
"myid as variant_id",
@ -58,11 +57,11 @@ def masters(args, LSD):
api = frappe.db.get_list(
"Vehicle Segment",
fields=[
"vehicle_segment",
"name as vehicle_segment",
"active_status",
"display_order",
"myid as vehicle_segment_id",
"modified",
"modified"
],
filters={"modified": [">", LSD]},
)
@ -76,7 +75,7 @@ def masters(args, LSD):
api = frappe.db.get_list(
"Transmission",
fields=[
"transmission",
"name as transmission",
"active_status",
"myid as transmission_id",
"modified",
@ -92,7 +91,7 @@ def masters(args, LSD):
elif args == "drive":
api = frappe.db.get_list(
"Drive",
fields=["drive", "active_status", "myid as drive_id", "modified"],
fields=["name as drive", "active_status", "myid as drive_id", "modified"],
filters={"modified": [">", LSD]},
)
for i in api:
@ -104,7 +103,7 @@ def masters(args, LSD):
elif args == "fuel":
api = frappe.db.get_list(
"Fuel",
fields=["fuel", "active_status", "myid as fuel_id", "modified"],
fields=["name as fuel", "active_status", "myid as fuel_id", "modified"],
filters={"modified": [">", LSD]},
)
for i in api:
@ -117,7 +116,7 @@ def masters(args, LSD):
api = frappe.db.get_list(
"Systems",
fields=[
"system_name",
"name as system_name",
"active_status",
"icon_file",
"myid as system_id",
@ -135,7 +134,7 @@ def masters(args, LSD):
api = frappe.db.get_list(
"Sub Systems",
fields=[
"sub_system_name",
"name as sub_system_name",
"active_status",
"myid as sub_system_id",
"modified",
@ -152,7 +151,7 @@ def masters(args, LSD):
api = frappe.db.get_list(
"Service Kilometers",
fields=[
"kilometer",
"name as kilometer",
"active_status",
"myid as service_kilometers_id",
"modified",
@ -232,6 +231,12 @@ def masters(args, LSD):
return api
# @frappe.whitelist()
# def testFile():
# mime = magic.Magic(mime=True)
# return mime.from_file("/home/ubuntu/frappe-bench/sites/guidedsmartservice.com/public/files/anydesk.xlsx")
def labels_json():
labels_lst = frappe.db.sql(
"""SELECT `tabApp Labels`.name as name,`tabApp Labels`.page_name as menu_type, `tabApp Labels`.english_label as element, `tabApp Labels`.language as lang, `tabApp Labels`.label as label, `tabApp Labels`.parent_app_labels as parent FROM {0}.`tabApp Labels` order by name asc""".format(

12
smart_service/fixtures/client_script.json

File diff suppressed because one or more lines are too long

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

@ -42,6 +42,7 @@
"label": "Icon File"
},
{
"depends_on": "eval:doc.icon_file",
"fieldname": "icon_preview",
"fieldtype": "Image",
"label": "Icon Preview",
@ -59,7 +60,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-03-31 14:49:04.303134",
"modified": "2022-04-01 13:01:57.103930",
"modified_by": "Administrator",
"module": "Masters",
"name": "Systems",

50
smart_service/masters/doctype/systems/systems.py

@ -1,8 +1,54 @@
# Copyright (c) 2021, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
# import frappe
import frappe
from frappe.model.document import Document
from PIL import Image
from frappe.utils import cstr
import os
class Systems(Document):
pass
def validate(self):
pass
@frappe.whitelist()
def image_size(image,doc):
current_db_name = frappe.conf.get("db_name")
doc = frappe.get_doc("Systems",doc)
site_name = cstr(frappe.local.site)
file_path = "/home/ubuntu/frappe-bench/sites/"+site_name +"/public" + image
size = os.path.getsize(file_path)
img = Image.open(file_path)
width = img.width
height = img.height
if(width > 510 and height > 510):
frappe.db.sql("""delete from `tabFile` where file_url = %s""",image)
frappe.db.commit()
a = frappe.db.sql("""select name from {0}.`tabFile` where file_url = '{1}'""".format(current_db_name,image))
frappe.msgprint(str(a))
return image
if(size > 10485760 ):
frappe.db.sql("""delete from `tabFile` where file_url = %s""",image)
frappe.db.commit()
return size
@frappe.whitelist()
def image_size(image,doc):
current_db_name = frappe.conf.get("db_name")
site_name = cstr(frappe.local.site)
file_path = "/home/ubuntu/frappe-bench/sites/"+site_name +"/public" + image
size = os.path.getsize(file_path)
img = Image.open(file_path)
width = img.width
height = img.height
# if size > 10485760000:
# frappe.db.sql("""delete from {0}.`tabFile` where file_url = '{1}'""".format(current_db_name,image))
# frappe.db.commit()
# return size
if (width > 2048 or height > 1080):
frappe.db.sql("""delete from {0}.`tabFile` where file_url = '{1}'""".format(current_db_name,image))
frappe.db.commit()
return image

3
smart_service/masters/doctype/vehicle/vehicle.json

@ -58,6 +58,7 @@
"set_only_once": 1
},
{
"depends_on": "eval:doc.image",
"fieldname": "preview",
"fieldtype": "Image",
"label": "Preview",
@ -119,7 +120,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-03-28 16:15:54.574158",
"modified": "2022-04-01 17:41:13.606316",
"modified_by": "Administrator",
"module": "Masters",
"name": "Vehicle",

21
smart_service/masters/doctype/vehicle/vehicle.py

@ -61,12 +61,15 @@ def image_size(image,doc):
img = Image.open(file_path)
width = img.width
height = img.height
if(width > 510 and height > 510):
frappe.db.sql("""delete from `tabFile` where file_url = %s""",image)
frappe.db.commit()
return image
if(size > 10485760 ):
frappe.db.sql("""delete from `tabFile` where file_url = %s""",image)
frappe.db.commit()
return size
# if size > 1048576 :
# frappe.db.sql("""delete from {0}.`tabFile` where file_url = '{1}'""".format(current_db_name,image))
# frappe.db.commit()
# return size
if width > 2048 and height > 1080:
frappe.db.sql("""delete from {0}.`tabFile` where file_url = '{1}'""".format(current_db_name,image))
frappe.db.commit()
return image

26
smart_service/transactions/report/audit_report/audit_report.py

@ -40,7 +40,6 @@ def getData(filters):
and substring(`tabProcedure_Details`.parent, -2) = 'en'
order by `tabSystem Mapping_Sub System`.systems ,`tabSystem Mapping_Sub System`.sub_systems,`procedure`,idx;
""".format(current_db_name, fil), as_dict=True)
filterData = filters.variant_mapping
if filterData != None and len(data) > 0:
data = modifyData(data, filterData)
@ -57,7 +56,7 @@ def statusLengthAppend(dicVal,parameter):
def modifyData(dataInput, filterParent):
list1 = []
inputData = modifyChildData(dataInput, indent=6, header=0)
inputData = modifyChildData(dataInput, indent=5, header=0)
parentAppend = addParent(filterParent, indent=0, header=1)
sMap, sSize = getParentMap(inputData, 'systems')
systemSize = statusLengthAppend(sSize,'System')
@ -87,21 +86,19 @@ def modifyData(dataInput, filterParent):
val = j['procedure_name']
proc = j['procedure']
procMap, procSize = getParentMap(ssMap[val], 'procedure_name')
print(procMap)
procValuesDic = appendToDic3(
procMap, procSize, j, indent=3, header=0, procedure=proc)
procLength = statusLengthAppend(procValuesDic,'Procedure')
j['active_status'] = j['active_status'] + ' / ' + procLength
list1.append(j)
for d in procValuesDic:
list1.append(d)
for pm in procMap:
list1.append({'procedure_name': pm, 'indent': 4,'header':0,'active_status':'','modified':''})
for pm in procMap:
step_list,steps_size = getParentMap(procMap[pm], 'step_name')
stepLength = statusLengthAppend(steps_size,'Step')
list1.append({'procedure_name': pm, 'indent': 3,'header':0,'active_status':stepLength,'modified':''})
for sl in step_list:
list1.append({'procedure_name': sl, 'indent': 5,'header':0,'active_status':'','modified':''})
list1.append({'procedure_name': sl, 'indent': 4,'header':0,'active_status':'','modified':''})
for ss in step_list[sl]:
ss.update({'procedure_name':ss['content_type']})
list1.append(ss)
@ -110,8 +107,6 @@ def modifyData(dataInput, filterParent):
appendData = removeDuplicateAndHeader(appendData)
return appendData
def print(sts):
frappe.msgprint(str(sts))
def appendToDic1(mapData, indent, header):
mapDataAppend = []
@ -193,12 +188,11 @@ def appendToDic3(mapData, procSize, j, indent, header, procedure):
dateList.append(str(k['modified']))
dateList.sort(key=lambda date: datetime.strptime(date, "%Y-%m-%d %H:%M:%S.%f"))
# if procSize[i] == 1:
# stepLength = str(procSize[i]) + " Step"
# else:
# stepLength = str(procSize[i]) + " Steps"
if len(mapData[u]) ==1:
stepLength = str(len(mapData[u])) + " Step"
else:
stepLength = str(len(mapData[u])) + " Steps"
stepLength = "TEsting"
procDict = {
'systems': mapData[u][0]['systems'],
'sub_systems': mapData[u][0]['sub_systems'],

Loading…
Cancel
Save