X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/967eed676fc83d15b26149047f353ac61faa8217..a409c6cc6901eea44c2cbe3a49038eb21f2db18d:/src/picture/migrations/0005_auto_20141022_1001.py?ds=sidebyside diff --git a/src/picture/migrations/0005_auto_20141022_1001.py b/src/picture/migrations/0005_auto_20141022_1001.py index 7f8d346ec..2d8f7b166 100644 --- a/src/picture/migrations/0005_auto_20141022_1001.py +++ b/src/picture/migrations/0005_auto_20141022_1001.py @@ -1,6 +1,7 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - +# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# +import json from django.core.files.base import ContentFile from django.db import models, migrations from django.template.loader import render_to_string @@ -12,14 +13,14 @@ def rebuild_extra_info(apps, schema_editor): from librarian import dcparser for pic in Picture.objects.all(): info = dcparser.parse(pic.xml_file.path, PictureInfo) - pic.extra_info = info.to_dict() - areas_json = pic.areas_json - for field in areas_json[u'things'].values(): - field[u'object'] = field[u'object'].capitalize() - pic.areas_json = areas_json + pic.extra_info = json.dumps(info.to_dict()) + areas_json = json.loads(pic.areas_json) + for field in areas_json['things'].values(): + field['object'] = field['object'].capitalize() + pic.areas_json = json.dumps(areas_json) html_text = render_to_string('picture/picture_info.html', { - 'things': pic.areas_json['things'], - 'themes': pic.areas_json['themes'], + 'things': areas_json['things'], + 'themes': areas_json['themes'], }) pic.html_file.save("%s.html" % pic.slug, ContentFile(html_text)) pic.save()