Django 2.0
[wolnelektury.git] / src / isbn / management / commands / export_onix.py
index 19f3166..860bc79 100644 (file)
@@ -1,5 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
+import json
 from django.core.management.base import BaseCommand
 from django.utils import timezone
 
 from django.core.management.base import BaseCommand
 from django.utils import timezone
 
@@ -113,7 +112,7 @@ class Command(BaseCommand):
         for record in ONIXRecord.objects.all():
             xml += self.render_product(record)
         xml += FOOTER
         for record in ONIXRecord.objects.all():
             xml += self.render_product(record)
         xml += FOOTER
-        print xml.encode('utf-8')
+        print(xml)
 
     def render_product(self, record):
         if record.product_form_detail:
 
     def render_product(self, record):
         if record.product_form_detail:
@@ -125,7 +124,7 @@ class Command(BaseCommand):
         else:
             part_number = ''
         contributors = ''
         else:
             part_number = ''
         contributors = ''
-        for no, contributor in enumerate(record.contributors, start=1):
+        for no, contributor in enumerate(json.loads(record.contributors), start=1):
             contributors += self.render_contributor(no, contributor)
         return PRODUCT % {
             'datestamp': record.datestamp.strftime('%Y%m%d'),
             contributors += self.render_contributor(no, contributor)
         return PRODUCT % {
             'datestamp': record.datestamp.strftime('%Y%m%d'),