From d147e85723e8c9d3466c9b3d56288696b21a6ad8 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 14 Feb 2017 20:47:35 +0100 Subject: Importer: report bad configuration in a cleaner way --- ishtar_common/models.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'ishtar_common/models.py') diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 90e2bd6f6..c1edc13c6 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -22,6 +22,7 @@ Models description """ from cStringIO import StringIO import copy +import csv import datetime from PIL import Image from importlib import import_module @@ -2302,6 +2303,19 @@ class Import(models.Model): return bool(TargetKey.objects.filter(associated_import=self, is_set=False).count()) + @property + def errors(self): + if not self.error_file: + return [] + errors = [] + with open(self.error_file.path, 'rb') as csvfile: + reader = csv.DictReader(csvfile, fieldnames=['line', 'column', + 'error']) + reader.next() # pass the header + for row in reader: + errors.append(row) + return errors + def get_actions(self): """ Get available action relevant with the current status -- cgit v1.2.3