X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/e7c8c7e1fd0fe2eb867b26ae205b75822204a45f..013ec8a416d4ff1ea3e1f2fa9ee2935623197ecd:/apps/picture/migrations/0005_auto_20141022_1001.py diff --git a/apps/picture/migrations/0005_auto_20141022_1001.py b/apps/picture/migrations/0005_auto_20141022_1001.py index e5e87387c..677877eae 100644 --- a/apps/picture/migrations/0005_auto_20141022_1001.py +++ b/apps/picture/migrations/0005_auto_20141022_1001.py @@ -1,7 +1,10 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +from django.core.files.base import ContentFile from django.db import models, migrations +from django.template.loader import render_to_string + def rebuild_extra_info(apps, schema_editor): Picture = apps.get_model("picture", "Picture") @@ -10,6 +13,15 @@ def rebuild_extra_info(apps, schema_editor): 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 + html_text = unicode(render_to_string('picture/picture_info.html', { + 'things': pic.areas_json['things'], + 'themes': pic.areas_json['themes'], + })) + pic.html_file.save("%s.html" % pic.slug, ContentFile(html_text)) pic.save()