|
@ -6,7 +6,7 @@ from frappe.model.document import Document |
|
|
from frappe.utils import cstr |
|
|
from frappe.utils import cstr |
|
|
import zipfile |
|
|
import zipfile |
|
|
import os |
|
|
import os |
|
|
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,check_ppt_ext,get_file_size,check_html_ext |
|
|
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,check_ppt_ext,get_file_size,check_html_ext,check_ppt_ext,check_web_link |
|
|
site_name = cstr(frappe.local.site) |
|
|
site_name = cstr(frappe.local.site) |
|
|
|
|
|
|
|
|
BASE_URL = os.path.expanduser( |
|
|
BASE_URL = os.path.expanduser( |
|
@ -32,6 +32,12 @@ class TrainingInformation(Document): |
|
|
self.my_id = 1 |
|
|
self.my_id = 1 |
|
|
if not self.is_new() and self.is_published == 1: |
|
|
if not self.is_new() and self.is_published == 1: |
|
|
self.is_published = 0 |
|
|
self.is_published = 0 |
|
|
|
|
|
|
|
|
|
|
|
if self.content: |
|
|
|
|
|
for d in self.content: |
|
|
|
|
|
if len(d.file_name)>100: |
|
|
|
|
|
frappe.throw("<b>"+str(d.topic)+ ":"+"</b>"+"File Name should not exceed more than 100 characters") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except Exception as e: |
|
|
except Exception as e: |
|
|
raise e |
|
|
raise e |
|
@ -164,11 +170,13 @@ def file_validation_child(name, value=None): |
|
|
if name: |
|
|
if name: |
|
|
child_data = frappe.db.sql( |
|
|
child_data = frappe.db.sql( |
|
|
"""select * from `tabTraining Information Content Reference` where parent='%s';""" % (name), as_dict=1) |
|
|
"""select * from `tabTraining Information Content Reference` where parent='%s';""" % (name), as_dict=1) |
|
|
|
|
|
frappe.log_error(str(child_data)) |
|
|
for d in child_data: |
|
|
for d in child_data: |
|
|
if d['topic'] and d['file_url']: |
|
|
if d['topic']: |
|
|
res = False |
|
|
res = False |
|
|
res1 = False |
|
|
res1 = False |
|
|
if d['topic'] =="PDF": |
|
|
if d['topic'] =="PDF": |
|
|
|
|
|
frappe.log_error(str(d['topic'])) |
|
|
res = check_pdf_ext(d['file_url']) |
|
|
res = check_pdf_ext(d['file_url']) |
|
|
|
|
|
|
|
|
if d['topic'] =="PPT": |
|
|
if d['topic'] =="PPT": |
|
@ -186,6 +194,9 @@ def file_validation_child(name, value=None): |
|
|
|
|
|
|
|
|
if d['topic'] == "HTML": |
|
|
if d['topic'] == "HTML": |
|
|
res = check_zip_ext(d['file_url']) |
|
|
res = check_zip_ext(d['file_url']) |
|
|
|
|
|
|
|
|
|
|
|
if d['topic'] == "Web Links": |
|
|
|
|
|
break |
|
|
|
|
|
|
|
|
if res==True or res1==True: |
|
|
if res==True or res1==True: |
|
|
valuess,idx = get_file_details(d['topic'],d['file_url'],value,name,1,d['idx'],d['name']) |
|
|
valuess,idx = get_file_details(d['topic'],d['file_url'],value,name,1,d['idx'],d['name']) |
|
|