Compare commits

...

15 Commits

Author SHA1 Message Date
venkataakhil aceebfb85d Special character remove * 2 years ago
venkataakhil 2fab47a15b FIle ext final push 2 years ago
venkataakhil ef62143c27 Base url 2 years ago
venkataakhil dedc92ed2c Base url 2 years ago
venkataakhil 9e4bc69452 Base url 2 years ago
venkataakhil 35000f9cec Base url 2 years ago
venkataakhil 989205a2c8 File ext file path validation 2 years ago
venkataakhil 1ab39640c3 File ext file path validation 2 years ago
venkataakhil 277a2408bb File ext file path validation 2 years ago
venkataakhil f388404c64 File ext validation 2 years ago
venkataakhil 0e7fb020e2 File ext validation 2 years ago
venkataakhil 26e1e4e1e5 File ext validation 2 years ago
venkataakhil 96f7c68093 File ext validation 2 years ago
venkataakhil 92d46f4158 Allow special charcter + 2 years ago
venkataakhil 1229b595b5 reformat : 2 years ago
  1. 40
      smart_service/apis/master_api.py
  2. 5
      smart_service/transactions/doctype/procedure/procedure.js

40
smart_service/apis/master_api.py

@ -389,29 +389,43 @@ def asset_to_files_path():
def change_file_dir():
data = frappe.db.sql('''
select name,file from tabProcedure_Details where content_type = 'File';''', as_dict=1)
for d in data:
path = os.path.join(base_url, d['file'])
isExist = os.path.exists(path)
base_path = os.path.expanduser(
"~") + "/frappe-bench/sites/" + site_name + "/public"
file_data = frappe.db.sql('''
select name,file from tabProcedure_Details where content_type = 'File' ;''', as_dict=1)
changed_file_list = []
for d in file_data:
frappe.log_error("File data :", str(d))
path = d['file']
isExist = os.path.exists(base_path + path)
frappe.log_error("Path exists :", str(isExist))
if not isExist:
frappe.log_error("Invalid file:", str(path))
ext = path[-3:]
path = path[:-3]
extension = ''
if ext == 'png':
extension = 'jpg'
if ext == 'jpg':
extension = 'png'
path = path[:-3] + extension
if os.path.exists(path):
file_name = d[:-3]+ extension
frappe.log_error("New file :", str(file_name))
new_full_path = path + extension
frappe.log_error("New path:", str(new_full_path))
new_file_dir = base_path + new_full_path
if os.path.exists(new_file_dir):
changed_file_list.append(str(new_full_path))
frappe.db.sql(f'''
update tabProcedure_Details set file = '{d[:-3]+ ext}' where content_type = 'File' and name = '{d['name']}';
update tabProcedure_Details set file = '{new_full_path}' where content_type = 'File' and name = '{d['name']}';
''')
# frappe.db.commit()
frappe.db.commit()
return data
frappe.log_error("ALL updated files", str(changed_file_list))
if file_data:
return file_data
else:
return "Done"

5
smart_service/transactions/doctype/procedure/procedure.js

@ -35,14 +35,15 @@ frappe.ui.form.on('Procedure', {
},
validate: function (frm) {
var regex = /[@#$%^*+\\[\]{}`~\\|\?]+/;
// var regex = /[@#$%^*\\[\]{}`~\\|\?]/;
var regex = /[@#$%^\\[\]{}`~\\|\?]/;
if (frm.doc.procedure_details) {
for (var i = 0; i < frm.doc.procedure_details.length; i++) {
if (regex.test(frm.doc.procedure_details[i].content) === true) {
if (frm.doc.procedure_details[i].content_type != "Link") {
frm.doc.procedure_details[i].content_type = ''
frm.refresh_fields();
frappe.msgprint(__("<b>Content:</b> Only letters, numbers and <b> - ,'<>_()!=/±;</b> are allowed."));
frappe.msgprint(__("<b>Content:</b> Only letters, numbers and <b> - ,'<>_()!=/:+;</b> are allowed."));
}
}
}

Loading…
Cancel
Save