|
|
@ -27,13 +27,45 @@ class SpecialToolInformation(Document): |
|
|
|
if not self.is_new() and self.published == 1: |
|
|
|
self.published = 0 |
|
|
|
|
|
|
|
@frappe.whitelist() |
|
|
|
def file_validation(image, name, value=None): |
|
|
|
from smart_service.apis.utils import check_png_ext, check_img_ext, check_zip_ext, check_pdf_ext,checking_image, details_of_image,check_mp4_ext ,get_file_size |
|
|
|
if image: |
|
|
|
res = check_img_ext(image) |
|
|
|
res1 = check_png_ext(image) |
|
|
|
if res == True: |
|
|
|
(width, height, size) = details_of_image(image) |
|
|
|
if value == 'image': |
|
|
|
if width > 1280 or height > 720 or size > 1*1024 and image: |
|
|
|
val = checking_image(image, 'Special Tool Information', |
|
|
|
value, name) |
|
|
|
if val == True: |
|
|
|
return (False, 2) |
|
|
|
else: |
|
|
|
return True |
|
|
|
|
|
|
|
if value == 'aggregate_image': |
|
|
|
if width > 1280 or height > 720 or size > 1*1024 and image: |
|
|
|
val = checking_image(image, 'Special Tool Information', |
|
|
|
value, name) |
|
|
|
if val == True: |
|
|
|
return (False, 2) |
|
|
|
else: |
|
|
|
return True |
|
|
|
else: |
|
|
|
val = checking_image(image, 'Special Tool Information', value, name) |
|
|
|
if res == False: |
|
|
|
ret = res |
|
|
|
else: |
|
|
|
ret = res1 |
|
|
|
return ret, 1 |
|
|
|
|
|
|
|
@frappe.whitelist() |
|
|
|
def file_validation_child(name, value=None): |
|
|
|
from smart_service.apis.utils import check_png_ext, check_img_ext, check_zip_ext, check_pdf_ext, details_of_image, checking_image, check_mp4_ext, get_file_size |
|
|
|
if name: |
|
|
|
child_data = frappe.db.sql( |
|
|
|
"""select * from `tabtabInstructions` where parent='%s'"""%(name), as_dict=1) |
|
|
|
"""select * from `tabInstructions` where parent='%s'"""%(name), as_dict=1) |
|
|
|
for d in child_data: |
|
|
|
if d['attach_file']: |
|
|
|
res = False |
|
|
|