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
|
||||
rows = read_xlsx_file_from_attached_file(file_id=filename)
|
||||
elif (filename.lower().endswith("csv")):
|
||||
from frappe.utils.file_manager import get_file_path
|
||||
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:
|
||||
rows = read_csv_content(csvfile.read())
|
||||
elif (filename.lower().endswith("xls")):
|
||||
@ -427,8 +427,8 @@ def get_transaction_entries(filename, headers):
|
||||
return transactions
|
||||
|
||||
def get_rows_from_xls_file(filename):
|
||||
from frappe.utils.file_manager import get_file_path
|
||||
filepath = get_file_path(filename)
|
||||
_file = frappe.get_doc("File", {"file_name": filename})
|
||||
filepath = _file.get_full_path()
|
||||
import xlrd
|
||||
book = xlrd.open_workbook(filepath)
|
||||
sheets = book.sheets()
|
||||
|
@ -10,7 +10,6 @@ import requests
|
||||
from frappe import _
|
||||
from frappe.frappeclient import FrappeClient
|
||||
from frappe.desk.form.load import get_attachments
|
||||
from frappe.utils.file_manager import get_file_path
|
||||
from six import string_types
|
||||
|
||||
current_user = frappe.session.user
|
||||
|
@ -2,7 +2,7 @@ from __future__ import print_function, unicode_literals
|
||||
import frappe
|
||||
import os
|
||||
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():
|
||||
files_path = get_files_path()
|
||||
|
@ -5,7 +5,6 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import cstr, getdate
|
||||
from frappe.utils.file_manager import save_file
|
||||
from .default_website import website_maker
|
||||
from erpnext.accounts.doctype.account.account import RootNotEditable
|
||||
|
||||
@ -107,10 +106,16 @@ def create_logo(args):
|
||||
attach_logo = args.get("attach_logo").split(",")
|
||||
if len(attach_logo)==3:
|
||||
filename, filetype, content = attach_logo
|
||||
fileurl = save_file(filename, content, "Website Settings", "Website Settings",
|
||||
decode=True).file_url
|
||||
_file = frappe.get_doc({
|
||||
"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",
|
||||
"<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):
|
||||
website_maker(args)
|
||||
@ -121,4 +126,4 @@ def get_fy_details(fy_start_date, fy_end_date):
|
||||
fy = cstr(start_year)
|
||||
else:
|
||||
fy = cstr(start_year) + '-' + cstr(start_year + 1)
|
||||
return fy
|
||||
return fy
|
||||
|
@ -256,7 +256,7 @@ class Item(WebsiteGenerator):
|
||||
"file_url": self.website_image,
|
||||
"attached_to_doctype": "Item",
|
||||
"attached_to_name": self.name
|
||||
}).insert()
|
||||
}).save()
|
||||
|
||||
except IOError:
|
||||
self.website_image = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user