diff --git a/openslides/motion/csv_import.py b/openslides/motion/csv_import.py
index 7bf0583f5..aeb6a35e3 100644
--- a/openslides/motion/csv_import.py
+++ b/openslides/motion/csv_import.py
@@ -27,8 +27,6 @@ def import_motions(csv_file, default_submitter, override=False, importing_person
when the flag 'override' is true. If no or multiple categories found,
the category is set to None.
"""
- error_messages = []
- warning_messages = []
count_success = 0
count_lines = 0
@@ -43,20 +41,21 @@ def import_motions(csv_file, default_submitter, override=False, importing_person
dialect = csv.Sniffer().sniff(csv_file.readline())
dialect = csv_ext.patchup(dialect)
csv_file.seek(0)
+ all_error_messages = []
+ all_warning_messages = []
for (line_no, line) in enumerate(csv.reader(csv_file, dialect=dialect)):
- warnings = []
+ warning = []
if line_no < 1:
# Do not read the header line
continue
-
+ importline = html_strong(_('Line %d:') % (line_no + 1))
count_lines += 1
# Check format
try:
(identifier, title, text, reason, submitter, category) = line[:6]
except ValueError:
- error_line = html_strong(_('Line %d of import file:') % (line_no + 1))
msg = _('Line is malformed. Motion not imported. Please check the required values.')
- error_messages.append("%s
%s" % (error_line, msg))
+ all_error_messages.append("%s %s" % (importline, msg))
continue
# Check existing motions according to the identifier
@@ -67,9 +66,8 @@ def import_motions(csv_file, default_submitter, override=False, importing_person
motion = Motion(identifier=identifier)
else:
if not override:
- error_line = html_strong(_('Line %d of import file:') % (line_no + 1))
msg = _('Identifier already exists. Motion not imported.')
- error_messages.append("%s
%s" % (error_line, msg))
+ all_error_messages.append("%s %s" % (importline, msg))
continue
else:
motion = Motion()
@@ -82,9 +80,9 @@ def import_motions(csv_file, default_submitter, override=False, importing_person
try:
motion.category = Category.objects.get(name=category)
except Category.DoesNotExist:
- warnings.append(_('Category unknown. No category is used.'))
+ warning.append(_('Category unknown. No category is used.'))
except Category.MultipleObjectsReturned:
- warnings.append(_('Several suitable categories found. No category is used.'))
+ warning.append(_('Several suitable categories found. No category is used.'))
motion.save()
# Add submitter
@@ -93,24 +91,22 @@ def import_motions(csv_file, default_submitter, override=False, importing_person
for person in Persons():
if person.clean_name == submitter.decode('utf8'):
if person_found:
- warnings.append(_('Several suitable submitters found.'))
+ warning.append(_('Several suitable submitters found.'))
person_found = False
break
else:
new_submitter = person
person_found = True
if not person_found:
- warnings.append(_('Submitter unknown. Default submitter is used.'))
+ warning.append(_('Submitter unknown. Default submitter is used.'))
new_submitter = default_submitter
- # show summarized warning message for each import line
- if warnings:
- warning_line = _('Line %d of import file:') % (line_no + 1)
- warning_message_string = "%s