File api (#15637)
* file-api: major refactor migrate from file_manager.py to file.py Signed-off-by: Chinmay Pai <chinmaydpai@gmail.com> * file-api: migrate to file-api remove file_manager stuff and migrate to file-api Signed-off-by: Chinmay Pai <chinmaydpai@gmail.com>
This commit is contained in:
parent
66922b9c8e
commit
905c0ff978
@ -405,9 +405,9 @@ def get_transaction_entries(filename, headers):
|
|||||||
from frappe.utils.xlsxutils import read_xlsx_file_from_attached_file
|
from frappe.utils.xlsxutils import read_xlsx_file_from_attached_file
|
||||||
rows = read_xlsx_file_from_attached_file(file_id=filename)
|
rows = read_xlsx_file_from_attached_file(file_id=filename)
|
||||||
elif (filename.lower().endswith("csv")):
|
elif (filename.lower().endswith("csv")):
|
||||||
from frappe.utils.file_manager import get_file_path
|
|
||||||
from frappe.utils.csvutils import read_csv_content
|
from frappe.utils.csvutils import read_csv_content
|
||||||
filepath = get_file_path(filename)
|
_file = frappe.get_doc("File", {"file_name": filename})
|
||||||
|
filepath = _file.get_full_path()
|
||||||
with open(filepath,'rb') as csvfile:
|
with open(filepath,'rb') as csvfile:
|
||||||
rows = read_csv_content(csvfile.read())
|
rows = read_csv_content(csvfile.read())
|
||||||
elif (filename.lower().endswith("xls")):
|
elif (filename.lower().endswith("xls")):
|
||||||
@ -427,8 +427,8 @@ def get_transaction_entries(filename, headers):
|
|||||||
return transactions
|
return transactions
|
||||||
|
|
||||||
def get_rows_from_xls_file(filename):
|
def get_rows_from_xls_file(filename):
|
||||||
from frappe.utils.file_manager import get_file_path
|
_file = frappe.get_doc("File", {"file_name": filename})
|
||||||
filepath = get_file_path(filename)
|
filepath = _file.get_full_path()
|
||||||
import xlrd
|
import xlrd
|
||||||
book = xlrd.open_workbook(filepath)
|
book = xlrd.open_workbook(filepath)
|
||||||
sheets = book.sheets()
|
sheets = book.sheets()
|
||||||
|
@ -10,7 +10,6 @@ import requests
|
|||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.frappeclient import FrappeClient
|
from frappe.frappeclient import FrappeClient
|
||||||
from frappe.desk.form.load import get_attachments
|
from frappe.desk.form.load import get_attachments
|
||||||
from frappe.utils.file_manager import get_file_path
|
|
||||||
from six import string_types
|
from six import string_types
|
||||||
|
|
||||||
current_user = frappe.session.user
|
current_user = frappe.session.user
|
||||||
|
@ -2,7 +2,7 @@ from __future__ import print_function, unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
import os
|
import os
|
||||||
from frappe.utils import get_files_path
|
from frappe.utils import get_files_path
|
||||||
from frappe.utils.file_manager import get_content_hash
|
from frappe.core.doctype.file.file import get_content_hash
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
files_path = get_files_path()
|
files_path = get_files_path()
|
||||||
|
@ -5,7 +5,6 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import cstr, getdate
|
from frappe.utils import cstr, getdate
|
||||||
from frappe.utils.file_manager import save_file
|
|
||||||
from .default_website import website_maker
|
from .default_website import website_maker
|
||||||
from erpnext.accounts.doctype.account.account import RootNotEditable
|
from erpnext.accounts.doctype.account.account import RootNotEditable
|
||||||
|
|
||||||
@ -107,10 +106,16 @@ def create_logo(args):
|
|||||||
attach_logo = args.get("attach_logo").split(",")
|
attach_logo = args.get("attach_logo").split(",")
|
||||||
if len(attach_logo)==3:
|
if len(attach_logo)==3:
|
||||||
filename, filetype, content = attach_logo
|
filename, filetype, content = attach_logo
|
||||||
fileurl = save_file(filename, content, "Website Settings", "Website Settings",
|
_file = frappe.get_doc({
|
||||||
decode=True).file_url
|
"doctype": "File",
|
||||||
|
"file_name": filename,
|
||||||
|
"attached_to_doctype": "Website Settings",
|
||||||
|
"attached_to_name": "Website Settings",
|
||||||
|
"decode": True})
|
||||||
|
_file.save()
|
||||||
|
fileurl = _file.file_url
|
||||||
frappe.db.set_value("Website Settings", "Website Settings", "brand_html",
|
frappe.db.set_value("Website Settings", "Website Settings", "brand_html",
|
||||||
"<img src='{0}' style='max-width: 40px; max-height: 25px;'> {1}".format(fileurl, args.get("company_name") ))
|
"<img src='{0}' style='max-width: 40px; max-height: 25px;'> {1}".format(fileurl, args.get("company_name")))
|
||||||
|
|
||||||
def create_website(args):
|
def create_website(args):
|
||||||
website_maker(args)
|
website_maker(args)
|
||||||
|
@ -256,7 +256,7 @@ class Item(WebsiteGenerator):
|
|||||||
"file_url": self.website_image,
|
"file_url": self.website_image,
|
||||||
"attached_to_doctype": "Item",
|
"attached_to_doctype": "Item",
|
||||||
"attached_to_name": self.name
|
"attached_to_name": self.name
|
||||||
}).insert()
|
}).save()
|
||||||
|
|
||||||
except IOError:
|
except IOError:
|
||||||
self.website_image = None
|
self.website_image = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user