Merge branch 'master' into sync

This commit is contained in:
Anand Doshi 2012-02-29 14:09:29 +05:30
commit 3b48663ffb
2 changed files with 13 additions and 5 deletions

View file

@ -365,7 +365,6 @@ class CSVImport:
self.csv_data = self.convert_csv_data_into_list(csv.reader(csv_data.splitlines()))
self.import_date_format, self.overwrite = import_date_format, overwrite
if len(self.csv_data) > 4:
self.doctype_data, self.labels, self.data = self.csv_data[0][:4], self.csv_data[3], self.csv_data[4:]
self.fields = []
@ -378,12 +377,20 @@ class CSVImport:
self.validate_data()
else:
self.msg.append('<p><b>No data entered in file.</b></p>')
return '\n'.join([m.encode('utf-8') for m in self.msg])
try:
out_utf8 = '\n'.join([m.encode('utf-8') for m in self.msg])
except UnicodeEncodeError, e:
out_utf8 = """<div>We are unable to detect the encoding of the
given .csv file. Please save the .csv file with UTF-8
encoding. (See Data Import Guide -- Do you have Non-English data?)</div>"""
return out_utf8
def convert_csv_data_into_list(self,csv_data):
st_list = []
for s in csv_data:
st_list.append([unicode(d, 'utf-8').strip() for d in s])
st_list.append([d.strip() for d in s])
return st_list
# Get Template method

View file

@ -67,6 +67,7 @@ def get_link_fields(doctype):
#=================================================================================
def get_table_fields(doctype):
return webnotes.conn.sql("select options, fieldname from tabDocField where parent='%s' and fieldtype='Table'" % doctype)
return webnotes.conn.sql("select options, fieldname from tabDocField \
where parent='%s' and fieldtype='Table'" % doctype, as_list=1)