fix: Sider issues

This commit is contained in:
Faris Ansari 2020-05-30 00:18:39 +05:30
parent 7119179fa5
commit 4e669c218f
4 changed files with 13 additions and 17 deletions

View file

@ -10,7 +10,6 @@ from frappe.model import (
)
from frappe.utils.csvutils import build_csv_response
from frappe.utils.xlsxutils import build_xlsx_response
from frappe.core.doctype.data_import_beta.importer import INVALID_VALUES
class Exporter:
@ -152,8 +151,9 @@ class Exporter:
return rows
def get_data_as_docs(self):
format_column_name = lambda df: "`tab{0}`.`{1}`".format(df.parent, df.fieldname)
fields = [format_column_name(df) for df in self.fields]
def format_column_name(df):
return "`tab{0}`.`{1}`".format(df.parent, df.fieldname)
filters = self.export_filters
if self.meta.is_nested_set():

View file

@ -9,7 +9,7 @@ import timeit
import json
from datetime import datetime
from frappe import _
from frappe.utils import cint, flt, update_progress_bar, cstr, DATETIME_FORMAT
from frappe.utils import cint, flt, update_progress_bar, cstr
from frappe.utils.csvutils import read_csv_content
from frappe.utils.xlsxutils import (
read_xlsx_file_from_attached_file,
@ -79,7 +79,7 @@ class Importer:
import_log = []
# remove previous failures from import log
import_log = [l for l in import_log if l.get("success") == True]
import_log = [log for log in import_log if log.get("success")]
# get successfully imported rows
imported_rows = []
@ -160,7 +160,7 @@ class Importer:
frappe.db.rollback()
# set status
failures = [l for l in import_log if l.get("success") == False]
failures = [log for log in import_log if not log.get("success")]
if len(failures) == total_payload_count:
status = "Pending"
elif len(failures) > 0:
@ -235,7 +235,7 @@ class Importer:
return
import_log = frappe.parse_json(self.data_import.import_log or "[]")
failures = [l for l in import_log if l.get("success") == False]
failures = [log for log in import_log if not log.get("success")]
row_indexes = []
for f in failures:
row_indexes.extend(f.get("row_indexes", []))
@ -397,7 +397,6 @@ class ImportFile:
# if any of those conditions dont match, it's the next doc
break
parsed_docs = {}
parent_doc = None
for row in rows:
for doctype, table_df in doctypes:
@ -774,7 +773,6 @@ class Column:
def parse(self):
header_title = self.header_title
header_row_index = str(self.index)
column_number = str(self.column_number)
skip_import = False
@ -849,10 +847,9 @@ class Column:
self.date_format = self.guess_date_format_for_column()
def guess_date_format_for_column(self):
""" Guesses date format for a column by parsing the first 100 values in the column,
""" Guesses date format for a column by parsing all the values in the column,
getting the date format and then returning the one which has the maximum frequency
"""
PARSE_ROW_COUNT = 100
date_formats = [
frappe.utils.guess_date_format(d) for d in self.column_values if isinstance(d, str)

View file

@ -3,10 +3,8 @@
# See license.txt
from __future__ import unicode_literals
import datetime
import unittest
import frappe
from frappe.core.doctype.data_import_beta.importer import Importer
from frappe.utils import getdate
doctype_name = 'DocType for Import'
@ -41,6 +39,9 @@ class TestImporter(unittest.TestCase):
self.assertEqual(doc1.table_field_1_again[1].child_title, 'child title again 2')
self.assertEqual(doc1.table_field_1_again[1].child_date, getdate('2021-09-22'))
self.assertEqual(doc2.description, 'test description 2')
self.assertEqual(doc3.another_number, 5)
def test_data_import_preview(self):
import_file = get_import_file('sample_import_file')
data_import = self.get_importer(doctype_name, import_file)

View file

@ -101,10 +101,8 @@ frappe.data_import.DataExporter = class DataExporter {
let doctype = df.options;
let child_fieldname = df.fieldname;
let label = df.reqd
? __('{0} ({1}) (1 row mandatory)', [
df.label || df.fieldname,
doctype
])
? // prettier-ignore
__('{0} ({1}) (1 row mandatory)', [df.label || df.fieldname, doctype])
: __('{0} ({1})', [df.label || df.fieldname, doctype]);
return {
label,