Parse specific titles field in application importer.
@@ -28,15 +28,25 @@ class Command(BaseCommand):
next(reader, None) # skip the headers
for row in reader:
try:
- # If the collections field is empty, make it an emtpy list
+ # If the collections field is empty, make it a list containing an empty string.
if row[4] in (None, ""):
specific_stream_ids = ['']
# Otherwise try to split it on comma
else:
specific_stream_ids = row[4].split(',')
+ # If the title field is empty, make it a list containing an empty string.
+ if row[5] in (None, ""):
+ specific_titles = ['']
+ # Otherwise try to split it on semicolon
+ else:
+ specific_titles = row[5].split(';')
+
for specific_stream_id in specific_stream_ids:
- # Where possible we're fetching the objects attaChed
+
+ for specific_title in specific_titles:
+
+ # Where possible we're fetching the objects attached
# to our attributes to verify they already exist.
partner_id = row[0]
@@ -86,6 +96,7 @@ class Command(BaseCommand):
date_closed = date_created,
editor_id = editor_id,
specific_stream_id = specific_stream_id,
+ specific_title = specific_title,
status = 4
)
except Application.DoesNotExist:
@@ -95,6 +106,7 @@ class Command(BaseCommand):
date_closed = date_created,
editor_id = editor_id,
specific_stream_id = specific_stream_id,
+ specific_title = specific_title,
comments = import_note,
rationale = import_note,
imported = True,
