From 392d3d00e4426caf956f86eec84a7d656c5fa9d9 Mon Sep 17 00:00:00 2001 From: "malte.vogl" Date: Wed, 2 Aug 2017 15:22:28 +0200 Subject: [PATCH] fix editors and authors --- eoa/tests.py | 1 + .../management/commands/_importer_class.py | 28 +++++++++---------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/eoa/tests.py b/eoa/tests.py index d40c08c..225c30e 100644 --- a/eoa/tests.py +++ b/eoa/tests.py @@ -110,6 +110,7 @@ def testCit(self): cit1 = Citation.objects.get(idstring = 'Mop1909') self.assertEqual(aut1.citations.get(pk = cit1.pk),cit1) self.assertEqual(cit1.__str__(), 'Mop1909: Testing citations') + print(cit1.citauthors.all()) class MixedContentModelTest(TestCase): diff --git a/publications/management/commands/_importer_class.py b/publications/management/commands/_importer_class.py index 25701d4..cdc0201 100644 --- a/publications/management/commands/_importer_class.py +++ b/publications/management/commands/_importer_class.py @@ -269,7 +269,7 @@ def createParagraphs(text,publication): print(parent) pass except: - print('Could not find parent element of: {0}'.format(paragraph)) + #print('Could not find parent element of: {0}'.format(paragraph)) pass parList.append(paraTemp) return parList @@ -282,20 +282,18 @@ def createCitations(text,publication): citTemp, created = Citation.objects.update_or_create( **cit ) - for author in aut: - if type(author)==dict: - autTemp, created = Author.objects.update_or_create( - **author - ) - autTemp.citations.add(citTemp) - autList.append(autTemp) - for editor in edi: - if type(editor)==dict: - ediTemp, created = Author.objects.update_or_create( - **editor - ) - ediTemp.editions.add(citTemp) - ediList.append(ediTemp) + for author in aut[1]: + autTemp, created = Author.objects.update_or_create( + **author + ) + autTemp.citations.add(citTemp) + autList.append(autTemp) + for editor in edi[1]: + ediTemp, created = Author.objects.update_or_create( + **editor + ) + ediTemp.editions.add(citTemp) + ediList.append(ediTemp) return (autList,ediList,cit) # print(cit['author']) # try: