mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Bankimport: Force re-annotation for badly parsed files
This commit is contained in:
@@ -13,6 +13,7 @@ def parse(data, hint):
|
||||
raise HintMismatchError('Invalid hint')
|
||||
if len(data[0]) != hint['cols']:
|
||||
raise HintMismatchError('Wrong column count')
|
||||
good_hint = False
|
||||
for row in data:
|
||||
resrow = {}
|
||||
if None in row or len(row) != hint['cols']:
|
||||
@@ -31,8 +32,10 @@ def parse(data, hint):
|
||||
or len(resrow['reference']) == 0 or resrow['date'] == '':
|
||||
# This is probably a headline or something other special.
|
||||
continue
|
||||
if resrow['reference'] or resrow['payer']:
|
||||
good_hint = True
|
||||
result.append(resrow)
|
||||
return result
|
||||
return result, good_hint
|
||||
|
||||
|
||||
def get_rows_from_file(file):
|
||||
|
||||
@@ -275,12 +275,14 @@ class ImportView(EventPermissionRequiredMixin, ListView):
|
||||
|
||||
if self.request.event.settings.get('banktransfer_csvhint') is not None:
|
||||
hint = self.request.event.settings.get('banktransfer_csvhint', as_type=dict)
|
||||
|
||||
try:
|
||||
parsed = csvimport.parse(data, hint)
|
||||
parsed, good = csvimport.parse(data, hint)
|
||||
except csvimport.HintMismatchError: # TODO: narrow down
|
||||
logger.exception('Import using stored hint failed')
|
||||
else:
|
||||
return self.start_processing(parsed)
|
||||
if good:
|
||||
return self.start_processing(parsed)
|
||||
|
||||
return self.assign_view(data)
|
||||
|
||||
@@ -308,7 +310,7 @@ class ImportView(EventPermissionRequiredMixin, ListView):
|
||||
logger.error('Import using stored hint failed: ' + str(e))
|
||||
pass
|
||||
else:
|
||||
parsed = csvimport.parse(data, hint)
|
||||
parsed, __ = csvimport.parse(data, hint)
|
||||
return self.start_processing(parsed)
|
||||
|
||||
def process_csv(self):
|
||||
|
||||
Reference in New Issue
Block a user